Maybe fix nsfw gif cannot be blurred in PostRecyclerViewAdapter.

This commit is contained in:
Alex Ning 2021-07-21 19:34:01 +08:00
parent 8415ace96a
commit b36a99da6d

View File

@ -1523,7 +1523,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private void loadImage(final RecyclerView.ViewHolder holder, final Post post, @NonNull Post.Preview preview) { private void loadImage(final RecyclerView.ViewHolder holder, final Post post, @NonNull Post.Preview preview) {
if (holder instanceof PostWithPreviewTypeViewHolder) { if (holder instanceof PostWithPreviewTypeViewHolder) {
String url; String url;
if (post.getPostType() == Post.GIF_TYPE && mAutoplay) { boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
url = post.getUrl(); url = post.getUrl();
} else { } else {
url = preview.getPreviewUrl(); url = preview.getPreviewUrl();
@ -1549,7 +1550,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
}); });
if ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler) { if (blurImage) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostWithPreviewTypeViewHolder) holder).imageView); .into(((PostWithPreviewTypeViewHolder) holder).imageView);
} else { } else {
@ -1592,7 +1593,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
} else if (holder instanceof PostGalleryViewHolder) { } else if (holder instanceof PostGalleryViewHolder) {
String url; String url;
if (post.getPostType() == Post.GIF_TYPE && mAutoplay) { boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
url = post.getUrl(); url = post.getUrl();
} else { } else {
url = preview.getPreviewUrl(); url = preview.getPreviewUrl();
@ -1618,7 +1620,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
}); });
if ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler) { if (blurImage) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostGalleryViewHolder) holder).imageView); .into(((PostGalleryViewHolder) holder).imageView);
} else { } else {
@ -1630,7 +1632,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
} else if (holder instanceof PostCard2WithPreviewViewHolder) { } else if (holder instanceof PostCard2WithPreviewViewHolder) {
String url; String url;
if (post.getPostType() == Post.GIF_TYPE && mAutoplay) { boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
url = post.getUrl(); url = post.getUrl();
} else { } else {
url = preview.getPreviewUrl(); url = preview.getPreviewUrl();
@ -1656,7 +1659,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
}); });
if ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler) { if (blurImage) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostCard2WithPreviewViewHolder) holder).imageView); .into(((PostCard2WithPreviewViewHolder) holder).imageView);
} else { } else {