From 0201a661b2459ff4d93ba6a707f14ab39e2806e0 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 6 Nov 2020 14:50:36 +0800 Subject: Fix image preview not available. Fix gif autoplay. --- .../infinityforreddit/Adapter/PostRecyclerViewAdapter.java | 12 ++++++++++-- .../ml/docilealligator/infinityforreddit/Post/ParsePost.java | 10 ++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index 164b283e..ac223d3d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -612,7 +612,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter imageRequestBuilder = mGlide.load(preview.getPreviewUrl()).listener(new RequestListener() { + String url; + if (post.getPostType() == Post.GIF_TYPE && mAutoplay) { + url = post.getUrl(); + } else { + url = preview.getPreviewUrl(); + } + RequestBuilder imageRequestBuilder = mGlide.load(url).listener(new RequestListener() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { ((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java index 9f77fdda..64c1ad98 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java @@ -199,6 +199,9 @@ public class ParsePost { nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); + if (previews.isEmpty()) { + previews.add(new Post.Preview(url, 0, 0)); + } post.setPreviews(previews); } else { //No preview link post @@ -278,6 +281,9 @@ public class ParsePost { voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); + if (previews.isEmpty()) { + previews.add(new Post.Preview(url, 0, 0)); + } post.setPreviews(previews); } else if (url.endsWith("gif")){ //Gif post @@ -359,6 +365,10 @@ public class ParsePost { authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, postType, voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost); + + if (previews.isEmpty()) { + previews.add(new Post.Preview(url, 0, 0)); + } post.setPreviews(previews); } else if (url.endsWith("mp4")) { //Video post -- cgit v1.2.3