aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-11-25 05:03:11 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-11-25 05:03:11 +0000
commitc8e527d326e4e64b373d363e8f6032de6f73ae4c (patch)
tree33859b043414ed1664c9a8d6931069afeee254f7
parentd0430e6842af66a30786200714e32f9125e67127 (diff)
downloadinfinity-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.
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/ImageAndGifEntry.java29
-rw-r--r--app/src/main/res/layout/markdown_image_and_gif_block.xml8
2 files changed, 32 insertions, 5 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);
diff --git a/app/src/main/res/layout/markdown_image_and_gif_block.xml b/app/src/main/res/layout/markdown_image_and_gif_block.xml
index 95746933..264a80e8 100644
--- a/app/src/main/res/layout/markdown_image_and_gif_block.xml
+++ b/app/src/main/res/layout/markdown_image_and_gif_block.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/image_wrapper_relative_layout_markdown_image_and_gif_block"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="wrap_content"
+ android:padding="8dp">
<ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView
android:id="@+id/image_view_markdown_image_and_gif_block"
@@ -21,11 +23,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:drawableTop="@drawable/ic_error_outline_black_24dp"
android:fontFamily="?attr/font_family"
android:gravity="center"
android:text="@string/error_loading_image_tap_to_retry"
android:textSize="?attr/font_default"
- android:visibility="gone" />
+ android:visibility="gone"
+ app:drawableTopCompat="@drawable/ic_error_outline_black_24dp" />
</FrameLayout> \ No newline at end of file