From d0430e6842af66a30786200714e32f9125e67127 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Fri, 24 Nov 2023 22:13:51 -0500 Subject: Remove some markdown processing related to inline gifs. Remove awards related stuff. --- .../activities/ViewPostDetailActivity.java | 9 --- .../CommentsListingRecyclerViewAdapter.java | 13 ----- .../adapters/CommentsRecyclerViewAdapter.java | 24 -------- .../infinityforreddit/comment/Comment.java | 14 +---- .../infinityforreddit/comment/ParseComment.java | 23 +------- .../fragments/ViewPostDetailFragment.java | 6 -- .../infinityforreddit/post/ParsePost.java | 55 +++++++----------- .../infinityforreddit/post/Post.java | 4 +- .../infinityforreddit/utils/JSONUtils.java | 1 - .../utils/SharedPreferencesUtils.java | 2 +- .../infinityforreddit/utils/Utils.java | 65 ---------------------- 11 files changed, 25 insertions(+), 191 deletions(-) (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java index e88f9e22..bd2d6ed4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java @@ -421,15 +421,6 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele } } - private void awardGiven(String awardsHTML, int awardCount, int position) { - if (sectionsPagerAdapter != null) { - ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment(); - if (fragment != null) { - fragment.awardGiven(awardsHTML, awardCount, position); - } - } - } - public void deleteComment(String fullName, int position) { if (sectionsPagerAdapter != null) { ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java index d947a370..f9a445dd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java @@ -240,11 +240,6 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter mediaMetadataMap) { this.id = id; this.fullName = fullName; @@ -87,7 +86,6 @@ public class Comment implements Parcelable { this.isSubmitter = isSubmitter; this.distinguished = distinguished; this.permalink = APIUtils.API_BASE_URI + permalink; - this.awards = awards; this.depth = depth; this.collapsed = collapsed; this.hasReply = hasReply; @@ -136,7 +134,6 @@ public class Comment implements Parcelable { isSubmitter = in.readByte() != 0; distinguished = in.readString(); permalink = in.readString(); - awards = in.readString(); depth = in.readInt(); childCount = in.readInt(); collapsed = in.readByte() != 0; @@ -258,14 +255,6 @@ public class Comment implements Parcelable { return permalink; } - public String getAwards() { - return awards; - } - - public void addAwards(String newAwardsHTML) { - awards += newAwardsHTML; - } - public int getDepth() { return depth; } @@ -440,7 +429,6 @@ public class Comment implements Parcelable { parcel.writeByte((byte) (isSubmitter ? 1 : 0)); parcel.writeString(distinguished); parcel.writeString(permalink); - parcel.writeString(awards); parcel.writeInt(depth); parcel.writeInt(childCount); parcel.writeByte((byte) (collapsed ? 1 : 0)); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java index d08bebd1..e37bf304 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java @@ -272,31 +272,12 @@ public class ParseComment { String commentMarkdown = ""; if (!singleCommentData.isNull(JSONUtils.BODY_KEY)) { commentMarkdown = Utils.parseInlineRedditImages( - Utils.parseInlineGifInComments( Utils.modifyMarkdown( - Utils.trimTrailingWhitespace(singleCommentData.getString(JSONUtils.BODY_KEY))))); - if (!singleCommentData.isNull(JSONUtils.MEDIA_METADATA_KEY)) { - JSONObject mediaMetadataObject = singleCommentData.getJSONObject(JSONUtils.MEDIA_METADATA_KEY); - commentMarkdown = Utils.parseInlineEmotes(commentMarkdown, mediaMetadataObject); - } + Utils.trimTrailingWhitespace(singleCommentData.getString(JSONUtils.BODY_KEY)))); } String commentRawText = Utils.trimTrailingWhitespace( Html.fromHtml(singleCommentData.getString(JSONUtils.BODY_HTML_KEY))).toString(); String permalink = Html.fromHtml(singleCommentData.getString(JSONUtils.PERMALINK_KEY)).toString(); - StringBuilder awardingsBuilder = new StringBuilder(); - JSONArray awardingsArray = singleCommentData.getJSONArray(JSONUtils.ALL_AWARDINGS_KEY); - for (int i = 0; i < awardingsArray.length(); i++) { - JSONObject award = awardingsArray.getJSONObject(i); - int count = award.getInt(JSONUtils.COUNT_KEY); - JSONArray icons = award.getJSONArray(JSONUtils.RESIZED_ICONS_KEY); - if (icons.length() > 4) { - String iconUrl = icons.getJSONObject(3).getString(JSONUtils.URL_KEY); - awardingsBuilder.append(" ").append("x").append(count).append(" "); - } else if (icons.length() > 0) { - String iconUrl = icons.getJSONObject(icons.length() - 1).getString(JSONUtils.URL_KEY); - awardingsBuilder.append(" ").append("x").append(count).append(" "); - } - } int score = singleCommentData.getInt(JSONUtils.SCORE_KEY); int voteType; if (singleCommentData.isNull(JSONUtils.LIKES_KEY)) { @@ -324,7 +305,7 @@ public class ParseComment { return new Comment(id, fullName, author, authorFlair, authorFlairHTMLBuilder.toString(), linkAuthor, submitTime, commentMarkdown, commentRawText, linkId, subredditName, parentId, score, voteType, isSubmitter, distinguished, - permalink, awardingsBuilder.toString(), depth, collapsed, hasReply, scoreHidden, saved, edited, + permalink, depth, collapsed, hasReply, scoreHidden, saved, edited, mediaMetadataMap); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index 902bffca..1e1c32db 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -793,12 +793,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } } - public void awardGiven(String awardsHTML, int awardCount, int position) { - if (mCommentsAdapter != null) { - mCommentsAdapter.giveAward(awardsHTML, awardCount, position); - } - } - public void changeFlair(Flair flair) { Map params = new HashMap<>(); params.put(APIUtils.API_TYPE_KEY, APIUtils.API_TYPE_JSON); 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 81e95c0c..31a1f139 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -187,23 +187,6 @@ public class ParsePost { if (flair.equals("") && data.has(JSONUtils.LINK_FLAIR_TEXT_KEY) && !data.isNull(JSONUtils.LINK_FLAIR_TEXT_KEY)) { flair = data.getString(JSONUtils.LINK_FLAIR_TEXT_KEY); } - - StringBuilder awardingsBuilder = new StringBuilder(); - JSONArray awardingsArray = data.getJSONArray(JSONUtils.ALL_AWARDINGS_KEY); - int nAwards = 0; - for (int i = 0; i < awardingsArray.length(); i++) { - JSONObject award = awardingsArray.getJSONObject(i); - int count = award.getInt(JSONUtils.COUNT_KEY); - nAwards += count; - JSONArray icons = award.getJSONArray(JSONUtils.RESIZED_ICONS_KEY); - if (icons.length() > 4) { - String iconUrl = icons.getJSONObject(3).getString(JSONUtils.URL_KEY); - awardingsBuilder.append(" ").append("x").append(count).append(" "); - } else if (icons.length() > 0) { - String iconUrl = icons.getJSONObject(icons.length() - 1).getString(JSONUtils.URL_KEY); - awardingsBuilder.append(" ").append("x").append(count).append(" "); - } - } if (data.isNull(JSONUtils.LIKES_KEY)) { voteType = 0; @@ -242,7 +225,7 @@ public class ParsePost { Post post = parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTMLBuilder.toString(), postTime, title, previews, mediaMetadataMap, - score, voteType, nComments, upvoteRatio, flair, awardingsBuilder.toString(), nAwards, hidden, + score, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, deleted, removed, true, distinguished, suggestedSort); post.setCrosspostParentId(crosspostParent.getId()); @@ -251,7 +234,7 @@ public class ParsePost { return parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTMLBuilder.toString(), postTime, title, previews, mediaMetadataMap, - score, voteType, nComments, upvoteRatio, flair, awardingsBuilder.toString(), nAwards, hidden, + score, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, deleted, removed, false, distinguished, suggestedSort); } @@ -302,7 +285,7 @@ public class ParsePost { String authorFlair, String authorFlairHTML, long postTimeMillis, String title, ArrayList previews, Map mediaMetadataMap, int score, int voteType, int nComments, int upvoteRatio, String flair, - String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, + boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean deleted, boolean removed, boolean isCrosspost, String distinguished, String suggestedSort) throws JSONException { @@ -319,7 +302,7 @@ public class ParsePost { int postType = Post.TEXT_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, - voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, + voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); } else { if (path.endsWith(".jpg") || path.endsWith(".png") || path.endsWith(".jpeg")) { @@ -328,7 +311,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, + postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); if (previews.isEmpty()) { @@ -352,7 +335,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, - nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, + nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); post.setVideoUrl(videoUrl); @@ -362,7 +345,7 @@ public class ParsePost { int postType = Post.NO_PREVIEW_LINK_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, + postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { post.setSelfText(""); @@ -426,7 +409,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, - nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, + nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); post.setPreviews(previews); @@ -444,7 +427,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, - nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, + nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); post.setPreviews(previews); post.setVideoUrl(url); @@ -460,7 +443,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, postType, voteType, - nComments, upvoteRatio, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, + nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); post.setPreviews(previews); post.setVideoUrl(videoUrl); @@ -473,7 +456,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, + postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); @@ -493,7 +476,7 @@ public class ParsePost { int postType = Post.GIF_TYPE; post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, + postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); @@ -509,7 +492,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, + postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); post.setPreviews(previews); @@ -522,7 +505,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, + postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); post.setPreviews(previews); @@ -535,7 +518,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, + postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); @@ -547,7 +530,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, + postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); if (data.isNull(JSONUtils.SELFTEXT_KEY)) { @@ -591,7 +574,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, + postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); if (previews.isEmpty()) { @@ -611,7 +594,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, + postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); post.setPreviews(previews); post.setVideoUrl(url); @@ -622,7 +605,7 @@ public class ParsePost { post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, authorFlair, authorFlairHTML, postTimeMillis, title, url, permalink, score, - postType, voteType, nComments, upvoteRatio, flair, awards, nAwards, hidden, + postType, voteType, nComments, upvoteRatio, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost, distinguished, suggestedSort); //Need attention if (data.isNull(JSONUtils.SELFTEXT_KEY)) { 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 930f7225..bdf1ef27 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java @@ -79,7 +79,7 @@ public class Post implements Parcelable { 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, - int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler, + int upvoteRatio, String flair, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost, String distinguished, String suggestedSort) { this.id = id; @@ -115,7 +115,7 @@ public class Post implements Parcelable { public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author, String authorFlair, String authorFlairHTML, long postTimeMillis, String title, String url, String permalink, int score, int postType, int voteType, int nComments, - int upvoteRatio, String flair, String awards, int nAwards, boolean hidden, boolean spoiler, + int upvoteRatio, String flair, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost, String distinguished, String suggestedSort) { this.id = id; 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 c43608be..79182378 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/JSONUtils.java @@ -109,7 +109,6 @@ public class JSONUtils { public static final String IS_FAVORITED_KEY = "is_favorited"; public static final String SUBREDDITS_KEY = "subreddits"; public static final String PATH_KEY = "path"; - public static final String ALL_AWARDINGS_KEY = "all_awardings"; public static final String RESIZED_ICONS_KEY = "resized_icons"; public static final String GFY_ITEM_KEY = "gfyItem"; public static final String MP4_URL_KEY = "mp4Url"; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java index 684d9468..de2e72d4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -205,7 +205,6 @@ public class SharedPreferencesUtils { public static final String PINCH_TO_ZOOM_VIDEO = "pinch_to_zoom_video"; public static final String FIXED_HEIGHT_PREVIEW_IN_CARD = "fixed_height_preview_in_card"; public static final String HIDE_TEXT_POST_CONTENT = "hide_text_post_content"; - public static final String HIDE_COMMENT_AWARDS = "hide_comment_awards"; public static final String SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD = "show_fewer_toolbar_options_threshold"; public static final String SHOW_AUTHOR_AVATAR = "show_author_avatar"; public static final String ALWAYS_SHOW_CHILD_COMMENT_COUNT = "always_show_child_comment_count"; @@ -395,4 +394,5 @@ public class SharedPreferencesUtils { public static final String DO_NOT_SHOW_REDDIT_API_INFO_AGAIN_LEGACY = "do_not_show_reddit_api_info_again"; public static final String HIDE_THE_NUMBER_OF_AWARDS_LEGACY = "hide_the_number_of_awards"; + public static final String HIDE_COMMENT_AWARDS_LEGACY = "hide_comment_awards"; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java index d6b3ed6c..2fb4cfb0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java @@ -39,7 +39,6 @@ import com.google.android.material.tabs.TabLayout; import com.google.android.material.textfield.TextInputLayout; import org.json.JSONException; -import org.json.JSONObject; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; @@ -86,70 +85,6 @@ public final class Utils { return regexed; } - public static String parseInlineGifInComments(String markdown) { - /*StringBuilder markdownStringBuilder = new StringBuilder(markdown); - Pattern inlineGifPattern = REGEX_PATTERNS[3]; - Matcher matcher = inlineGifPattern.matcher(markdownStringBuilder); - while (matcher.find()) { - markdownStringBuilder.replace(matcher.start(), matcher.end(), "![gif](https://i.giphy.com/media/" + markdownStringBuilder.substring(matcher.start() + "![gif](giphy|".length(), matcher.end() - 1) + "/giphy.mp4)"); - matcher = inlineGifPattern.matcher(markdownStringBuilder); - } - - Pattern inlineGifPattern2 = REGEX_PATTERNS[4]; - Matcher matcher2 = inlineGifPattern2.matcher(markdownStringBuilder); - while (matcher2.find()) { - markdownStringBuilder.replace(matcher2.start(), matcher2.end(), "![gif](https://i.giphy.com/media/" + markdownStringBuilder.substring(matcher2.start() + "![gif](giphy|".length(), matcher2.end() - "|downsized\\)".length() + 1) + "/giphy.mp4)"); - matcher2 = inlineGifPattern2.matcher(markdownStringBuilder); - } - - Pattern inlineGifPattern3 = REGEX_PATTERNS[5]; - Matcher matcher3 = inlineGifPattern3.matcher(markdownStringBuilder); - while (matcher3.find()) { - markdownStringBuilder.replace(matcher3.start(), matcher3.end(), - "![emote](https://reddit-meta-production.s3.amazonaws.com/public/fortnitebr/emotes/snoomoji_emotes/" - + markdownStringBuilder.substring( - matcher3.start() + "![emote](emote|".length(), matcher3.end() - 1).replace('|', '/') + ".gif)"); - matcher3 = inlineGifPattern3.matcher(markdownStringBuilder); - } - - return markdownStringBuilder.toString();*/ - return markdown; - } - - public static String parseInlineEmotes(String markdown, JSONObject mediaMetadataObject) throws JSONException { - /*JSONArray mediaMetadataNames = mediaMetadataObject.names(); - if (mediaMetadataNames != null) { - for (int i = 0; i < mediaMetadataNames.length(); i++) { - if (!mediaMetadataNames.isNull(i)) { - String mediaMetadataKey = mediaMetadataNames.getString(i); - if (mediaMetadataObject.isNull(mediaMetadataKey)) { - continue; - } - JSONObject item = mediaMetadataObject.getJSONObject(mediaMetadataKey); - if (item.isNull(JSONUtils.STATUS_KEY) - || !item.getString(JSONUtils.STATUS_KEY).equals("valid") - || item.isNull(JSONUtils.ID_KEY) - || item.isNull(JSONUtils.T_KEY) - || item.isNull(JSONUtils.S_KEY)) { - continue; - } - String emote_type = item.getString(JSONUtils.T_KEY); - String emote_id = item.getString(JSONUtils.ID_KEY); - - JSONObject s_key = item.getJSONObject(JSONUtils.S_KEY); - if (s_key.isNull(JSONUtils.U_KEY)) { - continue; - } - String emote_url = s_key.getString(JSONUtils.U_KEY); - - markdown = markdown.replace("![img](" + emote_id + ")", "[" + emote_type + "](" + emote_url + ") "); - } - } - } - return markdown;*/ - return markdown; - } - public static String parseInlineRedditImages(String markdown) { StringBuilder markdownStringBuilder = new StringBuilder(markdown); Pattern inlineRedditImagePattern = REGEX_PATTERNS[6]; -- cgit v1.2.3