From 3cae2b0dbadfcc109f8e7f52170722c664638d1f Mon Sep 17 00:00:00 2001 From: Docile-Alligator Date: Fri, 11 Mar 2022 17:00:23 +0800 Subject: Load image after the AspectRatioGifImageView's height is determined in PostRecyclerViewAdapter to prevent blurry images. --- .../adapters/PostRecyclerViewAdapter.java | 65 ++++++++++++++++++---- .../customviews/AspectRatioGifImageView.java | 21 ++++++- .../main/res/layout/item_post_detail_gallery.xml | 3 +- .../item_post_detail_image_and_gif_autoplay.xml | 3 +- app/src/main/res/layout/item_post_detail_link.xml | 3 +- .../item_post_detail_video_and_gif_preview.xml | 3 +- .../res/layout/item_post_detail_video_autoplay.xml | 1 - 7 files changed, 78 insertions(+), 21 deletions(-) (limited to 'app/src/main') 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 7c9814f0..d929aa0d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -15,7 +15,6 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.ViewTreeObserver; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; @@ -40,6 +39,7 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.RequestManager; import com.bumptech.glide.load.DataSource; +import com.bumptech.glide.load.DecodeFormat; import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; @@ -816,7 +816,13 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter imageRequestBuilder = mGlide.load(url).listener(((PostWithPreviewTypeViewHolder) holder).glideRequestListener); - + if (post.getAuthor().startsWith("GLIBG10")) { + Log.i("sssssaffd", "s " + url + " " + ((PostWithPreviewTypeViewHolder) holder).imageView.getRatio()); + } if (blurImage) { imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) .into(((PostWithPreviewTypeViewHolder) holder).imageView); } else { - imageRequestBuilder.downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostWithPreviewTypeViewHolder) holder).imageView); + imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostWithPreviewTypeViewHolder) holder).imageView); } } } else if (holder instanceof PostCompactBaseViewHolder) { @@ -1756,7 +1800,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter + android:adjustViewBounds="true" /> + android:adjustViewBounds="true" /> + android:adjustViewBounds="true" /> + android:adjustViewBounds="true" />