diff options
Diffstat (limited to '')
-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"; } |