diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2023-11-25 05:03:11 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2023-11-25 05:03:11 +0000 |
commit | c8e527d326e4e64b373d363e8f6032de6f73ae4c (patch) | |
tree | 33859b043414ed1664c9a8d6931069afeee254f7 /app/src/main/java/ml/docilealligator | |
parent | d0430e6842af66a30786200714e32f9125e67127 (diff) | |
download | infinity-for-reddit-c8e527d326e4e64b373d363e8f6032de6f73ae4c.tar infinity-for-reddit-c8e527d326e4e64b373d363e8f6032de6f73ae4c.tar.gz infinity-for-reddit-c8e527d326e4e64b373d363e8f6032de6f73ae4c.tar.bz2 infinity-for-reddit-c8e527d326e4e64b373d363e8f6032de6f73ae4c.tar.lz infinity-for-reddit-c8e527d326e4e64b373d363e8f6032de6f73ae4c.tar.xz infinity-for-reddit-c8e527d326e4e64b373d363e8f6032de6f73ae4c.tar.zst infinity-for-reddit-c8e527d326e4e64b373d363e8f6032de6f73ae4c.zip |
Layout tweaks in ImageAndGifEntry.
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java | 29 |
1 files changed, 27 insertions, 2 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 77e470cd..86287cc0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java @@ -3,9 +3,11 @@ package ml.docilealligator.infinityforreddit.markdown; import android.content.SharedPreferences; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.FrameLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -13,7 +15,9 @@ import androidx.annotation.Nullable; import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.RequestManager; import com.bumptech.glide.load.DataSource; +import com.bumptech.glide.load.MultiTransformation; import com.bumptech.glide.load.engine.GlideException; +import com.bumptech.glide.load.resource.bitmap.CenterInside; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.Target; @@ -21,6 +25,7 @@ import com.bumptech.glide.request.target.Target; import io.noties.markwon.Markwon; import io.noties.markwon.recycler.MarkwonAdapter; import jp.wasabeef.glide.transformations.BlurTransformation; +import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import ml.docilealligator.infinityforreddit.MediaMetadata; import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy; import ml.docilealligator.infinityforreddit.activities.BaseActivity; @@ -83,6 +88,11 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima ViewGroup.LayoutParams params = holder.binding.imageViewMarkdownImageAndGifBlock.getLayoutParams(); params.width = (int) Utils.convertDpToPixel(160, baseActivity); holder.binding.imageViewMarkdownImageAndGifBlock.setLayoutParams(params); + + FrameLayout.LayoutParams progressBarParams = (FrameLayout.LayoutParams) holder.binding.progressBarMarkdownImageAndGifBlock.getLayoutParams(); + progressBarParams.gravity = Gravity.CENTER_VERTICAL; + progressBarParams.leftMargin = (int) Utils.convertDpToPixel(56, baseActivity); + holder.binding.progressBarMarkdownImageAndGifBlock.setLayoutParams(progressBarParams); } RequestBuilder<Drawable> imageRequestBuilder; @@ -95,10 +105,20 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima } if (blurImage && !node.mediaMetadata.isGIF) { - imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) + imageRequestBuilder + .apply(RequestOptions.bitmapTransform( + new MultiTransformation<>( + new BlurTransformation(50, 10), + new RoundedCornersTransformation(72, 0)))) .into(holder.binding.imageViewMarkdownImageAndGifBlock); } else { - imageRequestBuilder.centerInside().downsample(saveMemoryCenterInsideDownsampleStrategy).into(holder.binding.imageViewMarkdownImageAndGifBlock); + imageRequestBuilder + .apply(RequestOptions.bitmapTransform( + new MultiTransformation<>( + new CenterInside(), + new RoundedCornersTransformation(16, 0)))) + .downsample(saveMemoryCenterInsideDownsampleStrategy) + .into(holder.binding.imageViewMarkdownImageAndGifBlock); } } @@ -109,6 +129,11 @@ public class ImageAndGifEntry extends MarkwonAdapter.Entry<ImageAndGifBlock, Ima params.width = ViewGroup.LayoutParams.MATCH_PARENT; holder.binding.imageViewMarkdownImageAndGifBlock.setLayoutParams(params); + FrameLayout.LayoutParams progressBarParams = (FrameLayout.LayoutParams) holder.binding.progressBarMarkdownImageAndGifBlock.getLayoutParams(); + progressBarParams.gravity = Gravity.CENTER; + progressBarParams.leftMargin = (int) Utils.convertDpToPixel(8, baseActivity); + holder.binding.progressBarMarkdownImageAndGifBlock.setLayoutParams(progressBarParams); + glide.clear(holder.binding.imageViewMarkdownImageAndGifBlock); holder.binding.progressBarMarkdownImageAndGifBlock.setVisibility(View.GONE); holder.binding.loadImageErrorTextViewMarkdownImageAndGifBlock.setVisibility(View.GONE); |