From dcf951e48e81dd03a7909fb1ddb404ca46a0d00c Mon Sep 17 00:00:00 2001 From: steckbrief Date: Mon, 14 Dec 2015 19:13:30 +0100 Subject: Fixes FS#88, Code cleanup --- .../java/github/ankushsachdeva/emojicon/EmojiconHandler.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libs') diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java index 81c6c393..5523314b 100644 --- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java +++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconHandler.java @@ -1406,6 +1406,7 @@ public final class EmojiconHandler { } public static final Map ANDROID_EMOTICONS = new HashMap(); + private static final Pattern TIME_AND_SCORING_PATTERN = Pattern.compile("[0-9]{1,3}:[0-9]{1,3}"); private static final Spannable.Factory spannableFactory = Spannable.Factory .getInstance(); @@ -1453,7 +1454,7 @@ public final class EmojiconHandler { falsePositives.add(Pair.create(webUrlMatcher.start(), webUrlMatcher.end())); } - Matcher timeAndScoringMatcher = Pattern.compile("[0-9]{1,3}:[0-9]{1,3}").matcher(spannable); + Matcher timeAndScoringMatcher = TIME_AND_SCORING_PATTERN.matcher(spannable); while (timeAndScoringMatcher.find()) { falsePositives.add(Pair.create(timeAndScoringMatcher.start(), timeAndScoringMatcher.end())); } @@ -1475,9 +1476,9 @@ public final class EmojiconHandler { } if (set) { // check that found emojicon is not in an web url or in a time or in a scoring - for (Pair webUrl : falsePositives) { - if ((matcher.start() >= webUrl.first && matcher.start() <= webUrl.second) - || (matcher.end() >= webUrl.first && matcher.end() <= webUrl.second)) { + for (Pair falsePositive : falsePositives) { + if ((matcher.start() >= falsePositive.first && matcher.start() <= falsePositive.second) + || (matcher.end() >= falsePositive.first && matcher.end() <= falsePositive.second)) { set = false; break; } -- cgit v1.2.3