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>
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
}
}

View file

@ -29,20 +29,17 @@ 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>() {
interface OnItemClickListener {
fun selectRecommendedFile(fileId: Long)
fun showRecommendedFileMoreActions(fileId: Long)
}
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
}
}
}
}
RecyclerView.ViewHolder(binding.root)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecommendedFilesViewHolder {
val binding = RecommendedFilesListItemBinding
@ -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)
}
}
}
}

View file

@ -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"