From 8a0d77b7be6d44752b05d9dda9e2a8deef5229fc Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Thu, 14 Sep 2023 23:08:15 -0400 Subject: Continue changing vote button icons. --- .../adapters/PostRecyclerViewAdapter.java | 1409 +++++++++----------- 1 file changed, 649 insertions(+), 760 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 700ae3c7..50f7ff3a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -93,6 +93,10 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed; import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2GalleryTypeBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2TextBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2VideoAutoplayBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2VideoAutoplayLegacyControllerBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2WithPreviewBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostCard3GalleryTypeBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostCard3TextBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostCard3VideoTypeAutoplayBinding; @@ -100,6 +104,10 @@ import ml.docilealligator.infinityforreddit.databinding.ItemPostCard3VideoTypeAu import ml.docilealligator.infinityforreddit.databinding.ItemPostCard3WithPreviewBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryGalleryTypeBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryTypeBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostTextBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostVideoTypeAutoplayBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostVideoTypeAutoplayLegacyControllerBinding; +import ml.docilealligator.infinityforreddit.databinding.ItemPostWithPreviewBinding; import ml.docilealligator.infinityforreddit.events.PostUpdateEventToPostDetailFragment; import ml.docilealligator.infinityforreddit.fragments.PostFragment; import ml.docilealligator.infinityforreddit.post.Post; @@ -527,15 +535,20 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter imageRequestBuilder = mGlide.load(url).listener(((PostWithPreviewTypeViewHolder) holder).glideRequestListener); if (blurImage) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) - .into(((PostWithPreviewTypeViewHolder) holder).imageView); + .into(((PostWithPreviewTypeViewHolder) holder).binding.imageViewItemPostWithPreview); } else { - imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostWithPreviewTypeViewHolder) holder).imageView); + imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostWithPreviewTypeViewHolder) holder).binding.imageViewItemPostWithPreview); } } } else if (holder instanceof PostCompactBaseViewHolder) { @@ -2136,9 +2152,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { int position = getBindingAdapterPosition(); @@ -2954,32 +2962,35 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter fetchGfycatOrStreamableVideoCall; private boolean isManuallyPaused; - PostVideoAutoplayViewHolder(View itemView) { - super(itemView); - ButterKnife.bind(this, itemView); + PostBaseVideoAutoplayViewHolder(View rootView, + AspectRatioGifImageView iconGifImageView, + TextView subredditTextView, + TextView userTextView, + ImageView stickiedPostImageView, + TextView postTimeTextView, + TextView titleTextView, + AspectRatioFrameLayout aspectRatioFrameLayout, + GifImageView previewImageView, + ImageView errorLoadingGfycatImageView, + PlayerView videoPlayer, + ImageView muteButton, + ImageView fullscreenButton, + ImageView pauseButton, + ImageView playButton, + DefaultTimeBar progressBar, + ConstraintLayout bottomConstraintLayout, + MaterialButtonToggleGroup voteButtonToggleGroup, + MaterialButton upvoteButton, + MaterialButton downvoteButton, + MaterialButton commentsCountButton, + MaterialButton saveButton, + MaterialButton shareButton) { + super(rootView); setBaseView( iconGifImageView, subredditTextView, @@ -3355,13 +3346,23 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { @@ -3584,104 +3585,104 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter glideRequestListener; - PostWithPreviewTypeViewHolder(View itemView) { - super(itemView); - ButterKnife.bind(this, itemView); + PostWithPreviewTypeViewHolder(@NonNull ItemPostWithPreviewBinding binding) { + super(binding.getRoot()); setBaseView( - iconGifImageView, - subredditTextView, - userTextView, - stickiedPostImageView, - postTimeTextView, - titleTextView, - typeTextView, - archivedImageView, - lockedImageView, - crosspostImageView, - nsfwTextView, - spoilerTextView, - flairTextView, - awardsTextView, - bottomConstraintLayout, - upvoteButton, - scoreTextView, - downvoteButton, - commentsCountTextView, - saveButton, - shareButton); + binding.iconGifImageViewItemPostWithPreview, + binding.subredditNameTextViewItemPostWithPreview, + binding.userTextViewItemPostWithPreview, + binding.stickiedPostImageViewItemPostWithPreview, + binding.postTimeTextViewItemPostWithPreview, + binding.titleTextViewItemPostWithPreview, + binding.typeTextViewItemPostWithPreview, + binding.archivedImageViewItemPostWithPreview, + binding.lockedImageViewItemPostWithPreview, + binding.crosspostImageViewItemPostWithPreview, + binding.nsfwTextViewItemPostWithPreview, + binding.spoilerCustomTextViewItemPostWithPreview, + binding.flairCustomTextViewItemPostWithPreview, + binding.awardsTextViewItemPostWithPreview, + binding.bottomConstraintLayoutItemPostWithPreview, + binding.voteButtonToggleItemPostWithPreview, + binding.upvoteButtonItemPostWithPreview, + binding.downvoteButtonItemPostWithPreview, + binding.commentsCountButtonItemPostWithPreview, + binding.saveButtonItemPostWithPreview, + binding.shareButtonItemPostWithPreview); if (mActivity.typeface != null) { - linkTextView.setTypeface(mActivity.typeface); - errorTextView.setTypeface(mActivity.typeface); + binding.linkTextViewItemPostWithPreview.setTypeface(mActivity.typeface); + binding.loadImageErrorTextViewItemPostWithPreview.setTypeface(mActivity.typeface); } - linkTextView.setTextColor(mSecondaryTextColor); - noPreviewLinkImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor); - noPreviewLinkImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN); - progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); - videoOrGifIndicatorImageView.setColorFilter(mMediaIndicatorIconTint, PorterDuff.Mode.SRC_IN); - videoOrGifIndicatorImageView.setBackgroundTintList(ColorStateList.valueOf(mMediaIndicatorBackgroundColor)); - errorTextView.setTextColor(mPrimaryTextColor); - - imageView.setOnClickListener(view -> { + binding.linkTextViewItemPostWithPreview.setTextColor(mSecondaryTextColor); + binding.imageViewNoPreviewGalleryItemPostWithPreview.setBackgroundColor(mNoPreviewPostTypeBackgroundColor); + binding.imageViewNoPreviewGalleryItemPostWithPreview.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN); + binding.progressBarItemPostWithPreview.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); + binding.videoOrGifIndicatorImageViewItemPostWithPreview.setColorFilter(mMediaIndicatorIconTint, PorterDuff.Mode.SRC_IN); + binding.videoOrGifIndicatorImageViewItemPostWithPreview.setBackgroundTintList(ColorStateList.valueOf(mMediaIndicatorBackgroundColor)); + binding.loadImageErrorTextViewItemPostWithPreview.setTextColor(mPrimaryTextColor); + + binding.imageViewItemPostWithPreview.setOnClickListener(view -> { int position = getBindingAdapterPosition(); if (position < 0) { return; @@ -3693,28 +3694,28 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { - progressBar.setVisibility(View.VISIBLE); - errorTextView.setVisibility(View.GONE); + binding.loadImageErrorTextViewItemPostWithPreview.setOnClickListener(view -> { + binding.progressBarItemPostWithPreview.setVisibility(View.VISIBLE); + binding.loadImageErrorTextViewItemPostWithPreview.setVisibility(View.GONE); loadImage(this); }); - noPreviewLinkImageView.setOnClickListener(view -> { - imageView.performClick(); + binding.imageViewNoPreviewGalleryItemPostWithPreview.setOnClickListener(view -> { + binding.imageViewItemPostWithPreview.performClick(); }); glideRequestListener = new RequestListener<>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - progressBar.setVisibility(View.GONE); - errorTextView.setVisibility(View.VISIBLE); + binding.progressBarItemPostWithPreview.setVisibility(View.GONE); + binding.loadImageErrorTextViewItemPostWithPreview.setVisibility(View.VISIBLE); return false; } @Override public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - errorTextView.setVisibility(View.GONE); - progressBar.setVisibility(View.GONE); + binding.loadImageErrorTextViewItemPostWithPreview.setVisibility(View.GONE); + binding.progressBarItemPostWithPreview.setVisibility(View.GONE); return false; } }; @@ -3750,12 +3751,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter fetchGfycatOrStreamableVideoCall; private boolean isManuallyPaused; - PostCard2VideoAutoplayViewHolder(View itemView) { + PostCard2BaseVideoAutoplayViewHolder(View itemView, + AspectRatioGifImageView iconGifImageView, + TextView subredditTextView, + TextView userTextView, + ImageView stickiedPostImageView, + TextView postTimeTextView, + TextView titleTextView, + AspectRatioFrameLayout aspectRatioFrameLayout, + GifImageView previewImageView, + ImageView errorLoadingGfycatImageView, + PlayerView videoPlayer, + ImageView muteButton, + ImageView fullscreenButton, + ImageView pauseButton, + ImageView playButton, + DefaultTimeBar progressBar, + ConstraintLayout bottomConstraintLayout, + MaterialButtonToggleGroup voteButtonToggleGroup, + MaterialButton upvoteButton, + MaterialButton downvoteButton, + MaterialButton commentsCountButton, + MaterialButton saveButton, + MaterialButton shareButton, + View divider) { super(itemView); - ButterKnife.bind(this, itemView); setBaseView( iconGifImageView, subredditTextView, @@ -5164,14 +5092,25 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter requestListener; - PostCard2WithPreviewViewHolder(@NonNull View itemView) { - super(itemView); - ButterKnife.bind(this, itemView); + PostCard2WithPreviewViewHolder(@NonNull ItemPostCard2WithPreviewBinding binding) { + super(binding.getRoot()); setBaseView( - iconGifImageView, - subredditTextView, - userTextView, - stickiedPostImageView, - postTimeTextView, - titleTextView, - typeTextView, - archivedImageView, - lockedImageView, - crosspostImageView, - nsfwTextView, - spoilerTextView, - flairTextView, - awardsTextView, - bottomConstraintLayout, - upvoteButton, - scoreTextView, - downvoteButton, - commentsCountTextView, - saveButton, - shareButton, + binding.iconGifImageViewItemPostCard2WithPreview, + binding.subredditNameTextViewItemPostCard2WithPreview, + binding.userTextViewItemPostCard2WithPreview, + binding.stickiedPostImageViewItemPostCard2WithPreview, + binding.postTimeTextViewItemPostCard2WithPreview, + binding.titleTextViewItemPostCard2WithPreview, + binding.typeTextViewItemPostCard2WithPreview, + binding.archivedImageViewItemPostCard2WithPreview, + binding.lockedImageViewItemPostCard2WithPreview, + binding.crosspostImageViewItemPostCard2WithPreview, + binding.nsfwTextViewItemPostCard2WithPreview, + binding.spoilerCustomTextViewItemPostCard2WithPreview, + binding.flairCustomTextViewItemPostCard2WithPreview, + binding.awardsTextViewItemPostCard2WithPreview, + binding.bottomConstraintLayoutItemPostCard2WithPreview, + binding.voteButtonToggleItemPostCard2WithPreview, + binding.upvoteButtonItemPostCard2WithPreview, + binding.downvoteButtonItemPostCard2WithPreview, + binding.commentsCountButtonItemPostCard2WithPreview, + binding.saveButtonItemPostCard2WithPreview, + binding.shareButtonItemPostCard2WithPreview, true); if (mActivity.typeface != null) { - linkTextView.setTypeface(mActivity.typeface); - errorTextView.setTypeface(mActivity.typeface); + binding.linkTextViewItemPostCard2WithPreview.setTypeface(mActivity.typeface); + binding.loadImageErrorTextViewItemPostCard2WithPreview.setTypeface(mActivity.typeface); } - linkTextView.setTextColor(mSecondaryTextColor); - noPreviewImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor); - noPreviewImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN); - progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); - videoOrGifIndicatorImageView.setColorFilter(mMediaIndicatorIconTint, PorterDuff.Mode.SRC_IN); - videoOrGifIndicatorImageView.setBackgroundTintList(ColorStateList.valueOf(mMediaIndicatorBackgroundColor)); - errorTextView.setTextColor(mPrimaryTextColor); - divider.setBackgroundColor(mDividerColor); - - imageView.setOnClickListener(view -> { + binding.linkTextViewItemPostCard2WithPreview.setTextColor(mSecondaryTextColor); + binding.imageViewNoPreviewGalleryItemPostCard2WithPreview.setBackgroundColor(mNoPreviewPostTypeBackgroundColor); + binding.imageViewNoPreviewGalleryItemPostCard2WithPreview.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN); + binding.progressBarItemPostCard2WithPreview.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); + binding.videoOrGifIndicatorImageViewItemPostCard2WithPreview.setColorFilter(mMediaIndicatorIconTint, PorterDuff.Mode.SRC_IN); + binding.videoOrGifIndicatorImageViewItemPostCard2WithPreview.setBackgroundTintList(ColorStateList.valueOf(mMediaIndicatorBackgroundColor)); + binding.loadImageErrorTextViewItemPostCard2WithPreview.setTextColor(mPrimaryTextColor); + binding.dividerItemPostCard2WithPreview.setBackgroundColor(mDividerColor); + + binding.imageViewItemPostCard2WithPreview.setOnClickListener(view -> { int position = getBindingAdapterPosition(); if (position < 0) { return; @@ -5504,28 +5445,28 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { - progressBar.setVisibility(View.VISIBLE); - errorTextView.setVisibility(View.GONE); + binding.loadImageErrorTextViewItemPostCard2WithPreview.setOnClickListener(view -> { + binding.progressBarItemPostCard2WithPreview.setVisibility(View.VISIBLE); + binding.loadImageErrorTextViewItemPostCard2WithPreview.setVisibility(View.GONE); loadImage(this); }); - noPreviewImageView.setOnClickListener(view -> { - imageView.performClick(); + binding.imageViewNoPreviewGalleryItemPostCard2WithPreview.setOnClickListener(view -> { + binding.imageViewItemPostCard2WithPreview.performClick(); }); requestListener = new RequestListener<>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - progressBar.setVisibility(View.GONE); - errorTextView.setVisibility(View.VISIBLE); + binding.progressBarItemPostCard2WithPreview.setVisibility(View.GONE); + binding.loadImageErrorTextViewItemPostCard2WithPreview.setVisibility(View.VISIBLE); return false; } @Override public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - errorTextView.setVisibility(View.GONE); - progressBar.setVisibility(View.GONE); + binding.loadImageErrorTextViewItemPostCard2WithPreview.setVisibility(View.GONE); + binding.progressBarItemPostCard2WithPreview.setVisibility(View.GONE); return false; } }; @@ -5555,10 +5496,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter