From f7a78df8155ebe3e0863eebd17010978990a91f2 Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Tue, 11 Aug 2020 22:41:57 +0200 Subject: [PATCH] Migrate FeedsAdapter to viewBinding --- .../readrops/app/adapters/FeedsAdapter.java | 60 ++++++++----------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java b/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java index 6050ea3b..385813e4 100644 --- a/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java +++ b/app/src/main/java/com/readrops/app/adapters/FeedsAdapter.java @@ -3,8 +3,6 @@ package com.readrops.app.adapters; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -14,12 +12,13 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.readrops.app.R; -import com.readrops.db.pojo.FeedWithFolder; +import com.readrops.app.databinding.FeedLayoutBinding; import com.readrops.app.utils.GlideApp; +import com.readrops.db.pojo.FeedWithFolder; import java.util.List; -public class FeedsAdapter extends ListAdapter { +public class FeedsAdapter extends ListAdapter { private ManageFeedsListener listener; @@ -52,20 +51,16 @@ public class FeedsAdapter extends ListAdapter listener.onEdit(feedWithFolder)); viewHolder.itemView.setOnLongClickListener(v -> { @@ -98,16 +93,16 @@ public class FeedsAdapter extends ListAdapter payloads) { + public void onBindViewHolder(@NonNull FeedViewHolder holder, int position, @NonNull List payloads) { if (!payloads.isEmpty()) { FeedWithFolder feedWithFolder = (FeedWithFolder) payloads.get(0); - holder.feedName.setText(feedWithFolder.getFeed().getName()); + holder.binding.feedLayoutName.setText(feedWithFolder.getFeed().getName()); if (feedWithFolder.getFolder() != null) - holder.folderName.setText(feedWithFolder.getFolder().getName()); + holder.binding.feedLayoutName.setText(feedWithFolder.getFolder().getName()); else - holder.folderName.setText(R.string.no_folder); + holder.binding.feedLayoutName.setText(R.string.no_folder); } else onBindViewHolder(holder, position); @@ -115,24 +110,19 @@ public class FeedsAdapter extends ListAdapter