From 329bc51f9066353b13c7e3e43833ce7ca8fa99b8 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Sat, 5 Feb 2022 08:56:24 +0100 Subject: [PATCH] fix apng emojis not rendered when animation is turned off (#2312) --- .../java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt index 2aee7384b..df7b4d9f8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/CustomEmojiHelper.kt @@ -33,7 +33,7 @@ import java.util.regex.Pattern /** * replaces emoji shortcodes in a text with EmojiSpans - * @param text the text containing custom emojis + * @receiver the text containing custom emojis * @param emojis a list of the custom emojis (nullable for backward compatibility with old mastodon instances) * @param view a reference to the a view the emojis will be shown in (should be the TextView, but parents of the TextView are also acceptable) * @return the text with the shortcodes replaced by EmojiSpans @@ -44,7 +44,7 @@ fun CharSequence.emojify(emojis: List?, view: View, animate: Boolean): Ch val builder = SpannableStringBuilder.valueOf(this) - emojis.forEach { (shortcode, url) -> + emojis.forEach { (shortcode, url, staticUrl) -> val matcher = Pattern.compile(":$shortcode:", Pattern.LITERAL) .matcher(this) @@ -54,7 +54,7 @@ fun CharSequence.emojify(emojis: List?, view: View, animate: Boolean): Ch builder.setSpan(span, matcher.start(), matcher.end(), 0) Glide.with(view) .asDrawable() - .load(url) + .load(if (animate) { url } else { staticUrl }) .into(span.getTarget(animate)) } }