mirror of
https://github.com/nextcloud/android.git
synced 2024-12-21 08:24:08 +03:00
set on click listener
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
8b58685e1f
commit
ba9377fdae
3 changed files with 31 additions and 39 deletions
|
@ -440,7 +440,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
// TODO use actual data
|
||||
ArrayList<Recommendation> mockData = new ArrayList<>(Arrays.asList(
|
||||
new Recommendation(
|
||||
1L,
|
||||
2124L,
|
||||
System.currentTimeMillis(),
|
||||
"Document1",
|
||||
"/documents",
|
||||
|
@ -450,7 +450,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
"Recently opened"
|
||||
),
|
||||
new Recommendation(
|
||||
2L,
|
||||
2130L,
|
||||
System.currentTimeMillis() - 3600000,
|
||||
"Image1",
|
||||
"/pictures",
|
||||
|
@ -460,7 +460,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
"Frequently viewed"
|
||||
),
|
||||
new Recommendation(
|
||||
3L,
|
||||
2131L,
|
||||
System.currentTimeMillis() - 7200000,
|
||||
"Presentation1",
|
||||
"/presentations",
|
||||
|
@ -470,27 +470,18 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
"Shared with you"
|
||||
),
|
||||
new Recommendation(
|
||||
4L,
|
||||
System.currentTimeMillis() - 86400000,
|
||||
"Video1",
|
||||
"/videos",
|
||||
"mp4",
|
||||
"video/mp4",
|
||||
true,
|
||||
"Recent download"
|
||||
),
|
||||
new Recommendation(
|
||||
5L,
|
||||
System.currentTimeMillis() - 604800000,
|
||||
"Spreadsheet1",
|
||||
"/spreadsheets",
|
||||
"xlsx",
|
||||
"application/vnd.ms-excel",
|
||||
2126L,
|
||||
System.currentTimeMillis() - 7200000,
|
||||
"Presentation1",
|
||||
"/presentations",
|
||||
"pptx",
|
||||
"application/vnd.ms-powerpoint",
|
||||
false,
|
||||
"Marked as important"
|
||||
)));
|
||||
"Shared with you"
|
||||
))
|
||||
);
|
||||
|
||||
final var adapter = new RecommendedFilesAdapter(activity, mockData, ocFileListDelegate, this);
|
||||
final var adapter = new RecommendedFilesAdapter(activity, mockData, ocFileListDelegate, this, mStorageManager);
|
||||
recommendedFiles.setAdapter(adapter);
|
||||
|
||||
PreviewTextFragment.setText(headerViewHolder.getHeaderText(), text, null, activity, true, true, viewThemeUtils);
|
||||
|
@ -1323,12 +1314,12 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
}
|
||||
|
||||
@Override
|
||||
public void selectRecommendedFile(long fileId) {
|
||||
// TODO Implement
|
||||
public void selectRecommendedFile(@NonNull OCFile file) {
|
||||
ocFileListFragmentInterface.onItemClicked(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showRecommendedFileMoreActions(long fileId) {
|
||||
// TODO Implement
|
||||
public void showRecommendedFileMoreActions(@NonNull OCFile file, @NonNull View view) {
|
||||
ocFileListFragmentInterface.onOverflowIconClicked(file, view);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,13 +195,7 @@ class OCFileListDelegate(
|
|||
}
|
||||
}
|
||||
|
||||
fun setThumbnailFromFileId(thumbnail: ImageView, shimmerThumbnail: LoaderImageView?, fileId: Long) {
|
||||
storageManager.getFileById(fileId)?.let { file ->
|
||||
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,
|
||||
|
|
|
@ -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<Recommendation>,
|
||||
private val delegate: OCFileListDelegate,
|
||||
private val onItemClickListener: OnItemClickListener
|
||||
private val onItemClickListener: OnItemClickListener,
|
||||
private val storageManager: FileDataStorageManager
|
||||
) : RecyclerView.Adapter<RecommendedFilesAdapter.RecommendedFilesViewHolder>() {
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue