mirror of
https://github.com/nextcloud/android.git
synced 2024-12-18 23:11:58 +03:00
setOnClickListener
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
a25b10347c
commit
3ebf65aa66
3 changed files with 29 additions and 13 deletions
|
@ -108,7 +108,7 @@ import me.zhanghai.android.fastscroll.PopupTextProvider;
|
|||
*/
|
||||
public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
implements DisplayUtils.AvatarGenerationListener,
|
||||
CommonOCFileListAdapterInterface, PopupTextProvider {
|
||||
CommonOCFileListAdapterInterface, PopupTextProvider, RecommendedFilesAdapter.OnItemClickListener {
|
||||
|
||||
private static final int showFilenameColumnThreshold = 4;
|
||||
private final String userId;
|
||||
|
@ -490,7 +490,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
"Marked as important"
|
||||
)));
|
||||
|
||||
final var adapter = new RecommendedFilesAdapter(activity, mockData, ocFileListDelegate);
|
||||
final var adapter = new RecommendedFilesAdapter(activity, mockData, ocFileListDelegate, this);
|
||||
recommendedFiles.setAdapter(adapter);
|
||||
|
||||
PreviewTextFragment.setText(headerViewHolder.getHeaderText(), text, null, activity, true, true, viewThemeUtils);
|
||||
|
@ -1321,4 +1321,14 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
public void notifyItemChanged(@NonNull OCFile file) {
|
||||
notifyItemChanged(getItemPosition(file));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectRecommendedFile(long fileId) {
|
||||
// TODO Implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showRecommendedFileMoreActions(long fileId) {
|
||||
// TODO Implement
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,21 +29,18 @@ data class Recommendation(
|
|||
class RecommendedFilesAdapter(
|
||||
private val context: Context,
|
||||
private val recommendations: List<Recommendation>,
|
||||
private val delegate: OCFileListDelegate
|
||||
private val delegate: OCFileListDelegate,
|
||||
private val onItemClickListener: OnItemClickListener
|
||||
) : RecyclerView.Adapter<RecommendedFilesAdapter.RecommendedFilesViewHolder>() {
|
||||
|
||||
inner class RecommendedFilesViewHolder(val binding: RecommendedFilesListItemBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
binding.root.setOnClickListener {
|
||||
val position = bindingAdapterPosition
|
||||
if (position != RecyclerView.NO_POSITION) {
|
||||
// TODO onclick item
|
||||
}
|
||||
}
|
||||
}
|
||||
interface OnItemClickListener {
|
||||
fun selectRecommendedFile(fileId: Long)
|
||||
fun showRecommendedFileMoreActions(fileId: Long)
|
||||
}
|
||||
|
||||
inner class RecommendedFilesViewHolder(val binding: RecommendedFilesListItemBinding) :
|
||||
RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecommendedFilesViewHolder {
|
||||
val binding = RecommendedFilesListItemBinding
|
||||
.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
|
@ -59,6 +56,14 @@ class RecommendedFilesAdapter(
|
|||
name.text = item.name
|
||||
timestamp.text = DisplayUtils.getRelativeTimestamp(context, item.timestamp)
|
||||
delegate.setThumbnailFromFileId(thumbnail, shimmerThumbnail, item.id)
|
||||
|
||||
container.setOnClickListener {
|
||||
onItemClickListener.selectRecommendedFile(item.id)
|
||||
}
|
||||
|
||||
moreAction.setOnClickListener {
|
||||
onItemClickListener.showRecommendedFileMoreActions(item.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
android:src="@drawable/file" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/more_action"
|
||||
android:src="@drawable/ic_dots_horizontal"
|
||||
android:contentDescription="@string/preview_image_description"
|
||||
android:background="@drawable/ic_circle"
|
||||
|
|
Loading…
Reference in a new issue