aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AccountChooserRecyclerViewAdapter.java29
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java33
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java45
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java217
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CustomThemeListingRecyclerViewAdapter.java55
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CustomizeThemeRecyclerViewAdapter.java97
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java36
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java142
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java176
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java105
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MultiRedditListingRecyclerViewAdapter.java142
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/OnlineCustomThemeListingRecyclerViewAdapter.java32
12 files changed, 480 insertions, 629 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AccountChooserRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AccountChooserRecyclerViewAdapter.java
index e22057f1..dcaa37fb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AccountChooserRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AccountChooserRecyclerViewAdapter.java
@@ -1,9 +1,7 @@
package ml.docilealligator.infinityforreddit.adapters;
import android.view.LayoutInflater;
-import android.view.View;
import android.view.ViewGroup;
-import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
@@ -14,14 +12,12 @@ import com.bumptech.glide.request.RequestOptions;
import java.util.ArrayList;
import java.util.List;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
-import pl.droidsonroids.gif.GifImageView;
+import ml.docilealligator.infinityforreddit.databinding.ItemNavDrawerAccountBinding;
public class AccountChooserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@@ -42,8 +38,8 @@ public class AccountChooserRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- return new AccountViewHolder(LayoutInflater.from(parent.getContext())
- .inflate(R.layout.item_nav_drawer_account, parent, false));
+ return new AccountViewHolder(ItemNavDrawerAccountBinding
+ .inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
@Override
@@ -52,8 +48,8 @@ public class AccountChooserRecyclerViewAdapter extends RecyclerView.Adapter<Recy
glide.load(accounts.get(position).getProfileImageUrl())
.error(glide.load(R.drawable.subreddit_default_icon))
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
- .into(((AccountViewHolder) holder).profileImageGifImageView);
- ((AccountViewHolder) holder).usernameTextView.setText(accounts.get(position).getAccountName());
+ .into(((AccountViewHolder) holder).binding.profileImageItemAccount);
+ ((AccountViewHolder) holder).binding.usernameTextViewItemAccount.setText(accounts.get(position).getAccountName());
holder.itemView.setOnClickListener(view ->
itemClickListener.onClick(accounts.get(position)));
}
@@ -70,18 +66,15 @@ public class AccountChooserRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
class AccountViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.profile_image_item_account)
- GifImageView profileImageGifImageView;
- @BindView(R.id.username_text_view_item_account)
- TextView usernameTextView;
+ ItemNavDrawerAccountBinding binding;
- AccountViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ AccountViewHolder(@NonNull ItemNavDrawerAccountBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (baseActivity.typeface != null) {
- usernameTextView.setTypeface(baseActivity.typeface);
+ binding.usernameTextViewItemAccount.setTypeface(baseActivity.typeface);
}
- usernameTextView.setTextColor(primaryTextColor);
+ binding.usernameTextViewItemAccount.setTextColor(primaryTextColor);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java
index 9e563772..aa7e930a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java
@@ -2,20 +2,16 @@ package ml.docilealligator.infinityforreddit.adapters;
import android.content.Intent;
import android.view.LayoutInflater;
-import android.view.View;
import android.view.ViewGroup;
-import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
-import butterknife.BindView;
-import butterknife.ButterKnife;
-import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.SettingsActivity;
+import ml.docilealligator.infinityforreddit.databinding.ItemAcknowledgementBinding;
import ml.docilealligator.infinityforreddit.settings.Acknowledgement;
public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<AcknowledgementRecyclerViewAdapter.AcknowledgementViewHolder> {
@@ -30,15 +26,15 @@ public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<Ack
@NonNull
@Override
public AcknowledgementViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- return new AcknowledgementViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_acknowledgement, parent, false));
+ return new AcknowledgementViewHolder(ItemAcknowledgementBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
@Override
public void onBindViewHolder(@NonNull AcknowledgementViewHolder holder, int position) {
Acknowledgement acknowledgement = acknowledgements.get(holder.getBindingAdapterPosition());
if (acknowledgement != null) {
- holder.nameTextView.setText(acknowledgement.getName());
- holder.introductionTextView.setText(acknowledgement.getIntroduction());
+ holder.binding.nameTextViewItemAcknowledgement.setText(acknowledgement.getName());
+ holder.binding.introductionTextViewItemAcknowledgement.setText(acknowledgement.getIntroduction());
holder.itemView.setOnClickListener(view -> {
if (activity != null) {
Intent intent = new Intent(activity, LinkResolverActivity.class);
@@ -55,23 +51,18 @@ public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<Ack
}
class AcknowledgementViewHolder extends RecyclerView.ViewHolder {
- View itemView;
- @BindView(R.id.name_text_view_item_acknowledgement)
- TextView nameTextView;
- @BindView(R.id.introduction_text_view_item_acknowledgement)
- TextView introductionTextView;
+ ItemAcknowledgementBinding binding;
- AcknowledgementViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
- this.itemView = itemView;
+ AcknowledgementViewHolder(@NonNull ItemAcknowledgementBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
- nameTextView.setTextColor(activity.customThemeWrapper.getPrimaryTextColor());
- introductionTextView.setTextColor(activity.customThemeWrapper.getSecondaryTextColor());
+ binding.nameTextViewItemAcknowledgement.setTextColor(activity.customThemeWrapper.getPrimaryTextColor());
+ binding.introductionTextViewItemAcknowledgement.setTextColor(activity.customThemeWrapper.getSecondaryTextColor());
if (activity.typeface != null) {
- nameTextView.setTypeface(activity.typeface);
- introductionTextView.setTypeface(activity.typeface);
+ binding.nameTextViewItemAcknowledgement.setTypeface(activity.typeface);
+ binding.introductionTextViewItemAcknowledgement.setTypeface(activity.typeface);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
index 1bc8ec14..567af63e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java
@@ -10,9 +10,7 @@ import android.text.Spanned;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Button;
import android.widget.LinearLayout;
-import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -29,8 +27,6 @@ import com.google.android.material.button.MaterialButton;
import java.util.Locale;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
@@ -56,10 +52,12 @@ import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.databinding.ItemCommentBinding;
-import ml.docilealligator.infinityforreddit.markdown.EvenBetterLinkMovementMethod;
+import ml.docilealligator.infinityforreddit.databinding.ItemFooterErrorBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemFooterLoadingBinding;
import ml.docilealligator.infinityforreddit.markdown.CustomMarkwonAdapter;
import ml.docilealligator.infinityforreddit.markdown.EmoteCloseBracketInlineProcessor;
import ml.docilealligator.infinityforreddit.markdown.EmotePlugin;
+import ml.docilealligator.infinityforreddit.markdown.EvenBetterLinkMovementMethod;
import ml.docilealligator.infinityforreddit.markdown.ImageAndGifEntry;
import ml.docilealligator.infinityforreddit.markdown.ImageAndGifPlugin;
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
@@ -223,9 +221,9 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
if (viewType == VIEW_TYPE_DATA) {
return new CommentViewHolder(ItemCommentBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
} else if (viewType == VIEW_TYPE_ERROR) {
- return new ErrorViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false));
+ return new ErrorViewHolder(ItemFooterErrorBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
} else {
- return new LoadingViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_loading, parent, false));
+ return new LoadingViewHolder(ItemFooterLoadingBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
}
@@ -814,34 +812,25 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
}
class ErrorViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.error_text_view_item_footer_error)
- TextView errorTextView;
- @BindView(R.id.retry_button_item_footer_error)
- Button retryButton;
-
- ErrorViewHolder(View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ ErrorViewHolder(@NonNull ItemFooterErrorBinding binding) {
+ super(binding.getRoot());
if (mActivity.typeface != null) {
- errorTextView.setTypeface(mActivity.typeface);
- retryButton.setTypeface(mActivity.typeface);
+ binding.errorTextViewItemFooterError.setTypeface(mActivity.typeface);
+ binding.retryButtonItemFooterError.setTypeface(mActivity.typeface);
}
- errorTextView.setText(R.string.load_comments_failed);
- retryButton.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore());
- errorTextView.setTextColor(mSecondaryTextColor);
- retryButton.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
- retryButton.setTextColor(mButtonTextColor);
+ binding.errorTextViewItemFooterError.setText(R.string.load_comments_failed);
+ binding.retryButtonItemFooterError.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore());
+ binding.errorTextViewItemFooterError.setTextColor(mSecondaryTextColor);
+ binding.retryButtonItemFooterError.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
+ binding.retryButtonItemFooterError.setTextColor(mButtonTextColor);
}
}
class LoadingViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.progress_bar_item_footer_loading)
- ProgressBar progressBar;
- LoadingViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
- progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
+ LoadingViewHolder(@NonNull ItemFooterLoadingBinding binding) {
+ super(binding.getRoot());
+ binding.progressBarItemFooterLoading.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index 766b68b2..8cb5bc4f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -12,10 +12,8 @@ import android.text.Spanned;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
-import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -30,14 +28,11 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.button.MaterialButton;
-import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.Executor;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
@@ -66,6 +61,13 @@ import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.databinding.ItemCommentBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemCommentFooterErrorBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemCommentFooterLoadingBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemCommentFullyCollapsedBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemLoadCommentsBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemLoadCommentsFailedPlaceholderBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemLoadMoreCommentsPlaceholderBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemNoCommentPlaceholderBinding;
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
import ml.docilealligator.infinityforreddit.markdown.CustomMarkwonAdapter;
import ml.docilealligator.infinityforreddit.markdown.EmoteCloseBracketInlineProcessor;
@@ -387,21 +389,21 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
switch (viewType) {
case VIEW_TYPE_FIRST_LOADING:
- return new LoadCommentsViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_load_comments, parent, false));
+ return new LoadCommentsViewHolder(ItemLoadCommentsBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
case VIEW_TYPE_FIRST_LOADING_FAILED:
- return new LoadCommentsFailedViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_load_comments_failed_placeholder, parent, false));
+ return new LoadCommentsFailedViewHolder(ItemLoadCommentsFailedPlaceholderBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
case VIEW_TYPE_NO_COMMENT_PLACEHOLDER:
- return new NoCommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_no_comment_placeholder, parent, false));
+ return new NoCommentViewHolder(ItemNoCommentPlaceholderBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
case VIEW_TYPE_COMMENT:
return new CommentViewHolder(ItemCommentBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
case VIEW_TYPE_COMMENT_FULLY_COLLAPSED:
- return new CommentFullyCollapsedViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment_fully_collapsed, parent, false));
+ return new CommentFullyCollapsedViewHolder(ItemCommentFullyCollapsedBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
case VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS:
- return new LoadMoreChildCommentsViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_load_more_comments_placeholder, parent, false));
+ return new LoadMoreChildCommentsViewHolder(ItemLoadMoreCommentsPlaceholderBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
case VIEW_TYPE_IS_LOADING_MORE_COMMENTS:
- return new IsLoadingMoreCommentsViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment_footer_loading, parent, false));
+ return new IsLoadingMoreCommentsViewHolder(ItemCommentFooterLoadingBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
case VIEW_TYPE_LOAD_MORE_COMMENTS_FAILED:
- return new LoadMoreCommentsFailedViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment_footer_error, parent, false));
+ return new LoadMoreCommentsFailedViewHolder(ItemCommentFooterErrorBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
default:
return new ViewAllCommentsViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_view_all_comments, parent, false));
}
@@ -583,7 +585,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
Comment comment = getCurrentComment(position);
if (comment != null) {
String authorWithPrefix = "u/" + comment.getAuthor();
- ((CommentFullyCollapsedViewHolder) holder).usernameTextView.setText(authorWithPrefix);
+ ((CommentFullyCollapsedViewHolder) holder).binding.userNameTextViewItemCommentFullyCollapsed.setText(authorWithPrefix);
if (comment.getAuthorIconUrl() == null) {
mFragment.loadIcon(comment.getAuthor(), (authorName, iconUrl) -> {
@@ -597,7 +599,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((CommentFullyCollapsedViewHolder) holder).authorIconImageView);
+ .into(((CommentFullyCollapsedViewHolder) holder).binding.authorIconImageViewItemCommentFullyCollapsed);
}
});
} else {
@@ -605,30 +607,30 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((CommentFullyCollapsedViewHolder) holder).authorIconImageView);
+ .into(((CommentFullyCollapsedViewHolder) holder).binding.authorIconImageViewItemCommentFullyCollapsed);
}
if (comment.getChildCount() > 0) {
- ((CommentFullyCollapsedViewHolder) holder).childCountTextView.setVisibility(View.VISIBLE);
- ((CommentFullyCollapsedViewHolder) holder).childCountTextView.setText("+" + comment.getChildCount());
+ ((CommentFullyCollapsedViewHolder) holder).binding.childCountTextViewItemCommentFullyCollapsed.setVisibility(View.VISIBLE);
+ ((CommentFullyCollapsedViewHolder) holder).binding.childCountTextViewItemCommentFullyCollapsed.setText("+" + comment.getChildCount());
} else {
- ((CommentFullyCollapsedViewHolder) holder).childCountTextView.setVisibility(View.GONE);
+ ((CommentFullyCollapsedViewHolder) holder).binding.childCountTextViewItemCommentFullyCollapsed.setVisibility(View.GONE);
}
if (mShowElapsedTime) {
- ((CommentFullyCollapsedViewHolder) holder).commentTimeTextView.setText(Utils.getElapsedTime(mActivity, comment.getCommentTimeMillis()));
+ ((CommentFullyCollapsedViewHolder) holder).binding.timeTextViewItemCommentFullyCollapsed.setText(Utils.getElapsedTime(mActivity, comment.getCommentTimeMillis()));
} else {
- ((CommentFullyCollapsedViewHolder) holder).commentTimeTextView.setText(Utils.getFormattedTime(mLocale, comment.getCommentTimeMillis(), mTimeFormatPattern));
+ ((CommentFullyCollapsedViewHolder) holder).binding.timeTextViewItemCommentFullyCollapsed.setText(Utils.getFormattedTime(mLocale, comment.getCommentTimeMillis(), mTimeFormatPattern));
}
if (!comment.isScoreHidden() && !mHideTheNumberOfVotes) {
- ((CommentFullyCollapsedViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.top_score,
+ ((CommentFullyCollapsedViewHolder) holder).binding.scoreTextViewItemCommentFullyCollapsed.setText(mActivity.getString(R.string.top_score,
Utils.getNVotes(mShowAbsoluteNumberOfVotes, comment.getScore() + comment.getVoteType())));
} else if (mHideTheNumberOfVotes) {
- ((CommentFullyCollapsedViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.vote));
+ ((CommentFullyCollapsedViewHolder) holder).binding.scoreTextViewItemCommentFullyCollapsed.setText(mActivity.getString(R.string.vote));
} else {
- ((CommentFullyCollapsedViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.hidden));
+ ((CommentFullyCollapsedViewHolder) holder).binding.scoreTextViewItemCommentFullyCollapsed.setText(mActivity.getString(R.string.hidden));
}
- ((CommentFullyCollapsedViewHolder) holder).commentIndentationView.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator);
- ((CommentFullyCollapsedViewHolder) holder).commentIndentationView.setLevelAndColors(comment.getDepth(), verticalBlockColors);
+ ((CommentFullyCollapsedViewHolder) holder).binding.verticalBlockIndentationItemCommentFullyCollapsed.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator);
+ ((CommentFullyCollapsedViewHolder) holder).binding.verticalBlockIndentationItemCommentFullyCollapsed.setLevelAndColors(comment.getDepth(), verticalBlockColors);
if (mShowCommentDivider) {
if (mDividerType == DIVIDER_PARENT && comment.getDepth() == 0) {
@@ -642,23 +644,23 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getBindingAdapterPosition() - 1)
: mVisibleComments.get(holder.getBindingAdapterPosition());
- ((LoadMoreChildCommentsViewHolder) holder).commentIndentationView.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator);
- ((LoadMoreChildCommentsViewHolder) holder).commentIndentationView.setLevelAndColors(placeholder.getDepth(), verticalBlockColors);
+ ((LoadMoreChildCommentsViewHolder) holder).binding.verticalBlockIndentationItemLoadMoreCommentsPlaceholder.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator);
+ ((LoadMoreChildCommentsViewHolder) holder).binding.verticalBlockIndentationItemLoadMoreCommentsPlaceholder.setLevelAndColors(placeholder.getDepth(), verticalBlockColors);
if (placeholder.getPlaceholderType() == Comment.PLACEHOLDER_LOAD_MORE_COMMENTS) {
if (placeholder.isLoadingMoreChildren()) {
- ((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.loading);
+ ((LoadMoreChildCommentsViewHolder) holder).binding.placeholderTextViewItemLoadMoreComments.setText(R.string.loading);
} else if (placeholder.isLoadMoreChildrenFailed()) {
- ((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.comment_load_more_comments_failed);
+ ((LoadMoreChildCommentsViewHolder) holder).binding.placeholderTextViewItemLoadMoreComments.setText(R.string.comment_load_more_comments_failed);
} else {
- ((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.comment_load_more_comments);
+ ((LoadMoreChildCommentsViewHolder) holder).binding.placeholderTextViewItemLoadMoreComments.setText(R.string.comment_load_more_comments);
}
} else {
- ((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.comment_continue_thread);
+ ((LoadMoreChildCommentsViewHolder) holder).binding.placeholderTextViewItemLoadMoreComments.setText(R.string.comment_continue_thread);
}
if (placeholder.getPlaceholderType() == Comment.PLACEHOLDER_LOAD_MORE_COMMENTS) {
- ((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setOnClickListener(view -> {
+ ((LoadMoreChildCommentsViewHolder) holder).binding.placeholderTextViewItemLoadMoreComments.setOnClickListener(view -> {
int commentPosition = mIsSingleCommentThreadMode ? holder.getBindingAdapterPosition() - 1 : holder.getBindingAdapterPosition();
int parentPosition = getParentPosition(commentPosition);
if (parentPosition >= 0) {
@@ -666,7 +668,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mVisibleComments.get(commentPosition).setLoadingMoreChildren(true);
mVisibleComments.get(commentPosition).setLoadMoreChildrenFailed(false);
- ((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.loading);
+ ((LoadMoreChildCommentsViewHolder) holder).binding.placeholderTextViewItemLoadMoreComments.setText(R.string.loading);
Retrofit retrofit = mAccountName.equals(Account.ANONYMOUS_ACCOUNT) ? mRetrofit : mOauthRetrofit;
SortType.Type sortType = mCommentRecyclerViewAdapterCallback.getSortType();
@@ -691,7 +693,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (placeholderPosition != -1) {
mVisibleComments.get(placeholderPosition).setLoadingMoreChildren(false);
mVisibleComments.get(placeholderPosition).setLoadMoreChildrenFailed(false);
- ((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.comment_load_more_comments);
+ ((LoadMoreChildCommentsViewHolder) holder).binding.placeholderTextViewItemLoadMoreComments.setText(R.string.comment_load_more_comments);
mVisibleComments.addAll(placeholderPosition, expandedComments);
if (mIsSingleCommentThreadMode) {
@@ -746,7 +748,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (placeholderPosition != -1) {
mVisibleComments.get(placeholderPosition).setLoadingMoreChildren(false);
mVisibleComments.get(placeholderPosition).setLoadMoreChildrenFailed(false);
- ((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.comment_load_more_comments);
+ ((LoadMoreChildCommentsViewHolder) holder).binding.placeholderTextViewItemLoadMoreComments.setText(R.string.comment_load_more_comments);
mVisibleComments.addAll(placeholderPosition, expandedComments);
if (mIsSingleCommentThreadMode) {
@@ -792,7 +794,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mVisibleComments.get(placeholderPosition).setLoadingMoreChildren(false);
mVisibleComments.get(placeholderPosition).setLoadMoreChildrenFailed(true);
}
- ((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.comment_load_more_comments_failed);
+ ((LoadMoreChildCommentsViewHolder) holder).binding.placeholderTextViewItemLoadMoreComments.setText(R.string.comment_load_more_comments_failed);
}
currentParentComment.getChildren().get(currentParentComment.getChildren().size() - 1)
.setLoadingMoreChildren(false);
@@ -803,7 +805,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
});
} else {
- ((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setOnClickListener(view -> {
+ ((LoadMoreChildCommentsViewHolder) holder).binding.placeholderTextViewItemLoadMoreComments.setOnClickListener(view -> {
Comment comment = getCurrentComment(holder);
if (comment != null) {
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
@@ -1830,48 +1832,35 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
class CommentFullyCollapsedViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.vertical_block_indentation_item_comment_fully_collapsed)
- CommentIndentationView commentIndentationView;
- @BindView(R.id.author_icon_image_view_item_comment_fully_collapsed)
- ImageView authorIconImageView;
- @BindView(R.id.user_name_text_view_item_comment_fully_collapsed)
- TextView usernameTextView;
- @BindView(R.id.child_count_text_view_item_comment_fully_collapsed)
- TextView childCountTextView;
- @BindView(R.id.score_text_view_item_comment_fully_collapsed)
- TextView scoreTextView;
- @BindView(R.id.time_text_view_item_comment_fully_collapsed)
- TextView commentTimeTextView;
- @BindView(R.id.divider_item_comment_fully_collapsed)
- View commentDivider;
+ ItemCommentFullyCollapsedBinding binding;
- public CommentFullyCollapsedViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ public CommentFullyCollapsedViewHolder(@NonNull ItemCommentFullyCollapsedBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- usernameTextView.setTypeface(mActivity.typeface);
- childCountTextView.setTypeface(mActivity.typeface);
- scoreTextView.setTypeface(mActivity.typeface);
- commentTimeTextView.setTypeface(mActivity.typeface);
+ binding.userNameTextViewItemCommentFullyCollapsed.setTypeface(mActivity.typeface);
+ binding.childCountTextViewItemCommentFullyCollapsed.setTypeface(mActivity.typeface);
+ binding.scoreTextViewItemCommentFullyCollapsed.setTypeface(mActivity.typeface);
+ binding.timeTextViewItemCommentFullyCollapsed.setTypeface(mActivity.typeface);
}
itemView.setBackgroundColor(mFullyCollapsedCommentBackgroundColor);
- usernameTextView.setTextColor(mUsernameColor);
- childCountTextView.setTextColor(mSecondaryTextColor);
- scoreTextView.setTextColor(mSecondaryTextColor);
- commentTimeTextView.setTextColor(mSecondaryTextColor);
+ binding.userNameTextViewItemCommentFullyCollapsed.setTextColor(mUsernameColor);
+ binding.childCountTextViewItemCommentFullyCollapsed.setTextColor(mSecondaryTextColor);
+ binding.scoreTextViewItemCommentFullyCollapsed.setTextColor(mSecondaryTextColor);
+ binding.timeTextViewItemCommentFullyCollapsed.setTextColor(mSecondaryTextColor);
if (mShowCommentDivider) {
if (mDividerType == DIVIDER_NORMAL) {
- commentDivider.setBackgroundColor(mDividerColor);
- commentDivider.setVisibility(View.VISIBLE);
+ binding.dividerItemCommentFullyCollapsed.setBackgroundColor(mDividerColor);
+ binding.dividerItemCommentFullyCollapsed.setVisibility(View.VISIBLE);
}
}
if (mShowAuthorAvatar) {
- authorIconImageView.setVisibility(View.VISIBLE);
+ binding.authorIconImageViewItemCommentFullyCollapsed.setVisibility(View.VISIBLE);
} else {
- usernameTextView.setPaddingRelative(0, usernameTextView.getPaddingTop(), usernameTextView.getPaddingEnd(), usernameTextView.getPaddingBottom());
+ binding.userNameTextViewItemCommentFullyCollapsed.setPaddingRelative(0, binding.userNameTextViewItemCommentFullyCollapsed.getPaddingTop(), binding.userNameTextViewItemCommentFullyCollapsed.getPaddingEnd(), binding.userNameTextViewItemCommentFullyCollapsed.getPaddingBottom());
}
itemView.setOnClickListener(view -> {
@@ -1904,102 +1893,90 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
class LoadMoreChildCommentsViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.vertical_block_indentation_item_load_more_comments_placeholder)
- CommentIndentationView commentIndentationView;
- @BindView(R.id.placeholder_text_view_item_load_more_comments)
- TextView placeholderTextView;
- @BindView(R.id.divider_item_load_more_comments_placeholder)
- View commentDivider;
+ ItemLoadMoreCommentsPlaceholderBinding binding;
- LoadMoreChildCommentsViewHolder(View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ LoadMoreChildCommentsViewHolder(@NonNull ItemLoadMoreCommentsPlaceholderBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mShowCommentDivider) {
if (mDividerType == DIVIDER_NORMAL) {
- commentDivider.setBackgroundColor(mDividerColor);
- commentDivider.setVisibility(View.VISIBLE);
+ binding.dividerItemLoadMoreCommentsPlaceholder.setBackgroundColor(mDividerColor);
+ binding.dividerItemLoadMoreCommentsPlaceholder.setVisibility(View.VISIBLE);
}
}
if (mActivity.typeface != null) {
- placeholderTextView.setTypeface(mActivity.typeface);
+ binding.placeholderTextViewItemLoadMoreComments.setTypeface(mActivity.typeface);
}
itemView.setBackgroundColor(mCommentBackgroundColor);
- placeholderTextView.setTextColor(mPrimaryTextColor);
+ binding.placeholderTextViewItemLoadMoreComments.setTextColor(mPrimaryTextColor);
}
}
class LoadCommentsViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.comment_progress_bar_item_load_comments)
- CircleProgressBar circleProgressBar;
+ ItemLoadCommentsBinding binding;
- LoadCommentsViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
- circleProgressBar.setBackgroundTintList(ColorStateList.valueOf(mCircularProgressBarBackgroundColor));
- circleProgressBar.setColorSchemeColors(mColorAccent);
+ LoadCommentsViewHolder(@NonNull ItemLoadCommentsBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
+ binding.commentProgressBarItemLoadComments.setBackgroundTintList(ColorStateList.valueOf(mCircularProgressBarBackgroundColor));
+ binding.commentProgressBarItemLoadComments.setColorSchemeColors(mColorAccent);
}
}
class LoadCommentsFailedViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.error_text_view_item_load_comments_failed_placeholder)
- TextView errorTextView;
+ ItemLoadCommentsFailedPlaceholderBinding binding;
- LoadCommentsFailedViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ LoadCommentsFailedViewHolder(@NonNull ItemLoadCommentsFailedPlaceholderBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
itemView.setOnClickListener(view -> mCommentRecyclerViewAdapterCallback.retryFetchingComments());
if (mActivity.typeface != null) {
- errorTextView.setTypeface(mActivity.typeface);
+ binding.errorTextViewItemLoadCommentsFailedPlaceholder.setTypeface(mActivity.typeface);
}
- errorTextView.setTextColor(mSecondaryTextColor);
+ binding.errorTextViewItemLoadCommentsFailedPlaceholder.setTextColor(mSecondaryTextColor);
}
}
class NoCommentViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.error_text_view_item_no_comment_placeholder)
- TextView errorTextView;
+ ItemNoCommentPlaceholderBinding binding;
- NoCommentViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ NoCommentViewHolder(@NonNull ItemNoCommentPlaceholderBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- errorTextView.setTypeface(mActivity.typeface);
+ binding.errorTextViewItemNoCommentPlaceholder.setTypeface(mActivity.typeface);
}
- errorTextView.setTextColor(mSecondaryTextColor);
+ binding.errorTextViewItemNoCommentPlaceholder.setTextColor(mSecondaryTextColor);
}
}
class IsLoadingMoreCommentsViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.progress_bar_item_comment_footer_loading)
- ProgressBar progressbar;
+ ItemCommentFooterLoadingBinding binding;
- IsLoadingMoreCommentsViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
- progressbar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
+ IsLoadingMoreCommentsViewHolder(@NonNull ItemCommentFooterLoadingBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
+ binding.progressBarItemCommentFooterLoading.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
}
}
class LoadMoreCommentsFailedViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.error_text_view_item_comment_footer_error)
- TextView errorTextView;
- @BindView(R.id.retry_button_item_comment_footer_error)
- Button retryButton;
+ ItemCommentFooterErrorBinding binding;
- LoadMoreCommentsFailedViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ LoadMoreCommentsFailedViewHolder(@NonNull ItemCommentFooterErrorBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- errorTextView.setTypeface(mActivity.typeface);
- retryButton.setTypeface(mActivity.typeface);
+ binding.errorTextViewItemCommentFooterError.setTypeface(mActivity.typeface);
+ binding.retryButtonItemCommentFooterError.setTypeface(mActivity.typeface);
}
- errorTextView.setText(R.string.load_comments_failed);
- retryButton.setOnClickListener(view -> mCommentRecyclerViewAdapterCallback.retryFetchingMoreComments());
- errorTextView.setTextColor(mSecondaryTextColor);
- retryButton.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
- retryButton.setTextColor(mButtonTextColor);
+ binding.errorTextViewItemCommentFooterError.setText(R.string.load_comments_failed);
+ binding.retryButtonItemCommentFooterError.setOnClickListener(view -> mCommentRecyclerViewAdapterCallback.retryFetchingMoreComments());
+ binding.errorTextViewItemCommentFooterError.setTextColor(mSecondaryTextColor);
+ binding.retryButtonItemCommentFooterError.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
+ binding.retryButtonItemCommentFooterError.setTextColor(mButtonTextColor);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CustomThemeListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CustomThemeListingRecyclerViewAdapter.java
index cee53dd6..4fbf3d8e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CustomThemeListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CustomThemeListingRecyclerViewAdapter.java
@@ -6,7 +6,6 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -15,14 +14,14 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CustomThemeListingActivity;
import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CustomThemeOptionsBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
+import ml.docilealligator.infinityforreddit.databinding.ItemPredefinedCustomThemeBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemUserCustomThemeBinding;
public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_PREDEFINED_THEME = 0;
@@ -60,11 +59,11 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
case VIEW_TYPE_PREDEFINED_THEME_DIVIDER:
return new PreDefinedThemeDividerViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_theme_type_divider, parent, false));
case VIEW_TYPE_PREDEFINED_THEME:
- return new PredefinedCustomThemeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_predefined_custom_theme, parent, false));
+ return new PredefinedCustomThemeViewHolder(ItemPredefinedCustomThemeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
case VIEW_TYPE_USER_THEME_DIVIDER:
return new UserThemeDividerViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_theme_type_divider, parent, false));
default:
- return new UserCustomThemeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_user_custom_theme, parent, false));
+ return new UserCustomThemeViewHolder(ItemUserCustomThemeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
}
@@ -72,8 +71,8 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof PredefinedCustomThemeViewHolder) {
CustomTheme customTheme = predefinedCustomThemes.get(position - 1);
- ((PredefinedCustomThemeViewHolder) holder).colorPrimaryView.setBackgroundTintList(ColorStateList.valueOf(customTheme.colorPrimary));
- ((PredefinedCustomThemeViewHolder) holder).nameTextView.setText(customTheme.name);
+ ((PredefinedCustomThemeViewHolder) holder).binding.colorPrimaryItemPredefinedCustomTheme.setBackgroundTintList(ColorStateList.valueOf(customTheme.colorPrimary));
+ ((PredefinedCustomThemeViewHolder) holder).binding.nameTextViewItemPredefinedCustomTheme.setText(customTheme.name);
holder.itemView.setOnClickListener(view -> {
Intent intent = new Intent(activity, CustomizeThemeActivity.class);
intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, customTheme.name);
@@ -83,15 +82,15 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
});
} else if (holder instanceof UserCustomThemeViewHolder) {
CustomTheme customTheme = userCustomThemes.get(position - predefinedCustomThemes.size() - 2);
- ((UserCustomThemeViewHolder) holder).colorPrimaryView.setBackgroundTintList(ColorStateList.valueOf(customTheme.colorPrimary));
- ((UserCustomThemeViewHolder) holder).nameTextView.setText(customTheme.name);
- ((UserCustomThemeViewHolder) holder).createThemeImageView.setOnClickListener(view -> {
+ ((UserCustomThemeViewHolder) holder).binding.colorPrimaryItemUserCustomTheme.setBackgroundTintList(ColorStateList.valueOf(customTheme.colorPrimary));
+ ((UserCustomThemeViewHolder) holder).binding.nameTextViewItemUserCustomTheme.setText(customTheme.name);
+ ((UserCustomThemeViewHolder) holder).binding.addImageViewItemUserCustomTheme.setOnClickListener(view -> {
Intent intent = new Intent(activity, CustomizeThemeActivity.class);
intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, customTheme.name);
intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true);
activity.startActivity(intent);
});
- ((UserCustomThemeViewHolder) holder).shareImageView.setOnClickListener(view -> {
+ ((UserCustomThemeViewHolder) holder).binding.shareImageViewItemUserCustomTheme.setOnClickListener(view -> {
((CustomThemeListingActivity) activity).shareTheme(customTheme);
});
((UserCustomThemeViewHolder) holder).itemView.setOnClickListener(view -> {
@@ -123,39 +122,25 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
}
class PredefinedCustomThemeViewHolder extends RecyclerView.ViewHolder {
+ ItemPredefinedCustomThemeBinding binding;
- @BindView(R.id.color_primary_item_predefined_custom_theme)
- View colorPrimaryView;
- @BindView(R.id.name_text_view_item_predefined_custom_theme)
- TextView nameTextView;
- @BindView(R.id.add_image_view_item_predefined_custom_theme)
- ImageView createThemeImageView;
-
- PredefinedCustomThemeViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ PredefinedCustomThemeViewHolder(@NonNull ItemPredefinedCustomThemeBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (activity.typeface != null) {
- nameTextView.setTypeface(activity.typeface);
+ binding.nameTextViewItemPredefinedCustomTheme.setTypeface(activity.typeface);
}
}
}
class UserCustomThemeViewHolder extends RecyclerView.ViewHolder {
+ ItemUserCustomThemeBinding binding;
- @BindView(R.id.color_primary_item_user_custom_theme)
- View colorPrimaryView;
- @BindView(R.id.name_text_view_item_user_custom_theme)
- TextView nameTextView;
- @BindView(R.id.add_image_view_item_user_custom_theme)
- ImageView createThemeImageView;
- @BindView(R.id.share_image_view_item_user_custom_theme)
- ImageView shareImageView;
-
- UserCustomThemeViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ UserCustomThemeViewHolder(@NonNull ItemUserCustomThemeBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (activity.typeface != null) {
- nameTextView.setTypeface(activity.typeface);
+ binding.nameTextViewItemUserCustomTheme.setTypeface(activity.typeface);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CustomizeThemeRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CustomizeThemeRecyclerViewAdapter.java
index d6ec995b..222e02dc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CustomizeThemeRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CustomizeThemeRecyclerViewAdapter.java
@@ -6,23 +6,22 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
-import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
-import com.google.android.material.materialswitch.MaterialSwitch;
import java.util.ArrayList;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeSettingsItem;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.ColorPickerDialog;
+import ml.docilealligator.infinityforreddit.databinding.ItemCustomThemeColorItemBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemCustomThemeSwitchItemBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemThemeNameBinding;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@@ -57,36 +56,36 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (viewType == VIEW_TYPE_SWITCH) {
- return new ThemeSwitchItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_custom_theme_switch_item, parent, false));
+ return new ThemeSwitchItemViewHolder(ItemCustomThemeSwitchItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
} else if (viewType == VIEW_TYPE_THEME_NAME) {
- return new ThemeNameItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_theme_name, parent, false));
+ return new ThemeNameItemViewHolder(ItemThemeNameBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
- return new ThemeColorItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_custom_theme_color_item, parent, false));
+ return new ThemeColorItemViewHolder(ItemCustomThemeColorItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ThemeColorItemViewHolder) {
CustomThemeSettingsItem customThemeSettingsItem = customThemeSettingsItems.get(position - 1);
- ((ThemeColorItemViewHolder) holder).themeItemNameTextView.setText(customThemeSettingsItem.itemName);
- ((ThemeColorItemViewHolder) holder).themeItemInfoTextView.setText(customThemeSettingsItem.itemDetails);
- ((ThemeColorItemViewHolder) holder).colorImageView.setBackgroundTintList(ColorStateList.valueOf(customThemeSettingsItem.colorValue));
+ ((ThemeColorItemViewHolder) holder).binding.themeItemNameTextViewItemCustomThemeColorItem.setText(customThemeSettingsItem.itemName);
+ ((ThemeColorItemViewHolder) holder).binding.themeItemInfoTextViewItemCustomThemeColorItem.setText(customThemeSettingsItem.itemDetails);
+ ((ThemeColorItemViewHolder) holder).binding.colorImageViewItemCustomThemeColorItem.setBackgroundTintList(ColorStateList.valueOf(customThemeSettingsItem.colorValue));
holder.itemView.setOnClickListener(view -> {
new ColorPickerDialog(activity, customThemeSettingsItem.colorValue, color -> {
customThemeSettingsItem.colorValue = color;
- ((ThemeColorItemViewHolder) holder).colorImageView.setBackgroundTintList(ColorStateList.valueOf(color));
+ ((ThemeColorItemViewHolder) holder).binding.colorImageViewItemCustomThemeColorItem.setBackgroundTintList(ColorStateList.valueOf(color));
}).show();
});
} else if (holder instanceof ThemeSwitchItemViewHolder) {
CustomThemeSettingsItem customThemeSettingsItem = customThemeSettingsItems.get(position - 1);
- ((ThemeSwitchItemViewHolder) holder).themeItemNameTextView.setText(customThemeSettingsItem.itemName);
- ((ThemeSwitchItemViewHolder) holder).themeItemInfoTextView.setText(customThemeSettingsItem.itemName);
- ((ThemeSwitchItemViewHolder) holder).themeItemSwitch.setChecked(customThemeSettingsItem.isEnabled);
- ((ThemeSwitchItemViewHolder) holder).themeItemSwitch.setOnClickListener(view -> customThemeSettingsItem.isEnabled = ((ThemeSwitchItemViewHolder) holder).themeItemSwitch.isChecked());
- holder.itemView.setOnClickListener(view -> ((ThemeSwitchItemViewHolder) holder).themeItemSwitch.performClick());
+ ((ThemeSwitchItemViewHolder) holder).binding.themeItemNameTextViewItemCustomThemeSwitchItem.setText(customThemeSettingsItem.itemName);
+ ((ThemeSwitchItemViewHolder) holder).binding.themeItemInfoTextViewItemCustomThemeSwitchItem.setText(customThemeSettingsItem.itemName);
+ ((ThemeSwitchItemViewHolder) holder).binding.themeItemSwitchItemCustomThemeSwitchItem.setChecked(customThemeSettingsItem.isEnabled);
+ ((ThemeSwitchItemViewHolder) holder).binding.themeItemSwitchItemCustomThemeSwitchItem.setOnClickListener(view -> customThemeSettingsItem.isEnabled = ((ThemeSwitchItemViewHolder) holder).binding.themeItemSwitchItemCustomThemeSwitchItem.isChecked());
+ holder.itemView.setOnClickListener(view -> ((ThemeSwitchItemViewHolder) holder).binding.themeItemSwitchItemCustomThemeSwitchItem.performClick());
} else if (holder instanceof ThemeNameItemViewHolder) {
- ((ThemeNameItemViewHolder) holder).themeNameTextView.setText(themeName);
+ ((ThemeNameItemViewHolder) holder).binding.themeNameTextViewItemThemeName.setText(themeName);
holder.itemView.setOnClickListener(view -> {
View dialogView = activity.getLayoutInflater().inflate(R.layout.dialog_edit_name, null);
EditText themeNameEditText = dialogView.findViewById(R.id.name_edit_text_edit_name_dialog);
@@ -100,7 +99,7 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
-> {
Utils.hideKeyboard(activity);
themeName = themeNameEditText.getText().toString();
- ((ThemeNameItemViewHolder) holder).themeNameTextView.setText(themeName);
+ ((ThemeNameItemViewHolder) holder).binding.themeNameTextViewItemThemeName.setText(themeName);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
Utils.hideKeyboard(activity);
@@ -129,64 +128,52 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
class ThemeColorItemViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.color_image_view_item_custom_theme_color_item)
- View colorImageView;
- @BindView(R.id.theme_item_name_text_view_item_custom_theme_color_item)
- TextView themeItemNameTextView;
- @BindView(R.id.theme_item_info_text_view_item_custom_theme_color_item)
- TextView themeItemInfoTextView;
+ ItemCustomThemeColorItemBinding binding;
- ThemeColorItemViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ ThemeColorItemViewHolder(@NonNull ItemCustomThemeColorItemBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
- themeItemNameTextView.setTextColor(customThemeWrapper.getPrimaryTextColor());
- themeItemInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor());
+ binding.themeItemNameTextViewItemCustomThemeColorItem.setTextColor(customThemeWrapper.getPrimaryTextColor());
+ binding.themeItemInfoTextViewItemCustomThemeColorItem.setTextColor(customThemeWrapper.getSecondaryTextColor());
if (activity.typeface != null) {
- themeItemNameTextView.setTypeface(activity.typeface);
- themeItemInfoTextView.setTypeface(activity.typeface);
+ binding.themeItemNameTextViewItemCustomThemeColorItem.setTypeface(activity.typeface);
+ binding.themeItemInfoTextViewItemCustomThemeColorItem.setTypeface(activity.typeface);
}
}
}
class ThemeSwitchItemViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.theme_item_name_text_view_item_custom_theme_switch_item)
- TextView themeItemNameTextView;
- @BindView(R.id.theme_item_info_text_view_item_custom_theme_switch_item)
- TextView themeItemInfoTextView;
- @BindView(R.id.theme_item_switch_item_custom_theme_switch_item)
- MaterialSwitch themeItemSwitch;
+ ItemCustomThemeSwitchItemBinding binding;
- ThemeSwitchItemViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ ThemeSwitchItemViewHolder(@NonNull ItemCustomThemeSwitchItemBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
- themeItemNameTextView.setTextColor(customThemeWrapper.getPrimaryTextColor());
- themeItemInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor());
+ binding.themeItemNameTextViewItemCustomThemeSwitchItem.setTextColor(customThemeWrapper.getPrimaryTextColor());
+ binding.themeItemInfoTextViewItemCustomThemeSwitchItem.setTextColor(customThemeWrapper.getSecondaryTextColor());
if (activity.typeface != null) {
- themeItemNameTextView.setTypeface(activity.typeface);
- themeItemInfoTextView.setTypeface(activity.typeface);
+ binding.themeItemNameTextViewItemCustomThemeSwitchItem.setTypeface(activity.typeface);
+ binding.themeItemInfoTextViewItemCustomThemeSwitchItem.setTypeface(activity.typeface);
}
}
}
class ThemeNameItemViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.theme_name_text_view_item_theme_name)
- TextView themeNameTextView;
- @BindView(R.id.description_text_view_item_theme_name)
- TextView descriptionTextView;
- public ThemeNameItemViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ ItemThemeNameBinding binding;
- themeNameTextView.setTextColor(customThemeWrapper.getPrimaryTextColor());
- descriptionTextView.setTextColor(customThemeWrapper.getSecondaryTextColor());
+ public ThemeNameItemViewHolder(@NonNull ItemThemeNameBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
+
+ binding.themeNameTextViewItemThemeName.setTextColor(customThemeWrapper.getPrimaryTextColor());
+ binding.descriptionTextViewItemThemeName.setTextColor(customThemeWrapper.getSecondaryTextColor());
if (activity.typeface != null) {
- themeNameTextView.setTypeface(activity.typeface);
- descriptionTextView.setTypeface(activity.typeface);
+ binding.themeNameTextViewItemThemeName.setTypeface(activity.typeface);
+ binding.descriptionTextViewItemThemeName.setTypeface(activity.typeface);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java
index 27af320e..70b0f258 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java
@@ -5,8 +5,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
@@ -15,12 +13,11 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.ArrayList;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.databinding.ItemFlairBinding;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<FlairBottomSheetRecyclerViewAdapter.FlairViewHolder> {
@@ -39,14 +36,14 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<Fl
@NonNull
@Override
public FlairViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- return new FlairViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_flair, parent, false));
+ return new FlairViewHolder(ItemFlairBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
@Override
public void onBindViewHolder(@NonNull FlairViewHolder holder, int position) {
if (flairs.get(holder.getBindingAdapterPosition()).isEditable()) {
- holder.editFlairImageView.setVisibility(View.VISIBLE);
- holder.editFlairImageView.setOnClickListener(view -> {
+ holder.binding.editFlairImageViewItemFlair.setVisibility(View.VISIBLE);
+ holder.binding.editFlairImageViewItemFlair.setOnClickListener(view -> {
View dialogView = activity.getLayoutInflater().inflate(R.layout.dialog_edit_flair, null);
EditText flairEditText = dialogView.findViewById(R.id.flair_edit_text_edit_flair_dialog);
flairEditText.requestFocus();
@@ -66,12 +63,12 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<Fl
}
if (flairs.get(holder.getBindingAdapterPosition()).isEditable() && flairs.get(holder.getBindingAdapterPosition()).getText().equals("")) {
- holder.itemView.setOnClickListener(view -> holder.editFlairImageView.performClick());
+ holder.itemView.setOnClickListener(view -> holder.binding.editFlairImageViewItemFlair.performClick());
} else {
holder.itemView.setOnClickListener(view -> itemClickListener.onClick(flairs.get(holder.getBindingAdapterPosition())));
}
- holder.flairTextView.setText(flairs.get(holder.getBindingAdapterPosition()).getText());
+ holder.binding.flairTextViewItemFlair.setText(flairs.get(holder.getBindingAdapterPosition()).getText());
}
@Override
@@ -82,7 +79,7 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<Fl
@Override
public void onViewRecycled(@NonNull FlairViewHolder holder) {
super.onViewRecycled(holder);
- holder.editFlairImageView.setVisibility(View.GONE);
+ holder.binding.editFlairImageViewItemFlair.setVisibility(View.GONE);
}
public void changeDataset(ArrayList<Flair> flairs) {
@@ -95,20 +92,15 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<Fl
}
class FlairViewHolder extends RecyclerView.ViewHolder {
- View itemView;
- @BindView(R.id.flair_text_view_item_flair)
- TextView flairTextView;
- @BindView(R.id.edit_flair_image_view_item_flair)
- ImageView editFlairImageView;
-
- FlairViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
- this.itemView = itemView;
- flairTextView.setTextColor(flairTextColor);
+ ItemFlairBinding binding;
+
+ FlairViewHolder(@NonNull ItemFlairBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
+ binding.flairTextViewItemFlair.setTextColor(flairTextColor);
if (activity.typeface != null) {
- flairTextView.setTypeface(activity.typeface);
+ binding.flairTextViewItemFlair.setTypeface(activity.typeface);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java
index b87bb9cb..430371b4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java
@@ -3,10 +3,7 @@ package ml.docilealligator.infinityforreddit.adapters;
import android.content.Intent;
import android.os.Handler;
import android.view.LayoutInflater;
-import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
@@ -20,8 +17,6 @@ import com.bumptech.glide.request.RequestOptions;
import java.util.List;
import java.util.concurrent.Executor;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import me.zhanghai.android.fastscroll.PopupTextProvider;
import ml.docilealligator.infinityforreddit.FavoriteThing;
@@ -30,8 +25,9 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.databinding.ItemFavoriteThingDividerBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemSubscribedThingBinding;
import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserData;
-import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
@@ -89,17 +85,17 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
switch (i) {
case VIEW_TYPE_FAVORITE_USER_DIVIDER:
- return new FavoriteUsersDividerViewHolder(LayoutInflater.from(viewGroup.getContext())
- .inflate(R.layout.item_favorite_thing_divider, viewGroup, false));
+ return new FavoriteUsersDividerViewHolder(ItemFavoriteThingDividerBinding
+ .inflate(LayoutInflater.from(viewGroup.getContext()), viewGroup, false));
case VIEW_TYPE_FAVORITE_USER:
- return new FavoriteUserViewHolder(LayoutInflater.from(viewGroup.getContext())
- .inflate(R.layout.item_subscribed_thing, viewGroup, false));
+ return new FavoriteUserViewHolder(ItemSubscribedThingBinding
+ .inflate(LayoutInflater.from(viewGroup.getContext()), viewGroup, false));
case VIEW_TYPE_USER_DIVIDER:
- return new AllUsersDividerViewHolder(LayoutInflater.from(viewGroup.getContext())
- .inflate(R.layout.item_favorite_thing_divider, viewGroup, false));
+ return new AllUsersDividerViewHolder(ItemFavoriteThingDividerBinding
+ .inflate(LayoutInflater.from(viewGroup.getContext()), viewGroup, false));
default:
- return new UserViewHolder(LayoutInflater.from(viewGroup.getContext())
- .inflate(R.layout.item_subscribed_thing, viewGroup, false));
+ return new UserViewHolder(ItemSubscribedThingBinding
+ .inflate(LayoutInflater.from(viewGroup.getContext()), viewGroup, false));
}
}
@@ -114,18 +110,18 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((UserViewHolder) viewHolder).iconGifImageView);
+ .into(((UserViewHolder) viewHolder).binding.thingIconGifImageViewItemSubscribedThing);
} else {
glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((UserViewHolder) viewHolder).iconGifImageView);
+ .into(((UserViewHolder) viewHolder).binding.thingIconGifImageViewItemSubscribedThing);
}
- ((UserViewHolder) viewHolder).userNameTextView.setText(mSubscribedUserData.get(viewHolder.getBindingAdapterPosition() - offset).getName());
+ ((UserViewHolder) viewHolder).binding.thingNameTextViewItemSubscribedThing.setText(mSubscribedUserData.get(viewHolder.getBindingAdapterPosition() - offset).getName());
if(mSubscribedUserData.get(viewHolder.getBindingAdapterPosition() - offset).isFavorite()) {
- ((UserViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ ((UserViewHolder) viewHolder).binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_24dp);
} else {
- ((UserViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ ((UserViewHolder) viewHolder).binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_border_24dp);
}
} else if (viewHolder instanceof FavoriteUserViewHolder) {
if (!mFavoriteSubscribedUserData.get(viewHolder.getBindingAdapterPosition() - 1).getIconUrl().equals("")) {
@@ -133,18 +129,18 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((FavoriteUserViewHolder) viewHolder).iconGifImageView);
+ .into(((FavoriteUserViewHolder) viewHolder).binding.thingIconGifImageViewItemSubscribedThing);
} else {
glide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((FavoriteUserViewHolder) viewHolder).iconGifImageView);
+ .into(((FavoriteUserViewHolder) viewHolder).binding.thingIconGifImageViewItemSubscribedThing);
}
- ((FavoriteUserViewHolder) viewHolder).userNameTextView.setText(mFavoriteSubscribedUserData.get(viewHolder.getBindingAdapterPosition() - 1).getName());
+ ((FavoriteUserViewHolder) viewHolder).binding.thingNameTextViewItemSubscribedThing.setText(mFavoriteSubscribedUserData.get(viewHolder.getBindingAdapterPosition() - 1).getName());
if(mFavoriteSubscribedUserData.get(viewHolder.getBindingAdapterPosition() - 1).isFavorite()) {
- ((FavoriteUserViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ ((FavoriteUserViewHolder) viewHolder).binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_24dp);
} else {
- ((FavoriteUserViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ ((FavoriteUserViewHolder) viewHolder).binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_border_24dp);
}
}
}
@@ -163,9 +159,9 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if(holder instanceof UserViewHolder) {
- glide.clear(((UserViewHolder) holder).iconGifImageView);
+ glide.clear(((UserViewHolder) holder).binding.thingIconGifImageViewItemSubscribedThing);
} else if (holder instanceof FavoriteUserViewHolder) {
- glide.clear(((FavoriteUserViewHolder) holder).iconGifImageView);
+ glide.clear(((FavoriteUserViewHolder) holder).binding.thingIconGifImageViewItemSubscribedThing);
}
}
@@ -195,20 +191,15 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
}
class FavoriteUserViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.thing_icon_gif_image_view_item_subscribed_thing)
- GifImageView iconGifImageView;
- @BindView(R.id.thing_name_text_view_item_subscribed_thing)
- TextView userNameTextView;
- @BindView(R.id.favorite_image_view_item_subscribed_thing)
- ImageView favoriteImageView;
-
- FavoriteUserViewHolder(View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ ItemSubscribedThingBinding binding;
+
+ FavoriteUserViewHolder(ItemSubscribedThingBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- userNameTextView.setTypeface(mActivity.typeface);
+ binding.thingNameTextViewItemSubscribedThing.setTypeface(mActivity.typeface);
}
- userNameTextView.setTextColor(mPrimaryTextColor);
+ binding.thingNameTextViewItemSubscribedThing.setTextColor(mPrimaryTextColor);
itemView.setOnClickListener(view -> {
int position = getBindingAdapterPosition() - 1;
@@ -219,11 +210,11 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
}
});
- favoriteImageView.setOnClickListener(view -> {
+ binding.favoriteImageViewItemSubscribedThing.setOnClickListener(view -> {
int position = getBindingAdapterPosition() - 1;
if(position >= 0 && mFavoriteSubscribedUserData.size() > position) {
if(mFavoriteSubscribedUserData.get(position).isFavorite()) {
- favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_border_24dp);
mFavoriteSubscribedUserData.get(position).setFavorite(false);
FavoriteThing.unfavoriteUser(mExecutor, new Handler(), mOauthRetrofit,
mRedditDataRoomDatabase, mAccessToken, mAccountName,
@@ -235,7 +226,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
if(position >= 0 && mFavoriteSubscribedUserData.size() > position) {
mFavoriteSubscribedUserData.get(position).setFavorite(false);
}
- favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_border_24dp);
}
@Override
@@ -245,11 +236,11 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
if(position >= 0 && mFavoriteSubscribedUserData.size() > position) {
mFavoriteSubscribedUserData.get(position).setFavorite(true);
}
- favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_24dp);
}
});
} else {
- favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_24dp);
mFavoriteSubscribedUserData.get(position).setFavorite(true);
FavoriteThing.favoriteUser(mExecutor, new Handler(), mOauthRetrofit,
mRedditDataRoomDatabase, mAccessToken, mAccountName,
@@ -261,7 +252,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
if(position >= 0 && mFavoriteSubscribedUserData.size() > position) {
mFavoriteSubscribedUserData.get(position).setFavorite(true);
}
- favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_24dp);
}
@Override
@@ -271,7 +262,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
if(position >= 0 && mFavoriteSubscribedUserData.size() > position) {
mFavoriteSubscribedUserData.get(position).setFavorite(false);
}
- favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_border_24dp);
}
});
}
@@ -281,20 +272,15 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
}
class UserViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.thing_icon_gif_image_view_item_subscribed_thing)
- GifImageView iconGifImageView;
- @BindView(R.id.thing_name_text_view_item_subscribed_thing)
- TextView userNameTextView;
- @BindView(R.id.favorite_image_view_item_subscribed_thing)
- ImageView favoriteImageView;
-
- UserViewHolder(View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ ItemSubscribedThingBinding binding;
+
+ UserViewHolder(@NonNull ItemSubscribedThingBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- userNameTextView.setTypeface(mActivity.typeface);
+ binding.thingNameTextViewItemSubscribedThing.setTypeface(mActivity.typeface);
}
- userNameTextView.setTextColor(mPrimaryTextColor);
+ binding.thingNameTextViewItemSubscribedThing.setTextColor(mPrimaryTextColor);
itemView.setOnClickListener(view -> {
int offset = (mFavoriteSubscribedUserData != null && mFavoriteSubscribedUserData.size() > 0) ?
@@ -307,14 +293,14 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
}
});
- favoriteImageView.setOnClickListener(view -> {
+ binding.favoriteImageViewItemSubscribedThing.setOnClickListener(view -> {
int offset = (mFavoriteSubscribedUserData != null && mFavoriteSubscribedUserData.size() > 0) ?
mFavoriteSubscribedUserData.size() + 2 : 0;
int position = getBindingAdapterPosition() - offset;
if(position >= 0 && mSubscribedUserData.size() > position) {
if(mSubscribedUserData.get(position).isFavorite()) {
- favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_border_24dp);
mSubscribedUserData.get(position).setFavorite(false);
FavoriteThing.unfavoriteUser(mExecutor, new Handler(), mOauthRetrofit,
mRedditDataRoomDatabase, mAccessToken, mAccountName,
@@ -326,7 +312,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
if(position >= 0 && mSubscribedUserData.size() > position) {
mSubscribedUserData.get(position).setFavorite(false);
}
- favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_border_24dp);
}
@Override
@@ -336,11 +322,11 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
if(position >= 0 && mSubscribedUserData.size() > position) {
mSubscribedUserData.get(position).setFavorite(true);
}
- favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_24dp);
}
});
} else {
- favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_24dp);
mSubscribedUserData.get(position).setFavorite(true);
FavoriteThing.favoriteUser(mExecutor, new Handler(), mOauthRetrofit,
mRedditDataRoomDatabase, mAccessToken, mAccountName,
@@ -352,7 +338,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
if(position >= 0 && mSubscribedUserData.size() > position) {
mSubscribedUserData.get(position).setFavorite(true);
}
- favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_24dp);
}
@Override
@@ -362,7 +348,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
if(position >= 0 && mSubscribedUserData.size() > position) {
mSubscribedUserData.get(position).setFavorite(false);
}
- favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ binding.favoriteImageViewItemSubscribedThing.setImageResource(R.drawable.ic_favorite_border_24dp);
}
});
}
@@ -372,30 +358,30 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
}
class FavoriteUsersDividerViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.divider_text_view_item_favorite_thing_divider) TextView dividerTextView;
+ ItemFavoriteThingDividerBinding binding;
- FavoriteUsersDividerViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ FavoriteUsersDividerViewHolder(@NonNull ItemFavoriteThingDividerBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- dividerTextView.setTypeface(mActivity.typeface);
+ binding.dividerTextViewItemFavoriteThingDivider.setTypeface(mActivity.typeface);
}
- dividerTextView.setText(R.string.favorites);
- dividerTextView.setTextColor(mSecondaryTextColor);
+ binding.dividerTextViewItemFavoriteThingDivider.setText(R.string.favorites);
+ binding.dividerTextViewItemFavoriteThingDivider.setTextColor(mSecondaryTextColor);
}
}
class AllUsersDividerViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.divider_text_view_item_favorite_thing_divider) TextView dividerTextView;
+ ItemFavoriteThingDividerBinding binding;
- AllUsersDividerViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ AllUsersDividerViewHolder(@NonNull ItemFavoriteThingDividerBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- dividerTextView.setTypeface(mActivity.typeface);
+ binding.dividerTextViewItemFavoriteThingDivider.setTypeface(mActivity.typeface);
}
- dividerTextView.setText(R.string.all);
- dividerTextView.setTextColor(mSecondaryTextColor);
+ binding.dividerTextViewItemFavoriteThingDivider.setText(R.string.all);
+ binding.dividerTextViewItemFavoriteThingDivider.setTextColor(mSecondaryTextColor);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
index 288788eb..0486751e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
@@ -61,8 +61,6 @@ import java.util.concurrent.Executor;
import javax.inject.Provider;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.FetchRedgifsVideoLinks;
@@ -100,6 +98,7 @@ import ml.docilealligator.infinityforreddit.databinding.ItemPostCard3VideoTypeAu
import ml.docilealligator.infinityforreddit.databinding.ItemPostCard3WithPreviewBinding;
import ml.docilealligator.infinityforreddit.databinding.ItemPostCompactBinding;
import ml.docilealligator.infinityforreddit.databinding.ItemPostCompactRightThumbnailBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryBinding;
import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryGalleryTypeBinding;
import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryTypeBinding;
import ml.docilealligator.infinityforreddit.databinding.ItemPostTextBinding;
@@ -513,7 +512,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
return new PostCompactLeftThumbnailViewHolder(ItemPostCompactBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
} else if (viewType == VIEW_TYPE_POST_GALLERY) {
- return new PostGalleryViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_gallery, parent, false));
+ return new PostGalleryViewHolder(ItemPostGalleryBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
} else if (viewType == VIEW_TYPE_POST_GALLERY_GALLERY_TYPE) {
return new PostGalleryGalleryTypeViewHolder(ItemPostGalleryGalleryTypeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
} else if (viewType == VIEW_TYPE_POST_CARD_2_VIDEO_AUTOPLAY_TYPE) {
@@ -1408,67 +1407,67 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
- ((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.setVisibility(View.VISIBLE);
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
- ((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
- ((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.getLayoutParams().height = height;
} else {
- ((PostGalleryViewHolder) holder).imageView
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- ((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
- ((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.removeOnLayoutChangeListener(this);
loadImage(holder);
}
});
} else {
- ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setVisibility(View.VISIBLE);
if (post.getPostType() == Post.VIDEO_TYPE) {
- ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_outline_video_24dp);
- ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setImageResource(R.drawable.ic_outline_video_24dp);
+ ((PostGalleryViewHolder) holder).binding.videoOrGifIndicatorImageViewItemPostGallery.setVisibility(View.GONE);
} else if (post.getPostType() == Post.IMAGE_TYPE || post.getPostType() == Post.GIF_TYPE) {
- ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
+ ((PostGalleryViewHolder) holder).binding.videoOrGifIndicatorImageViewItemPostGallery.setVisibility(View.GONE);
} else if (post.getPostType() == Post.LINK_TYPE) {
- ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setImageResource(R.drawable.ic_link);
}
- ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setImageResource(R.drawable.ic_image_24dp);
}
break;
}
case Post.GIF_TYPE: {
if (post.getPostType() == Post.GIF_TYPE && ((post.isNSFW() && mNeedBlurNsfw && !(mAutoplay && mAutoplayNsfwVideos)) || (post.isSpoiler() && mNeedBlurSpoiler))) {
- ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setImageResource(R.drawable.ic_image_24dp);
} else {
Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
- ((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.videoOrGifIndicatorImageViewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.videoOrGifIndicatorImageViewItemPostGallery.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
- ((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
- ((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.getLayoutParams().height = height;
} else {
- ((PostGalleryViewHolder) holder).imageView
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- ((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
- ((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.removeOnLayoutChangeListener(this);
loadImage(holder);
}
});
} else {
- ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setImageResource(R.drawable.ic_image_24dp);
}
}
break;
@@ -1477,28 +1476,28 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
- ((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.videoOrGifIndicatorImageViewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.videoOrGifIndicatorImageViewItemPostGallery.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
- ((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
- ((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.getLayoutParams().height = height;
} else {
- ((PostGalleryViewHolder) holder).imageView
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- ((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
- ((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.removeOnLayoutChangeListener(this);
loadImage(holder);
}
});
} else {
- ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_outline_video_24dp);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setImageResource(R.drawable.ic_outline_video_24dp);
}
break;
}
@@ -1506,39 +1505,39 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
- ((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_link_post_type_indicator));
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.videoOrGifIndicatorImageViewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.videoOrGifIndicatorImageViewItemPostGallery.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_link_post_type_indicator));
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
- ((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
- ((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.getLayoutParams().height = height;
} else {
- ((PostGalleryViewHolder) holder).imageView
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
}
- ((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
- ((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.removeOnLayoutChangeListener(this);
loadImage(holder);
}
});
} else {
- ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setImageResource(R.drawable.ic_link);
}
break;
}
case Post.NO_PREVIEW_LINK_TYPE: {
- ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setImageResource(R.drawable.ic_link);
break;
}
case Post.TEXT_TYPE: {
- ((PostGalleryViewHolder) holder).titleTextView.setVisibility(View.VISIBLE);
- ((PostGalleryViewHolder) holder).titleTextView.setText(post.getTitle());
+ ((PostGalleryViewHolder) holder).binding.titleTextViewItemPostGallery.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.titleTextViewItemPostGallery.setText(post.getTitle());
break;
}
}
@@ -1988,7 +1987,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
}
}
} else if (holder instanceof PostGalleryViewHolder) {
- ((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
+ ((PostGalleryViewHolder) holder).binding.progressBarItemPostGallery.setVisibility(View.VISIBLE);
Post post = ((PostGalleryViewHolder) holder).post;
Post.Preview preview = ((PostGalleryViewHolder) holder).preview;
if (preview != null) {
@@ -2003,9 +2002,9 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
if (blurImage) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
- .into(((PostGalleryViewHolder) holder).imageView);
+ .into(((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery);
} else {
- imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostGalleryViewHolder) holder).imageView);
+ imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery);
}
}
} else if (holder instanceof PostCard2WithPreviewViewHolder) {
@@ -2313,14 +2312,14 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
} else if (holder instanceof PostGalleryViewHolder) {
holder.itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor));
- ((PostGalleryViewHolder) holder).titleTextView.setText("");
- ((PostGalleryViewHolder) holder).titleTextView.setVisibility(View.GONE);
- mGlide.clear(((PostGalleryViewHolder) holder).imageView);
- ((PostGalleryViewHolder) holder).imageView.setVisibility(View.GONE);
- ((PostGalleryViewHolder) holder).progressBar.setVisibility(View.GONE);
- ((PostGalleryViewHolder) holder).errorTextView.setVisibility(View.GONE);
- ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
- ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.GONE);
+ ((PostGalleryViewHolder) holder).binding.titleTextViewItemPostGallery.setText("");
+ ((PostGalleryViewHolder) holder).binding.titleTextViewItemPostGallery.setVisibility(View.GONE);
+ mGlide.clear(((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery);
+ ((PostGalleryViewHolder) holder).binding.imageViewItemPostGallery.setVisibility(View.GONE);
+ ((PostGalleryViewHolder) holder).binding.progressBarItemPostGallery.setVisibility(View.GONE);
+ ((PostGalleryViewHolder) holder).binding.loadImageErrorTextViewItemGallery.setVisibility(View.GONE);
+ ((PostGalleryViewHolder) holder).binding.videoOrGifIndicatorImageViewItemPostGallery.setVisibility(View.GONE);
+ ((PostGalleryViewHolder) holder).binding.imageViewNoPreviewItemPostGallery.setVisibility(View.GONE);
} else if (holder instanceof PostGalleryBaseGalleryTypeViewHolder) {
holder.itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor));
((PostGalleryBaseGalleryTypeViewHolder) holder).frameLayout.setVisibility(View.GONE);
@@ -4489,40 +4488,29 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
}
class PostGalleryViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.progress_bar_item_post_gallery)
- ProgressBar progressBar;
- @BindView(R.id.video_or_gif_indicator_image_view_item_post_gallery)
- ImageView videoOrGifIndicatorImageView;
- @BindView(R.id.image_view_item_post_gallery)
- AspectRatioGifImageView imageView;
- @BindView(R.id.load_image_error_text_view_item_gallery)
- TextView errorTextView;
- @BindView(R.id.image_view_no_preview_item_post_gallery)
- ImageView noPreviewImageView;
- @BindView(R.id.title_text_view_item_post_gallery)
- TextView titleTextView;
+ ItemPostGalleryBinding binding;
RequestListener<Drawable> requestListener;
Post post;
Post.Preview preview;
- public PostGalleryViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ public PostGalleryViewHolder(@NonNull ItemPostGalleryBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- errorTextView.setTypeface(mActivity.typeface);
+ binding.loadImageErrorTextViewItemGallery.setTypeface(mActivity.typeface);
}
if (mActivity.titleTypeface != null) {
- titleTextView.setTypeface(mActivity.titleTypeface);
+ binding.titleTextViewItemPostGallery.setTypeface(mActivity.titleTypeface);
}
itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor));
- titleTextView.setTextColor(mPostTitleColor);
- progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
- noPreviewImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
- noPreviewImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
- videoOrGifIndicatorImageView.setColorFilter(mMediaIndicatorIconTint, PorterDuff.Mode.SRC_IN);
- videoOrGifIndicatorImageView.setBackgroundTintList(ColorStateList.valueOf(mMediaIndicatorBackgroundColor));
- errorTextView.setTextColor(mPrimaryTextColor);
+ binding.titleTextViewItemPostGallery.setTextColor(mPostTitleColor);
+ binding.progressBarItemPostGallery.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
+ binding.imageViewNoPreviewItemPostGallery.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
+ binding.imageViewNoPreviewItemPostGallery.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
+ binding.videoOrGifIndicatorImageViewItemPostGallery.setColorFilter(mMediaIndicatorIconTint, PorterDuff.Mode.SRC_IN);
+ binding.videoOrGifIndicatorImageViewItemPostGallery.setBackgroundTintList(ColorStateList.valueOf(mMediaIndicatorBackgroundColor));
+ binding.loadImageErrorTextViewItemGallery.setTextColor(mPrimaryTextColor);
itemView.setOnClickListener(view -> {
int position = getBindingAdapterPosition();
@@ -4554,28 +4542,28 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
return true;
});
- errorTextView.setOnClickListener(view -> {
- progressBar.setVisibility(View.VISIBLE);
- errorTextView.setVisibility(View.GONE);
+ binding.loadImageErrorTextViewItemGallery.setOnClickListener(view -> {
+ binding.progressBarItemPostGallery.setVisibility(View.VISIBLE);
+ binding.loadImageErrorTextViewItemGallery.setVisibility(View.GONE);
loadImage(this);
});
- noPreviewImageView.setOnClickListener(view -> {
+ binding.imageViewNoPreviewItemPostGallery.setOnClickListener(view -> {
itemView.performClick();
});
requestListener = new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
- progressBar.setVisibility(View.GONE);
- errorTextView.setVisibility(View.VISIBLE);
+ binding.progressBarItemPostGallery.setVisibility(View.GONE);
+ binding.loadImageErrorTextViewItemGallery.setVisibility(View.VISIBLE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
- errorTextView.setVisibility(View.GONE);
- progressBar.setVisibility(View.GONE);
+ binding.loadImageErrorTextViewItemGallery.setVisibility(View.GONE);
+ binding.progressBarItemPostGallery.setVisibility(View.GONE);
return false;
}
};
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
index 14deafa7..4b622551 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
@@ -8,9 +8,6 @@ import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.ProgressBar;
-import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.paging.PagedListAdapter;
@@ -21,8 +18,6 @@ import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
@@ -40,6 +35,9 @@ import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivity;
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.databinding.ItemFooterErrorBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemFooterLoadingBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemMessageBinding;
import ml.docilealligator.infinityforreddit.events.ChangeInboxCountEvent;
import ml.docilealligator.infinityforreddit.markdown.RedditHeadingPlugin;
import ml.docilealligator.infinityforreddit.markdown.SpoilerAwareMovementMethod;
@@ -143,11 +141,11 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (viewType == VIEW_TYPE_DATA) {
- return new DataViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message, parent, false));
+ return new DataViewHolder(ItemMessageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
} else if (viewType == VIEW_TYPE_ERROR) {
- return new ErrorViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false));
+ return new ErrorViewHolder(ItemFooterErrorBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
} else {
- return new LoadingViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_loading, parent, false));
+ return new LoadingViewHolder(ItemFooterLoadingBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
}
@@ -173,15 +171,15 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
}
if (message.wasComment()) {
- ((DataViewHolder) holder).titleTextView.setText(message.getTitle());
+ ((DataViewHolder) holder).binding.titleTextViewItemMessage.setText(message.getTitle());
} else {
- ((DataViewHolder) holder).titleTextView.setVisibility(View.GONE);
+ ((DataViewHolder) holder).binding.titleTextViewItemMessage.setVisibility(View.GONE);
}
- ((DataViewHolder) holder).authorTextView.setText(displayedMessage.getAuthor());
+ ((DataViewHolder) holder).binding.authorTextViewItemMessage.setText(displayedMessage.getAuthor());
String subject = displayedMessage.getSubject().substring(0, 1).toUpperCase() + displayedMessage.getSubject().substring(1);
- ((DataViewHolder) holder).subjectTextView.setText(subject);
- mMarkwon.setMarkdown(((DataViewHolder) holder).contentCustomMarkwonView, displayedMessage.getBody());
+ ((DataViewHolder) holder).binding.subjectTextViewItemMessage.setText(subject);
+ mMarkwon.setMarkdown(((DataViewHolder) holder).binding.contentCustomMarkwonViewItemMessage, displayedMessage.getBody());
holder.itemView.setOnClickListener(view -> {
if (mMessageType == FetchMessage.MESSAGE_TYPE_INBOX
@@ -217,7 +215,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
}
});
- ((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
+ ((DataViewHolder) holder).binding.authorTextViewItemMessage.setOnClickListener(view -> {
if (message.isAuthorDeleted()) {
return;
}
@@ -256,7 +254,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
super.onViewRecycled(holder);
if (holder instanceof DataViewHolder) {
((DataViewHolder) holder).itemView.setBackgroundColor(mMessageBackgroundColor);
- ((DataViewHolder) holder).titleTextView.setVisibility(View.VISIBLE);
+ ((DataViewHolder) holder).binding.titleTextViewItemMessage.setVisibility(View.VISIBLE);
}
}
@@ -298,34 +296,27 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
}
class DataViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.author_text_view_item_message)
- TextView authorTextView;
- @BindView(R.id.subject_text_view_item_message)
- TextView subjectTextView;
- @BindView(R.id.title_text_view_item_message)
- TextView titleTextView;
- @BindView(R.id.content_custom_markwon_view_item_message)
- TextView contentCustomMarkwonView;
-
- DataViewHolder(View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ ItemMessageBinding binding;
+
+ DataViewHolder(@NonNull ItemMessageBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- authorTextView.setTypeface(mActivity.typeface);
- subjectTextView.setTypeface(mActivity.typeface);
- titleTextView.setTypeface(mActivity.titleTypeface);
- contentCustomMarkwonView.setTypeface(mActivity.contentTypeface);
+ binding.authorTextViewItemMessage.setTypeface(mActivity.typeface);
+ binding.subjectTextViewItemMessage.setTypeface(mActivity.typeface);
+ binding.titleTextViewItemMessage.setTypeface(mActivity.titleTypeface);
+ binding.contentCustomMarkwonViewItemMessage.setTypeface(mActivity.contentTypeface);
}
itemView.setBackgroundColor(mMessageBackgroundColor);
- authorTextView.setTextColor(mUsernameColor);
- subjectTextView.setTextColor(mPrimaryTextColor);
- titleTextView.setTextColor(mPrimaryTextColor);
- contentCustomMarkwonView.setTextColor(mSecondaryTextColor);
+ binding.authorTextViewItemMessage.setTextColor(mUsernameColor);
+ binding.subjectTextViewItemMessage.setTextColor(mPrimaryTextColor);
+ binding.titleTextViewItemMessage.setTextColor(mPrimaryTextColor);
+ binding.contentCustomMarkwonViewItemMessage.setTextColor(mSecondaryTextColor);
- contentCustomMarkwonView.setMovementMethod(LinkMovementMethod.getInstance());
+ binding.contentCustomMarkwonViewItemMessage.setMovementMethod(LinkMovementMethod.getInstance());
- contentCustomMarkwonView.setOnClickListener(view -> {
- if (contentCustomMarkwonView.getSelectionStart() == -1 && contentCustomMarkwonView.getSelectionEnd() == -1) {
+ binding.contentCustomMarkwonViewItemMessage.setOnClickListener(view -> {
+ if (binding.contentCustomMarkwonViewItemMessage.getSelectionStart() == -1 && binding.contentCustomMarkwonViewItemMessage.getSelectionEnd() == -1) {
itemView.performClick();
}
});
@@ -333,34 +324,30 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
}
class ErrorViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.error_text_view_item_footer_error)
- TextView errorTextView;
- @BindView(R.id.retry_button_item_footer_error)
- Button retryButton;
-
- ErrorViewHolder(View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ ItemFooterErrorBinding binding;
+
+ ErrorViewHolder(@NonNull ItemFooterErrorBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- errorTextView.setTypeface(mActivity.typeface);
- retryButton.setTypeface(mActivity.typeface);
+ binding.errorTextViewItemFooterError.setTypeface(mActivity.typeface);
+ binding.retryButtonItemFooterError.setTypeface(mActivity.typeface);
}
- errorTextView.setText(R.string.load_comments_failed);
- errorTextView.setTextColor(mSecondaryTextColor);
- retryButton.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore());
- retryButton.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
- retryButton.setTextColor(mButtonTextColor);
+ binding.errorTextViewItemFooterError.setText(R.string.load_comments_failed);
+ binding.errorTextViewItemFooterError.setTextColor(mSecondaryTextColor);
+ binding.retryButtonItemFooterError.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore());
+ binding.retryButtonItemFooterError.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
+ binding.retryButtonItemFooterError.setTextColor(mButtonTextColor);
}
}
class LoadingViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.progress_bar_item_footer_loading)
- ProgressBar progressBar;
+ ItemFooterLoadingBinding binding;
- LoadingViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
- progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
+ LoadingViewHolder(@NonNull ItemFooterLoadingBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
+ binding.progressBarItemFooterLoading.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MultiRedditListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MultiRedditListingRecyclerViewAdapter.java
index 768a78fc..38d0a938 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MultiRedditListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MultiRedditListingRecyclerViewAdapter.java
@@ -2,10 +2,7 @@ package ml.docilealligator.infinityforreddit.adapters;
import android.os.Handler;
import android.view.LayoutInflater;
-import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
@@ -19,8 +16,6 @@ import com.bumptech.glide.request.RequestOptions;
import java.util.List;
import java.util.concurrent.Executor;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import me.zhanghai.android.fastscroll.PopupTextProvider;
import ml.docilealligator.infinityforreddit.R;
@@ -29,9 +24,10 @@ import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.asynctasks.InsertMultireddit;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.databinding.ItemFavoriteThingDividerBinding;
+import ml.docilealligator.infinityforreddit.databinding.ItemMultiRedditBinding;
import ml.docilealligator.infinityforreddit.multireddit.FavoriteMultiReddit;
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
-import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
@@ -99,17 +95,17 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
switch (viewType) {
case VIEW_TYPE_FAVORITE_MULTI_REDDIT_DIVIDER:
- return new FavoriteMultiRedditsDividerViewHolder(LayoutInflater.from(parent.getContext())
- .inflate(R.layout.item_favorite_thing_divider, parent, false));
+ return new FavoriteMultiRedditsDividerViewHolder(ItemFavoriteThingDividerBinding
+ .inflate(LayoutInflater.from(parent.getContext()), parent, false));
case VIEW_TYPE_FAVORITE_MULTI_REDDIT:
- return new FavoriteMultiRedditViewHolder(LayoutInflater.from(parent.getContext())
- .inflate(R.layout.item_multi_reddit, parent, false));
+ return new FavoriteMultiRedditViewHolder(ItemMultiRedditBinding
+ .inflate(LayoutInflater.from(parent.getContext()), parent, false));
case VIEW_TYPE_MULTI_REDDIT_DIVIDER:
- return new AllMultiRedditsDividerViewHolder(LayoutInflater.from(parent.getContext())
- .inflate(R.layout.item_favorite_thing_divider, parent, false));
+ return new AllMultiRedditsDividerViewHolder(ItemFavoriteThingDividerBinding
+ .inflate(LayoutInflater.from(parent.getContext()), parent, false));
default:
- return new MultiRedditViewHolder(LayoutInflater.from(parent.getContext())
- .inflate(R.layout.item_multi_reddit, parent, false));
+ return new MultiRedditViewHolder(ItemMultiRedditBinding
+ .inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
}
@@ -126,14 +122,14 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
name = multiReddit.getDisplayName();
iconUrl = multiReddit.getIconUrl();
if(multiReddit.isFavorite()) {
- ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ ((MultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_24dp);
} else {
- ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ ((MultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_border_24dp);
}
- ((MultiRedditViewHolder) holder).favoriteImageView.setOnClickListener(view -> {
+ ((MultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setOnClickListener(view -> {
if(multiReddit.isFavorite()) {
- ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ ((MultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_border_24dp);
multiReddit.setFavorite(false);
if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
@@ -150,7 +146,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
if(position >= 0 && mMultiReddits.size() > position) {
mMultiReddits.get(position).setFavorite(false);
}
- ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ ((MultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_border_24dp);
}
@Override
@@ -160,13 +156,13 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
if(position >= 0 && mMultiReddits.size() > position) {
mMultiReddits.get(position).setFavorite(true);
}
- ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ ((MultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_24dp);
}
}
);
}
} else {
- ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ ((MultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_24dp);
multiReddit.setFavorite(true);
if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
@@ -183,7 +179,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
if(position >= 0 && mMultiReddits.size() > position) {
mMultiReddits.get(position).setFavorite(true);
}
- ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ ((MultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_24dp);
}
@Override
@@ -193,7 +189,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
if(position >= 0 && mMultiReddits.size() > position) {
mMultiReddits.get(position).setFavorite(false);
}
- ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ ((MultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_border_24dp);
}
}
);
@@ -214,26 +210,26 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((MultiRedditViewHolder) holder).iconImageView);
+ .into(((MultiRedditViewHolder) holder).binding.multiRedditIconGifImageViewItemMultiReddit);
} else {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((MultiRedditViewHolder) holder).iconImageView);
+ .into(((MultiRedditViewHolder) holder).binding.multiRedditIconGifImageViewItemMultiReddit);
}
- ((MultiRedditViewHolder) holder).multiRedditNameTextView.setText(name);
+ ((MultiRedditViewHolder) holder).binding.multiRedditNameTextViewItemMultiReddit.setText(name);
} else if (holder instanceof FavoriteMultiRedditViewHolder) {
MultiReddit multiReddit = mFavoriteMultiReddits.get(holder.getBindingAdapterPosition() - 1);
String name = multiReddit.getDisplayName();
String iconUrl = multiReddit.getIconUrl();
if(multiReddit.isFavorite()) {
- ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ ((FavoriteMultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_24dp);
} else {
- ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ ((FavoriteMultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_border_24dp);
}
- ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setOnClickListener(view -> {
+ ((FavoriteMultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setOnClickListener(view -> {
if(multiReddit.isFavorite()) {
- ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ ((FavoriteMultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_border_24dp);
multiReddit.setFavorite(false);
if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
@@ -250,7 +246,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
mFavoriteMultiReddits.get(position).setFavorite(false);
}
- ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ ((FavoriteMultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_border_24dp);
}
@Override
@@ -260,13 +256,13 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
mFavoriteMultiReddits.get(position).setFavorite(true);
}
- ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ ((FavoriteMultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_24dp);
}
}
);
}
} else {
- ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ ((FavoriteMultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_24dp);
multiReddit.setFavorite(true);
if (mAccountName.equals(Account.ANONYMOUS_ACCOUNT)) {
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
@@ -283,7 +279,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
mFavoriteMultiReddits.get(position).setFavorite(true);
}
- ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
+ ((FavoriteMultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_24dp);
}
@Override
@@ -293,7 +289,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
mFavoriteMultiReddits.get(position).setFavorite(false);
}
- ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
+ ((FavoriteMultiRedditViewHolder) holder).binding.favoriteImageViewItemMultiReddit.setImageResource(R.drawable.ic_favorite_border_24dp);
}
}
);
@@ -314,13 +310,13 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((FavoriteMultiRedditViewHolder) holder).iconImageView);
+ .into(((FavoriteMultiRedditViewHolder) holder).binding.multiRedditIconGifImageViewItemMultiReddit);
} else {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((FavoriteMultiRedditViewHolder) holder).iconImageView);
+ .into(((FavoriteMultiRedditViewHolder) holder).binding.multiRedditIconGifImageViewItemMultiReddit);
}
- ((FavoriteMultiRedditViewHolder) holder).multiRedditNameTextView.setText(name);
+ ((FavoriteMultiRedditViewHolder) holder).binding.multiRedditNameTextViewItemMultiReddit.setText(name);
}
}
@@ -340,9 +336,9 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if(holder instanceof MultiRedditViewHolder) {
- mGlide.clear(((MultiRedditViewHolder) holder).iconImageView);
+ mGlide.clear(((MultiRedditViewHolder) holder).binding.multiRedditIconGifImageViewItemMultiReddit);
} else if (holder instanceof FavoriteMultiRedditViewHolder) {
- mGlide.clear(((FavoriteMultiRedditViewHolder) holder).iconImageView);
+ mGlide.clear(((FavoriteMultiRedditViewHolder) holder).binding.multiRedditIconGifImageViewItemMultiReddit);
}
}
@@ -372,66 +368,56 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
}
class MultiRedditViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.multi_reddit_icon_gif_image_view_item_multi_reddit)
- GifImageView iconImageView;
- @BindView(R.id.multi_reddit_name_text_view_item_multi_reddit)
- TextView multiRedditNameTextView;
- @BindView(R.id.favorite_image_view_item_multi_reddit)
- ImageView favoriteImageView;
-
- MultiRedditViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ ItemMultiRedditBinding binding;
+
+ MultiRedditViewHolder(@NonNull ItemMultiRedditBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- multiRedditNameTextView.setTypeface(mActivity.typeface);
+ binding.multiRedditNameTextViewItemMultiReddit.setTypeface(mActivity.typeface);
}
- multiRedditNameTextView.setTextColor(mPrimaryTextColor);
+ binding.multiRedditNameTextViewItemMultiReddit.setTextColor(mPrimaryTextColor);
}
}
class FavoriteMultiRedditViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.multi_reddit_icon_gif_image_view_item_multi_reddit)
- GifImageView iconImageView;
- @BindView(R.id.multi_reddit_name_text_view_item_multi_reddit)
- TextView multiRedditNameTextView;
- @BindView(R.id.favorite_image_view_item_multi_reddit)
- ImageView favoriteImageView;
-
- FavoriteMultiRedditViewHolder(View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ ItemMultiRedditBinding binding;
+
+ FavoriteMultiRedditViewHolder(@NonNull ItemMultiRedditBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- multiRedditNameTextView.setTypeface(mActivity.typeface);
+ binding.multiRedditNameTextViewItemMultiReddit.setTypeface(mActivity.typeface);
}
- multiRedditNameTextView.setTextColor(mPrimaryTextColor);
+ binding.multiRedditNameTextViewItemMultiReddit.setTextColor(mPrimaryTextColor);
}
}
class FavoriteMultiRedditsDividerViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.divider_text_view_item_favorite_thing_divider) TextView dividerTextView;
+ ItemFavoriteThingDividerBinding binding;
- FavoriteMultiRedditsDividerViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ FavoriteMultiRedditsDividerViewHolder(@NonNull ItemFavoriteThingDividerBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- dividerTextView.setTypeface(mActivity.typeface);
+ binding.dividerTextViewItemFavoriteThingDivider.setTypeface(mActivity.typeface);
}
- dividerTextView.setText(R.string.favorites);
- dividerTextView.setTextColor(mSecondaryTextColor);
+ binding.dividerTextViewItemFavoriteThingDivider.setText(R.string.favorites);
+ binding.dividerTextViewItemFavoriteThingDivider.setTextColor(mSecondaryTextColor);
}
}
class AllMultiRedditsDividerViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.divider_text_view_item_favorite_thing_divider) TextView dividerTextView;
+ ItemFavoriteThingDividerBinding binding;
- AllMultiRedditsDividerViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ AllMultiRedditsDividerViewHolder(@NonNull ItemFavoriteThingDividerBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (mActivity.typeface != null) {
- dividerTextView.setTypeface(mActivity.typeface);
+ binding.dividerTextViewItemFavoriteThingDivider.setTypeface(mActivity.typeface);
}
- dividerTextView.setText(R.string.all);
- dividerTextView.setTextColor(mSecondaryTextColor);
+ binding.dividerTextViewItemFavoriteThingDivider.setText(R.string.all);
+ binding.dividerTextViewItemFavoriteThingDivider.setTextColor(mSecondaryTextColor);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/OnlineCustomThemeListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/OnlineCustomThemeListingRecyclerViewAdapter.java
index 038d26ca..840ca209 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/OnlineCustomThemeListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/OnlineCustomThemeListingRecyclerViewAdapter.java
@@ -6,7 +6,6 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -14,14 +13,13 @@ import androidx.paging.PagingDataAdapter;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.RecyclerView;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CustomThemeListingActivity;
import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CustomThemeOptionsBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
+import ml.docilealligator.infinityforreddit.databinding.ItemUserCustomThemeBinding;
public class OnlineCustomThemeListingRecyclerViewAdapter extends PagingDataAdapter<CustomTheme, RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_USER_THEME = 1;
@@ -56,7 +54,7 @@ public class OnlineCustomThemeListingRecyclerViewAdapter extends PagingDataAdapt
case VIEW_TYPE_USER_THEME_DIVIDER:
return new OnlineCustomThemeDividerViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_theme_type_divider, parent, false));
default:
- return new OnlineCustomThemeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_user_custom_theme, parent, false));
+ return new OnlineCustomThemeViewHolder(ItemUserCustomThemeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
}
@@ -64,15 +62,15 @@ public class OnlineCustomThemeListingRecyclerViewAdapter extends PagingDataAdapt
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof OnlineCustomThemeViewHolder) {
CustomTheme customTheme = getItem(position);
- ((OnlineCustomThemeViewHolder) holder).colorPrimaryView.setBackgroundTintList(ColorStateList.valueOf(customTheme.colorPrimary));
- ((OnlineCustomThemeViewHolder) holder).nameTextView.setText(customTheme.name);
- ((OnlineCustomThemeViewHolder) holder).createThemeImageView.setOnClickListener(view -> {
+ ((OnlineCustomThemeViewHolder) holder).binding.colorPrimaryItemUserCustomTheme.setBackgroundTintList(ColorStateList.valueOf(customTheme.colorPrimary));
+ ((OnlineCustomThemeViewHolder) holder).binding.nameTextViewItemUserCustomTheme.setText(customTheme.name);
+ ((OnlineCustomThemeViewHolder) holder).binding.addImageViewItemUserCustomTheme.setOnClickListener(view -> {
Intent intent = new Intent(activity, CustomizeThemeActivity.class);
intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, customTheme.name);
intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true);
activity.startActivity(intent);
});
- ((OnlineCustomThemeViewHolder) holder).shareImageView.setOnClickListener(view -> {
+ ((OnlineCustomThemeViewHolder) holder).binding.shareImageViewItemUserCustomTheme.setOnClickListener(view -> {
((CustomThemeListingActivity) activity).shareTheme(customTheme);
});
holder.itemView.setOnClickListener(view -> {
@@ -90,21 +88,13 @@ public class OnlineCustomThemeListingRecyclerViewAdapter extends PagingDataAdapt
}
class OnlineCustomThemeViewHolder extends RecyclerView.ViewHolder {
+ ItemUserCustomThemeBinding binding;
- @BindView(R.id.color_primary_item_user_custom_theme)
- View colorPrimaryView;
- @BindView(R.id.name_text_view_item_user_custom_theme)
- TextView nameTextView;
- @BindView(R.id.add_image_view_item_user_custom_theme)
- ImageView createThemeImageView;
- @BindView(R.id.share_image_view_item_user_custom_theme)
- ImageView shareImageView;
-
- OnlineCustomThemeViewHolder(@NonNull View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ OnlineCustomThemeViewHolder(@NonNull ItemUserCustomThemeBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
if (activity.typeface != null) {
- nameTextView.setTypeface(activity.typeface);
+ binding.nameTextViewItemUserCustomTheme.setTypeface(activity.typeface);
}
}
}