From 110db39ff6011f95cdb2b78105f03e5f1d27e16f Mon Sep 17 00:00:00 2001 From: zerrium Date: Thu, 18 Mar 2021 11:32:50 +0700 Subject: [PATCH] Added FilterKeywords class (zerrium package) --- app/src/main/java/zerrium/FilterKeywords.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 app/src/main/java/zerrium/FilterKeywords.java diff --git a/app/src/main/java/zerrium/FilterKeywords.java b/app/src/main/java/zerrium/FilterKeywords.java new file mode 100644 index 00000000..10ee3502 --- /dev/null +++ b/app/src/main/java/zerrium/FilterKeywords.java @@ -0,0 +1,28 @@ +package zerrium; + +import java.util.ArrayList; +import java.util.Arrays; + +public class FilterKeywords { + private static final ArrayList FILTER_KEYWORDS = new ArrayList<>(); + + public static boolean append(String keyword){ + if(keyword == null) return false; + FILTER_KEYWORDS.add(keyword); + return true; + } + + public static boolean insert(String[] keywords){ + if(keywords == null) return false; + FILTER_KEYWORDS.addAll(Arrays.asList(keywords)); + return true; + } + + public static boolean filter(String word){ + if(word == null) return false; + for(String s:FILTER_KEYWORDS){ + if(word.contains(s)) return true; + } + return false; + } +}