aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Kozelko <KozelkoS@yandex.ru>2022-08-05 00:22:35 +0000
committerGitHub <noreply@github.com>2022-08-05 00:22:35 +0000
commit8db3736dd48d0ad4e9d70096902d446a0d04a87e (patch)
tree17dda150da3c2200fd28f9c50d287e2e9271c509
parent3c0e2ab2d6cea83f4423360da9b8713cf4fe3b5a (diff)
downloadinfinity-for-reddit-8db3736dd48d0ad4e9d70096902d446a0d04a87e.tar
infinity-for-reddit-8db3736dd48d0ad4e9d70096902d446a0d04a87e.tar.gz
infinity-for-reddit-8db3736dd48d0ad4e9d70096902d446a0d04a87e.tar.bz2
infinity-for-reddit-8db3736dd48d0ad4e9d70096902d446a0d04a87e.tar.lz
infinity-for-reddit-8db3736dd48d0ad4e9d70096902d446a0d04a87e.tar.xz
infinity-for-reddit-8db3736dd48d0ad4e9d70096902d446a0d04a87e.tar.zst
infinity-for-reddit-8db3736dd48d0ad4e9d70096902d446a0d04a87e.zip
Fix loading previews after quick scroll (#861)
* Request layout on ratio change * Change imageView visibility on bind/recycle to force layout change
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java7
2 files changed, 8 insertions, 1 deletions
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 8bf9d801..a50fd29b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -812,6 +812,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostWithPreviewTypeViewHolder) holder).preview = preview;
if (preview != null) {
+ ((PostWithPreviewTypeViewHolder) holder).imageView.setVisibility(View.VISIBLE);
((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.VISIBLE);
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
@@ -1847,6 +1848,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.GONE);
} else if (holder instanceof PostWithPreviewTypeViewHolder) {
mGlide.clear(((PostWithPreviewTypeViewHolder) holder).imageView);
+ ((PostWithPreviewTypeViewHolder) holder).imageView.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).errorTextView.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.GONE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java
index ff7df783..6e6c1059 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/AspectRatioGifImageView.java
@@ -25,7 +25,12 @@ public class AspectRatioGifImageView extends GifImageView {
}
public final void setRatio(float var1) {
- this.ratio = var1;
+ if (this.ratio != var1) {
+ this.ratio = var1;
+
+ requestLayout();
+ invalidate();
+ }
}
private void init(Context context, AttributeSet attrs) {