setOnClickListener

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-12-16 15:19:08 +01:00
parent 4cc2316578
commit 707ebaed9f
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
3 changed files with 29 additions and 13 deletions

View file

@ -108,7 +108,7 @@ import me.zhanghai.android.fastscroll.PopupTextProvider;
*/ */
public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
implements DisplayUtils.AvatarGenerationListener, implements DisplayUtils.AvatarGenerationListener,
CommonOCFileListAdapterInterface, PopupTextProvider { CommonOCFileListAdapterInterface, PopupTextProvider, RecommendedFilesAdapter.OnItemClickListener {
private static final int showFilenameColumnThreshold = 4; private static final int showFilenameColumnThreshold = 4;
private final String userId; private final String userId;
@ -490,7 +490,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
"Marked as important" "Marked as important"
))); )));
final var adapter = new RecommendedFilesAdapter(activity, mockData, ocFileListDelegate); final var adapter = new RecommendedFilesAdapter(activity, mockData, ocFileListDelegate, this);
recommendedFiles.setAdapter(adapter); recommendedFiles.setAdapter(adapter);
PreviewTextFragment.setText(headerViewHolder.getHeaderText(), text, null, activity, true, true, viewThemeUtils); 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) { public void notifyItemChanged(@NonNull OCFile file) {
notifyItemChanged(getItemPosition(file)); notifyItemChanged(getItemPosition(file));
} }
@Override
public void selectRecommendedFile(long fileId) {
// TODO Implement
}
@Override
public void showRecommendedFileMoreActions(long fileId) {
// TODO Implement
}
} }

View file

@ -29,21 +29,18 @@ data class Recommendation(
class RecommendedFilesAdapter( class RecommendedFilesAdapter(
private val context: Context, private val context: Context,
private val recommendations: List<Recommendation>, private val recommendations: List<Recommendation>,
private val delegate: OCFileListDelegate private val delegate: OCFileListDelegate,
private val onItemClickListener: OnItemClickListener
) : RecyclerView.Adapter<RecommendedFilesAdapter.RecommendedFilesViewHolder>() { ) : RecyclerView.Adapter<RecommendedFilesAdapter.RecommendedFilesViewHolder>() {
inner class RecommendedFilesViewHolder(val binding: RecommendedFilesListItemBinding) : interface OnItemClickListener {
RecyclerView.ViewHolder(binding.root) { fun selectRecommendedFile(fileId: Long)
init { fun showRecommendedFileMoreActions(fileId: Long)
binding.root.setOnClickListener {
val position = bindingAdapterPosition
if (position != RecyclerView.NO_POSITION) {
// TODO onclick item
}
}
}
} }
inner class RecommendedFilesViewHolder(val binding: RecommendedFilesListItemBinding) :
RecyclerView.ViewHolder(binding.root)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecommendedFilesViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecommendedFilesViewHolder {
val binding = RecommendedFilesListItemBinding val binding = RecommendedFilesListItemBinding
.inflate(LayoutInflater.from(parent.context), parent, false) .inflate(LayoutInflater.from(parent.context), parent, false)
@ -59,6 +56,14 @@ class RecommendedFilesAdapter(
name.text = item.name name.text = item.name
timestamp.text = DisplayUtils.getRelativeTimestamp(context, item.timestamp) timestamp.text = DisplayUtils.getRelativeTimestamp(context, item.timestamp)
delegate.setThumbnailFromFileId(thumbnail, shimmerThumbnail, item.id) delegate.setThumbnailFromFileId(thumbnail, shimmerThumbnail, item.id)
container.setOnClickListener {
onItemClickListener.selectRecommendedFile(item.id)
}
moreAction.setOnClickListener {
onItemClickListener.showRecommendedFileMoreActions(item.id)
}
} }
} }
} }

View file

@ -27,6 +27,7 @@
android:src="@drawable/file" /> android:src="@drawable/file" />
<ImageButton <ImageButton
android:id="@+id/more_action"
android:src="@drawable/ic_dots_horizontal" android:src="@drawable/ic_dots_horizontal"
android:contentDescription="@string/preview_image_description" android:contentDescription="@string/preview_image_description"
android:background="@drawable/ic_circle" android:background="@drawable/ic_circle"