Rename view holder interface for prevent confusion

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-08-15 15:55:48 +02:00
parent 5dab3e81fb
commit 8f0da11fb6
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
5 changed files with 25 additions and 25 deletions

View file

@ -9,6 +9,6 @@ package com.owncloud.android.ui.adapter
import android.widget.TextView import android.widget.TextView
internal interface ListGridItemViewHolder : ListGridImageViewHolder { internal interface ListGridItemViewHolder : ListViewHolder {
val fileName: TextView val fileName: TextView
} }

View file

@ -14,7 +14,7 @@ import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import com.elyeproj.loaderviewlibrary.LoaderImageView import com.elyeproj.loaderviewlibrary.LoaderImageView
interface ListGridImageViewHolder { interface ListViewHolder {
val thumbnail: ImageView val thumbnail: ImageView
fun showVideoOverlay() fun showVideoOverlay()
val shimmerThumbnail: LoaderImageView val shimmerThumbnail: LoaderImageView

View file

@ -99,8 +99,8 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
private static final int showFilenameColumnThreshold = 4; private static final int showFilenameColumnThreshold = 4;
private final String userId; private final String userId;
private Activity activity; private final Activity activity;
private AppPreferences preferences; private final AppPreferences preferences;
private List<OCFile> mFiles = new ArrayList<>(); private List<OCFile> mFiles = new ArrayList<>();
private List<OCFile> mFilesAll = new ArrayList<>(); private List<OCFile> mFilesAll = new ArrayList<>();
private boolean hideItemOptions; private boolean hideItemOptions;
@ -109,7 +109,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
public ArrayList<String> listOfHiddenFiles = new ArrayList<>(); public ArrayList<String> listOfHiddenFiles = new ArrayList<>();
private FileDataStorageManager mStorageManager; private FileDataStorageManager mStorageManager;
private User user; private User user;
private OCFileListFragmentInterface ocFileListFragmentInterface; private final OCFileListFragmentInterface ocFileListFragmentInterface;
private OCFile currentDirectory; private OCFile currentDirectory;
@ -384,7 +384,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} }
case VIEWTYPE_IMAGE -> { case VIEWTYPE_IMAGE -> {
if (gridView) { if (gridView) {
return new OCFileListGridImageViewHolder( return new OCFileListViewHolder(
GridImageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false) GridImageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false)
); );
} else { } else {
@ -425,7 +425,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
PreviewTextFragment.setText(headerViewHolder.getHeaderText(), text, null, activity, true, true, viewThemeUtils); PreviewTextFragment.setText(headerViewHolder.getHeaderText(), text, null, activity, true, true, viewThemeUtils);
headerViewHolder.getHeaderView().setOnClickListener(v -> ocFileListFragmentInterface.onHeaderClicked()); headerViewHolder.getHeaderView().setOnClickListener(v -> ocFileListFragmentInterface.onHeaderClicked());
} else { } else {
ListGridImageViewHolder gridViewHolder = (ListGridImageViewHolder) holder; ListViewHolder gridViewHolder = (ListViewHolder) holder;
OCFile file = getItem(position); OCFile file = getItem(position);
if (file == null) { if (file == null) {
@ -451,7 +451,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} }
} }
private void checkVisibilityOfFileFeaturesLayout(ListGridImageViewHolder holder) { private void checkVisibilityOfFileFeaturesLayout(ListViewHolder holder) {
int fileFeaturesVisibility = View.GONE; int fileFeaturesVisibility = View.GONE;
LinearLayout fileFeaturesLayout = holder.getFileFeaturesLayout(); LinearLayout fileFeaturesLayout = holder.getFileFeaturesLayout();
@ -469,7 +469,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
fileFeaturesLayout.setVisibility(fileFeaturesVisibility); fileFeaturesLayout.setVisibility(fileFeaturesVisibility);
} }
private void checkVisibilityOfMoreButtons(ListGridImageViewHolder holder) { private void checkVisibilityOfMoreButtons(ListViewHolder holder) {
ImageButton moreButton = holder.getMore(); ImageButton moreButton = holder.getMore();
if (moreButton == null) { if (moreButton == null) {
return; return;
@ -509,13 +509,13 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
filesToRemove.clear(); filesToRemove.clear();
} }
private void updateLivePhotoIndicators(ListGridImageViewHolder holder, OCFile file) { private void updateLivePhotoIndicators(ListViewHolder holder, OCFile file) {
boolean isLivePhoto = file.getLinkedFileIdForLivePhoto() != null; boolean isLivePhoto = file.getLinkedFileIdForLivePhoto() != null;
if (holder instanceof OCFileListItemViewHolder) { if (holder instanceof OCFileListItemViewHolder) {
holder.getLivePhotoIndicator().setVisibility(isLivePhoto ? (View.VISIBLE) : (View.GONE)); holder.getLivePhotoIndicator().setVisibility(isLivePhoto ? (View.VISIBLE) : (View.GONE));
holder.getLivePhotoIndicatorSeparator().setVisibility(isLivePhoto ? (View.VISIBLE) : (View.GONE)); holder.getLivePhotoIndicatorSeparator().setVisibility(isLivePhoto ? (View.VISIBLE) : (View.GONE));
} else if (holder instanceof OCFileListGridImageViewHolder) { } else if (holder instanceof OCFileListViewHolder) {
holder.getGridLivePhotoIndicator().setVisibility(isLivePhoto ? (View.VISIBLE) : (View.GONE)); holder.getGridLivePhotoIndicator().setVisibility(isLivePhoto ? (View.VISIBLE) : (View.GONE));
} }
} }
@ -669,7 +669,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
setColorFilterForOfflineOperations(holder, file); setColorFilterForOfflineOperations(holder, file);
} }
private void setColorFilterForOfflineOperations(ListGridImageViewHolder holder, OCFile file) { private void setColorFilterForOfflineOperations(ListViewHolder holder, OCFile file) {
if (!file.isFolder()) { if (!file.isFolder()) {
return; return;
} }
@ -684,8 +684,8 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
@Override @Override
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) { public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
if (holder instanceof ListGridImageViewHolder) { if (holder instanceof ListViewHolder) {
LoaderImageView thumbnailShimmer = ((ListGridImageViewHolder) holder).getShimmerThumbnail(); LoaderImageView thumbnailShimmer = ((ListViewHolder) holder).getShimmerThumbnail();
if (thumbnailShimmer.getVisibility() == View.VISIBLE) { if (thumbnailShimmer.getVisibility() == View.VISIBLE) {
thumbnailShimmer.setImageResource(R.drawable.background); thumbnailShimmer.setImageResource(R.drawable.background);
thumbnailShimmer.resetLoader(); thumbnailShimmer.resetLoader();

View file

@ -195,7 +195,7 @@ class OCFileListDelegate(
} }
fun bindGridViewHolder( fun bindGridViewHolder(
gridViewHolder: ListGridImageViewHolder, gridViewHolder: ListViewHolder,
file: OCFile, file: OCFile,
currentDirectory: OCFile?, currentDirectory: OCFile?,
searchType: SearchType? searchType: SearchType?
@ -253,7 +253,7 @@ class OCFileListDelegate(
} }
} }
private fun bindUnreadComments(file: OCFile, gridViewHolder: ListGridImageViewHolder) { private fun bindUnreadComments(file: OCFile, gridViewHolder: ListViewHolder) {
if (file.unreadCommentsCount > 0) { if (file.unreadCommentsCount > 0) {
gridViewHolder.unreadComments.visibility = View.VISIBLE gridViewHolder.unreadComments.visibility = View.VISIBLE
gridViewHolder.unreadComments.setOnClickListener { gridViewHolder.unreadComments.setOnClickListener {
@ -265,7 +265,7 @@ class OCFileListDelegate(
} }
} }
private fun bindGridItemLayout(file: OCFile, gridViewHolder: ListGridImageViewHolder) { private fun bindGridItemLayout(file: OCFile, gridViewHolder: ListViewHolder) {
setItemLayoutBackgroundColor(file, gridViewHolder) setItemLayoutBackgroundColor(file, gridViewHolder)
setCheckBoxImage(file, gridViewHolder) setCheckBoxImage(file, gridViewHolder)
setItemLayoutOnClickListeners(file, gridViewHolder) setItemLayoutOnClickListeners(file, gridViewHolder)
@ -275,7 +275,7 @@ class OCFileListDelegate(
} }
} }
private fun setItemLayoutOnClickListeners(file: OCFile, gridViewHolder: ListGridImageViewHolder) { private fun setItemLayoutOnClickListeners(file: OCFile, gridViewHolder: ListViewHolder) {
gridViewHolder.itemLayout.setOnClickListener { ocFileListFragmentInterface.onItemClicked(file) } gridViewHolder.itemLayout.setOnClickListener { ocFileListFragmentInterface.onItemClicked(file) }
if (!hideItemOptions) { if (!hideItemOptions) {
@ -290,7 +290,7 @@ class OCFileListDelegate(
} }
} }
private fun setItemLayoutBackgroundColor(file: OCFile, gridViewHolder: ListGridImageViewHolder) { private fun setItemLayoutBackgroundColor(file: OCFile, gridViewHolder: ListViewHolder) {
val cornerRadius = context.resources.getDimension(R.dimen.selected_grid_container_radius) val cornerRadius = context.resources.getDimension(R.dimen.selected_grid_container_radius)
val isDarkModeActive = (syncFolderProvider?.preferences?.isDarkModeEnabled == true) val isDarkModeActive = (syncFolderProvider?.preferences?.isDarkModeEnabled == true)
@ -313,7 +313,7 @@ class OCFileListDelegate(
} }
} }
private fun setCheckBoxImage(file: OCFile, gridViewHolder: ListGridImageViewHolder) { private fun setCheckBoxImage(file: OCFile, gridViewHolder: ListViewHolder) {
if (isCheckedFile(file)) { if (isCheckedFile(file)) {
gridViewHolder.checkbox.setImageDrawable( gridViewHolder.checkbox.setImageDrawable(
viewThemeUtils.platform.tintDrawable(context, R.drawable.ic_checkbox_marked, ColorRole.PRIMARY) viewThemeUtils.platform.tintDrawable(context, R.drawable.ic_checkbox_marked, ColorRole.PRIMARY)
@ -323,7 +323,7 @@ class OCFileListDelegate(
} }
} }
private fun bindGridMetadataViews(file: OCFile, gridViewHolder: ListGridImageViewHolder) { private fun bindGridMetadataViews(file: OCFile, gridViewHolder: ListViewHolder) {
if (showMetadata) { if (showMetadata) {
showLocalFileIndicator(file, gridViewHolder) showLocalFileIndicator(file, gridViewHolder)
gridViewHolder.favorite.visibility = if (file.isFavorite) View.VISIBLE else View.GONE gridViewHolder.favorite.visibility = if (file.isFavorite) View.VISIBLE else View.GONE
@ -333,7 +333,7 @@ class OCFileListDelegate(
} }
} }
private fun showLocalFileIndicator(file: OCFile, gridViewHolder: ListGridImageViewHolder) { private fun showLocalFileIndicator(file: OCFile, gridViewHolder: ListViewHolder) {
val operationsServiceBinder = transferServiceGetter.operationsServiceBinder val operationsServiceBinder = transferServiceGetter.operationsServiceBinder
val icon: Int? = when { val icon: Int? = when {
@ -365,7 +365,7 @@ class OCFileListDelegate(
} }
} }
private fun showShareIcon(gridViewHolder: ListGridImageViewHolder, file: OCFile) { private fun showShareIcon(gridViewHolder: ListViewHolder, file: OCFile) {
val sharedIconView = gridViewHolder.shared val sharedIconView = gridViewHolder.shared
if (gridViewHolder is OCFileListItemViewHolder || file.unreadCommentsCount == 0) { if (gridViewHolder is OCFileListItemViewHolder || file.unreadCommentsCount == 0) {
sharedIconView.visibility = View.VISIBLE sharedIconView.visibility = View.VISIBLE

View file

@ -16,11 +16,11 @@ import androidx.recyclerview.widget.RecyclerView
import com.elyeproj.loaderviewlibrary.LoaderImageView import com.elyeproj.loaderviewlibrary.LoaderImageView
import com.owncloud.android.databinding.GridImageBinding import com.owncloud.android.databinding.GridImageBinding
internal class OCFileListGridImageViewHolder(var binding: GridImageBinding) : internal class OCFileListViewHolder(var binding: GridImageBinding) :
RecyclerView.ViewHolder( RecyclerView.ViewHolder(
binding.root binding.root
), ),
ListGridImageViewHolder { ListViewHolder {
override val thumbnail: ImageView override val thumbnail: ImageView
get() = binding.thumbnail get() = binding.thumbnail