diff options
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java index aa053f4f..5f56faca 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java @@ -131,18 +131,16 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima RequestBuilder<Drawable> imageRequestBuilder; if (dataSavingMode) { - if (disableImagePreview || (node.mediaMetadata.isGIF && !canShowGif) || (!node.mediaMetadata.isGIF && !canShowImage)) { - holder.binding.imageWrapperRelativeLayoutMarkdownImageAndGifBlock.setVisibility(View.GONE); - holder.binding.captionTextViewMarkdownImageAndGifBlock.setVisibility(View.VISIBLE); - holder.binding.captionTextViewMarkdownImageAndGifBlock.setGravity(Gravity.NO_GRAVITY); - SpannableString spannableString = new SpannableString(node.mediaMetadata.caption == null ? node.mediaMetadata.original.url : node.mediaMetadata.caption); - spannableString.setSpan(new URLSpan(node.mediaMetadata.original.url), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - holder.binding.captionTextViewMarkdownImageAndGifBlock.setText(spannableString); + if (disableImagePreview) { + showImageAsUrl(holder, node); return; } else { imageRequestBuilder = glide.load(node.mediaMetadata.downscaled.url).listener(holder.requestListener); holder.binding.imageViewMarkdownImageAndGifBlock.setRatio((float) node.mediaMetadata.downscaled.y / node.mediaMetadata.downscaled.x); } + } else if ((node.mediaMetadata.isGIF && !canShowGif) || (!node.mediaMetadata.isGIF && !canShowImage)) { + showImageAsUrl(holder, node); + return; } else { imageRequestBuilder = glide.load(node.mediaMetadata.original.url).listener(holder.requestListener); holder.binding.imageViewMarkdownImageAndGifBlock.setRatio((float) node.mediaMetadata.original.y / node.mediaMetadata.original.x); @@ -171,6 +169,15 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima } } + private void showImageAsUrl(@NonNull Holder holder, @NonNull ImageAndGifBlock node) { + holder.binding.imageWrapperRelativeLayoutMarkdownImageAndGifBlock.setVisibility(View.GONE); + holder.binding.captionTextViewMarkdownImageAndGifBlock.setVisibility(View.VISIBLE); + holder.binding.captionTextViewMarkdownImageAndGifBlock.setGravity(Gravity.NO_GRAVITY); + SpannableString spannableString = new SpannableString(node.mediaMetadata.caption == null ? node.mediaMetadata.original.url : node.mediaMetadata.caption); + spannableString.setSpan(new URLSpan(node.mediaMetadata.original.url), 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + holder.binding.captionTextViewMarkdownImageAndGifBlock.setText(spannableString); + } + @Override public void onViewRecycled(@NonNull Holder holder) { super.onViewRecycled(holder); |