From 66ce42081ca0b2b862abf9ddfc62778dd57bbd0f Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Fri, 3 Nov 2023 22:42:21 -0400 Subject: Not loading images from i.redgifs.com because they are webpages. --- .../infinityforreddit/post/ParsePost.java | 27 +++++++++++++++++++--- .../infinityforreddit/post/Post.java | 1 + 2 files changed, 25 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 d63c42d3..ffdc4328 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -284,7 +284,14 @@ public class ParsePost { spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); if (previews.isEmpty()) { - previews.add(new Post.Preview(url, 0, 0, "", "")); + if ("i.redgifs.com".equals(uri.getAuthority())) { + //No preview link (Not able to load redgifs image) + post.setPostType(Post.NO_PREVIEW_LINK_TYPE); + } else { + previews.add(new Post.Preview(url, 0, 0, "", "")); + } + } else if ("i.redgifs.com".equals(uri.getAuthority())) { + post.setUrl(previews.get(previews.size() - 1).getPreviewUrl()); } post.setPreviews(previews); } else { @@ -423,7 +430,14 @@ public class ParsePost { distinguished, suggestedSort); if (previews.isEmpty()) { - previews.add(new Post.Preview(url, 0, 0, "", "")); + if ("i.redgifs.com".equals(uri.getAuthority())) { + //No preview link (Not able to load redgifs image) + post.setPostType(Post.NO_PREVIEW_LINK_TYPE); + } else { + previews.add(new Post.Preview(url, 0, 0, "", "")); + } + } else if ("i.redgifs.com".equals(uri.getAuthority())) { + post.setUrl(previews.get(previews.size() - 1).getPreviewUrl()); } post.setPreviews(previews); } else if (path.endsWith(".gif")) { @@ -533,7 +547,14 @@ public class ParsePost { spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); if (previews.isEmpty()) { - previews.add(new Post.Preview(url, 0, 0, "", "")); + if ("i.redgifs.com".equals(uri.getAuthority())) { + //No preview link (Not able to load redgifs image) + post.setPostType(Post.NO_PREVIEW_LINK_TYPE); + } else { + previews.add(new Post.Preview(url, 0, 0, "", "")); + } + } else if ("i.redgifs.com".equals(uri.getAuthority())) { + post.setUrl(previews.get(previews.size() - 1).getPreviewUrl()); } post.setPreviews(previews); } else if (path.endsWith(".mp4")) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java index 90577a2c..0916775b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java @@ -82,6 +82,7 @@ public class Post implements Parcelable { private ArrayList previews = new ArrayList<>(); private ArrayList gallery = new ArrayList<>(); + //Text and video posts public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author, String authorFlair, String authorFlairHTML, long postTimeMillis, String title, String permalink, int score, int postType, int voteType, int nComments, -- cgit v1.2.3