aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-04-27 10:06:40 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-04-27 10:06:40 +0000
commit0921d377597f23ed49c18945bb3021cc82675937 (patch)
treedf19e1fb6a6a67a5502dcf18537b387a68871a01 /app/src/main/java/ml/docilealligator
parent8d4e2fb149911e67cf5cbf38cacbb4c54f5b6fd3 (diff)
downloadinfinity-for-reddit-0921d377597f23ed49c18945bb3021cc82675937.tar
infinity-for-reddit-0921d377597f23ed49c18945bb3021cc82675937.tar.gz
infinity-for-reddit-0921d377597f23ed49c18945bb3021cc82675937.tar.bz2
infinity-for-reddit-0921d377597f23ed49c18945bb3021cc82675937.tar.lz
infinity-for-reddit-0921d377597f23ed49c18945bb3021cc82675937.tar.xz
infinity-for-reddit-0921d377597f23ed49c18945bb3021cc82675937.tar.zst
infinity-for-reddit-0921d377597f23ed49c18945bb3021cc82675937.zip
Support Reddit emote inline gif.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java11
1 files changed, 11 insertions, 0 deletions
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 4cea425b..4378bb9c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
@@ -10,6 +10,7 @@ import android.net.NetworkInfo;
import android.os.Build;
import android.text.Spannable;
import android.util.DisplayMetrics;
+import android.util.Log;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;
@@ -96,6 +97,7 @@ public class Utils {
}
public static String parseInlineGifInComments(String markdown) {
+ Log.i("asdfsdf", "s " + markdown);
StringBuilder markdownStringBuilder = new StringBuilder(markdown);
Pattern inlineGifPattern = Pattern.compile("!\\[gif]\\(giphy\\|\\w+\\)");
Matcher matcher = inlineGifPattern.matcher(markdownStringBuilder);
@@ -109,6 +111,15 @@ public class Utils {
markdownStringBuilder.replace(matcher2.start(), matcher2.end(), "[gif](https://media3.giphy.com/media/" + markdownStringBuilder.substring(matcher2.start() + "![gif](giphy|".length(), matcher2.end() - "|downsized\\)".length()) + "/giphy.mp4)");
}
+ Pattern inlineGifPattern3 = Pattern.compile("!\\[gif]\\(emote\\|\\w+\\|\\w+\\)");
+ Matcher matcher3 = inlineGifPattern3.matcher(markdownStringBuilder);
+ while (matcher3.find()) {
+ markdownStringBuilder.replace(matcher3.start(), matcher3.end(),
+ "[gif](https://reddit-meta-production.s3.amazonaws.com/public/fortnitebr/emotes/snoomoji_emotes/"
+ + markdownStringBuilder.substring(
+ matcher3.start() + "![gif](emote|".length(), matcher3.end() - 1).replace('|', '/') + ".gif)");
+ }
+
return markdownStringBuilder.toString();
}