From 860e7d3f4e2354c51bd46d96e4763ec85d8c6111 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 16 Dec 2024 16:19:21 +0100 Subject: [PATCH] set on click listener Signed-off-by: alperozturk --- .../android/ui/adapter/OCFileListAdapter.java | 43 ++++++++----------- .../android/ui/adapter/OCFileListDelegate.kt | 8 +--- .../ui/adapter/RecommendedFilesAdapter.kt | 19 +++++--- 3 files changed, 31 insertions(+), 39 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 6577efc9a6..3643fc0ea7 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 @@ -440,7 +440,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter mockData = new ArrayList<>(Arrays.asList( new Recommendation( - 1L, + 2124L, System.currentTimeMillis(), "Document1", "/documents", @@ -450,7 +450,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter - setThumbnail(thumbnail, shimmerThumbnail, file) - } - } - - private fun setThumbnail(thumbnail: ImageView, shimmerThumbnail: LoaderImageView?, file: OCFile) { + fun setThumbnail(thumbnail: ImageView, shimmerThumbnail: LoaderImageView?, file: OCFile) { DisplayUtils.setThumbnail( file, thumbnail, diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/RecommendedFilesAdapter.kt b/app/src/main/java/com/owncloud/android/ui/adapter/RecommendedFilesAdapter.kt index 7c2698860d..c94fcaa7a4 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/RecommendedFilesAdapter.kt +++ b/app/src/main/java/com/owncloud/android/ui/adapter/RecommendedFilesAdapter.kt @@ -9,9 +9,12 @@ package com.owncloud.android.ui.adapter import android.content.Context import android.view.LayoutInflater +import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.owncloud.android.databinding.RecommendedFilesListItemBinding +import com.owncloud.android.datamodel.FileDataStorageManager +import com.owncloud.android.datamodel.OCFile import com.owncloud.android.utils.DisplayUtils // TODO delete mock data @@ -30,12 +33,13 @@ class RecommendedFilesAdapter( private val context: Context, private val recommendations: List, private val delegate: OCFileListDelegate, - private val onItemClickListener: OnItemClickListener + private val onItemClickListener: OnItemClickListener, + private val storageManager: FileDataStorageManager ) : RecyclerView.Adapter() { interface OnItemClickListener { - fun selectRecommendedFile(fileId: Long) - fun showRecommendedFileMoreActions(fileId: Long) + fun selectRecommendedFile(file: OCFile) + fun showRecommendedFileMoreActions(file: OCFile, view: View) } inner class RecommendedFilesViewHolder(val binding: RecommendedFilesListItemBinding) : @@ -55,14 +59,17 @@ class RecommendedFilesAdapter( holder.binding.run { name.text = item.name timestamp.text = DisplayUtils.getRelativeTimestamp(context, item.timestamp) - delegate.setThumbnailFromFileId(thumbnail, shimmerThumbnail, item.id) + + val file = storageManager.getFileById(item.id) ?: return + + delegate.setThumbnail(thumbnail, shimmerThumbnail, file) container.setOnClickListener { - onItemClickListener.selectRecommendedFile(item.id) + onItemClickListener.selectRecommendedFile(file) } moreAction.setOnClickListener { - onItemClickListener.showRecommendedFileMoreActions(item.id) + onItemClickListener.showRecommendedFileMoreActions(file, holder.itemView) } } }