From 3ebf65aa669c174e8fa75ecc7419196699b098a8 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 16 Dec 2024 15:19:08 +0100 Subject: [PATCH] setOnClickListener Signed-off-by: alperozturk --- .../android/ui/adapter/OCFileListAdapter.java | 14 ++++++++-- .../ui/adapter/RecommendedFilesAdapter.kt | 27 +++++++++++-------- .../layout/recommended_files_list_item.xml | 1 + 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java index 270d8df4e8..6577efc9a6 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java @@ -108,7 +108,7 @@ import me.zhanghai.android.fastscroll.PopupTextProvider; */ public class OCFileListAdapter extends RecyclerView.Adapter 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, - private val delegate: OCFileListDelegate + private val delegate: OCFileListDelegate, + private val onItemClickListener: OnItemClickListener ) : RecyclerView.Adapter() { - 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) + } } } } diff --git a/app/src/main/res/layout/recommended_files_list_item.xml b/app/src/main/res/layout/recommended_files_list_item.xml index 529687bfd3..c4d18e463d 100644 --- a/app/src/main/res/layout/recommended_files_list_item.xml +++ b/app/src/main/res/layout/recommended_files_list_item.xml @@ -27,6 +27,7 @@ android:src="@drawable/file" />