diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-07-17 16:22:07 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-07-17 16:22:07 +0000 |
commit | 39ae0d3aaf0eba042ca70e7fd67fcea0349af156 (patch) | |
tree | c2e0abfc0070bb82aeb81de134afee7fd1618329 /app/src/main/java/ml | |
parent | 09efd35b29060e9a56b1fd1ac9449b970adfdbf1 (diff) | |
download | infinity-for-reddit-39ae0d3aaf0eba042ca70e7fd67fcea0349af156.tar infinity-for-reddit-39ae0d3aaf0eba042ca70e7fd67fcea0349af156.tar.gz infinity-for-reddit-39ae0d3aaf0eba042ca70e7fd67fcea0349af156.tar.bz2 infinity-for-reddit-39ae0d3aaf0eba042ca70e7fd67fcea0349af156.tar.lz infinity-for-reddit-39ae0d3aaf0eba042ca70e7fd67fcea0349af156.tar.xz infinity-for-reddit-39ae0d3aaf0eba042ca70e7fd67fcea0349af156.tar.zst infinity-for-reddit-39ae0d3aaf0eba042ca70e7fd67fcea0349af156.zip |
Fix parsing Reddit gallery posts error when they contain a gif. Fix progress bar not showing in item_post_detail_gallery.
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java | 12 | ||||
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java | 1 |
2 files changed, 12 insertions, 1 deletions
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 17bb9bba..477cb697 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java @@ -398,7 +398,17 @@ public class ParsePost { String galleryId = galleryIdsArray.getJSONObject(i).getString(JSONUtils.MEDIA_ID_KEY); JSONObject singleGalleryObject = galleryObject.getJSONObject(galleryId); String mimeType = singleGalleryObject.getString(JSONUtils.M_KEY); - String galleryItemUrl = singleGalleryObject.getJSONObject(JSONUtils.S_KEY).getString(JSONUtils.U_KEY); + String galleryItemUrl; + if (mimeType.contains("jpg") || mimeType.contains("png")) { + galleryItemUrl = singleGalleryObject.getJSONObject(JSONUtils.S_KEY).getString(JSONUtils.U_KEY); + } else { + JSONObject sourceObject = singleGalleryObject.getJSONObject(JSONUtils.S_KEY); + if (mimeType.contains("gif")) { + galleryItemUrl = sourceObject.getString(JSONUtils.GIF_KEY); + } else { + galleryItemUrl = sourceObject.getString(JSONUtils.MP4_KEY); + } + } if ((previewUrl.equals("")) && mimeType.contains("jpg") || mimeType.contains("png")) { previewUrl = galleryItemUrl; post.setPreviewUrl(previewUrl); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java index 1c47eb2a..1d9c876f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java @@ -122,4 +122,5 @@ public class JSONUtils { public static final String X_KEY = "x"; public static final String Y_KEY = "y"; public static final String DEST_KEY = "dest"; + public static final String GIF_KEY = "gif"; } |