Skip to content

Commit

Permalink
Improved giphy gifs using the preview if it is available
Browse files Browse the repository at this point in the history
  • Loading branch information
edgan committed Dec 20, 2024
1 parent d39492a commit d7673d8
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,40 @@ public void doImageAndText(final Submission submission, boolean full, String bas
thumbUsed = true;
}
loadedUrl = submission.getUrl();
} else if (type == ContentType.Type.GIF) {
JsonNode dataNode = submission.getDataNode();

url = submission.getUrl();
String redditPreviewUrl = null;

// Check for preview data
if (dataNode.has("preview")) {
JsonNode previewNode = dataNode.get("preview").get("images");
if (previewNode != null && previewNode.size() > 0) {
JsonNode sourceNode = previewNode.get(0).get("source");
if (sourceNode != null && sourceNode.has("url")) {
redditPreviewUrl = sourceNode.get("url").asText();
}
}
}

// Use Reddit preview URL if available
if (redditPreviewUrl != null) {
url = redditPreviewUrl;
}

// Load the URL
if (!full && !SettingValues.isPicsEnabled(baseSub)) {
thumbImage2.setVisibility(View.VISIBLE);
((Reddit) getContext().getApplicationContext()).getImageLoader()
.displayImage(url, thumbImage2);
setVisibility(View.GONE);
} else {
backdrop.setVisibility(View.VISIBLE);
((Reddit) getContext().getApplicationContext()).getImageLoader()
.displayImage(url, backdrop);
setVisibility(View.VISIBLE);
}
} else if (type == ContentType.Type.REDDIT_GALLERY) {
JsonNode dataNode = submission.getDataNode();

Expand Down

0 comments on commit d7673d8

Please sign in to comment.