aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/JSONUtils.java1
-rw-r--r--app/src/main/res/layout/item_post_detail_gallery.xml3
3 files changed, 13 insertions, 3 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";
}
diff --git a/app/src/main/res/layout/item_post_detail_gallery.xml b/app/src/main/res/layout/item_post_detail_gallery.xml
index 05f013a1..8d2a9ce2 100644
--- a/app/src/main/res/layout/item_post_detail_gallery.xml
+++ b/app/src/main/res/layout/item_post_detail_gallery.xml
@@ -212,8 +212,7 @@
android:id="@+id/load_wrapper_item_post_detail_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:visibility="gone">
+ android:layout_centerInParent="true">
<ProgressBar
android:id="@+id/progress_bar_item_post_detail_gallery"