Skip to content

Commit

Permalink
setOnClickListener
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Dec 16, 2024
1 parent db53719 commit e8e9897
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
*/
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;
Expand Down Expand Up @@ -490,7 +490,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
"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);
Expand Down Expand Up @@ -1321,4 +1321,14 @@ public int getFilesCount() {
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,18 @@ 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>() {

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)
Expand All @@ -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)
}
}
}
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/recommended_files_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e8e9897

Please sign in to comment.