diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java index baf17d8f19..10a4a48cc6 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java @@ -275,8 +275,9 @@ public static ArrayList buildItems(BaseStatusListFragment boolean hasSpoiler=!TextUtils.isEmpty(statusForContent.spoilerText); if(!TextUtils.isEmpty(statusForContent.content)){ SpannableStringBuilder parsedText=HtmlParser.parse(statusForContent.content, statusForContent.emojis, statusForContent.mentions, statusForContent.tags, accountID, fragment.getContext()); - HtmlParser.applyFilterHighlights(fragment.getActivity(), parsedText, status.filtered); - TextStatusDisplayItem text=new TextStatusDisplayItem(parentID, HtmlParser.parse(statusForContent.content, statusForContent.emojis, statusForContent.mentions, statusForContent.tags, accountID, fragment.getContext()), fragment, statusForContent, (flags & FLAG_NO_TRANSLATE) != 0); + if(applyingFilter!=null) + HtmlParser.applyFilterHighlights(fragment.getActivity(), parsedText, status.filtered); + TextStatusDisplayItem text=new TextStatusDisplayItem(parentID, parsedText, fragment, statusForContent, (flags & FLAG_NO_TRANSLATE) != 0); contentItems.add(text); }else if(!hasSpoiler && header!=null){ header.needBottomPadding=true; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java b/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java index 0e468d653c..cc956906f4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java @@ -321,12 +321,11 @@ public static CharSequence parseLinks(String text){ } public static void applyFilterHighlights(Context context, SpannableStringBuilder text, List filters){ - if (filters == null) return; int fgColor=UiUtils.getThemeColor(context, R.attr.colorM3Error); int bgColor=UiUtils.getThemeColor(context, R.attr.colorM3ErrorContainer); for(FilterResult filter:filters){ if(!filter.filter.isActive()) - continue;; + continue; for(String word:filter.keywordMatches){ Matcher matcher=Pattern.compile("\\b"+Pattern.quote(word)+"\\b", Pattern.CASE_INSENSITIVE).matcher(text); while(matcher.find()){