diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-11-06 06:50:36 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-11-06 06:50:36 +0000 |
commit | 0201a661b2459ff4d93ba6a707f14ab39e2806e0 (patch) | |
tree | 81e561f98b48a1e01fdcc928545479f185ff179f | |
parent | 50f5612a1451391d490bc3f8223619220c3a060c (diff) | |
download | infinity-for-reddit-0201a661b2459ff4d93ba6a707f14ab39e2806e0.tar infinity-for-reddit-0201a661b2459ff4d93ba6a707f14ab39e2806e0.tar.gz infinity-for-reddit-0201a661b2459ff4d93ba6a707f14ab39e2806e0.tar.bz2 infinity-for-reddit-0201a661b2459ff4d93ba6a707f14ab39e2806e0.tar.lz infinity-for-reddit-0201a661b2459ff4d93ba6a707f14ab39e2806e0.tar.xz infinity-for-reddit-0201a661b2459ff4d93ba6a707f14ab39e2806e0.tar.zst infinity-for-reddit-0201a661b2459ff4d93ba6a707f14ab39e2806e0.zip |
Fix image preview not available. Fix gif autoplay.
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java | 12 | ||||
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java | 10 |
2 files changed, 20 insertions, 2 deletions
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<Post, RecyclerView ((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE); ((PostWithPreviewTypeViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.video)); } else if (post.getPostType() == Post.GIF_TYPE) { - ((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE); + if (!mAutoplay) { + ((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE); + } ((PostWithPreviewTypeViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.gif)); } else if (post.getPostType() == Post.IMAGE_TYPE) { ((PostWithPreviewTypeViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.image)); @@ -964,7 +966,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView private void loadImage(final RecyclerView.ViewHolder holder, final Post post, @NonNull Post.Preview preview) { if (preview != null) { if (holder instanceof PostWithPreviewTypeViewHolder) { - RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl()).listener(new RequestListener<Drawable>() { + String url; + if (post.getPostType() == Post.GIF_TYPE && mAutoplay) { + url = post.getUrl(); + } else { + url = preview.getPreviewUrl(); + } + RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(new RequestListener<Drawable>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> 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 |