summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-06-14 10:30:54 -0700
committerSunny Goyal <sunnygoyal@google.com>2017-06-14 11:18:13 -0700
commitf6eb789016fdf56ca6721b4ebed37d2df0a33dfa (patch)
tree89947d555d7d04528a9d9ae3afb6addf16aaa664 /src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java
parent7847d10f389425a92e11b29f181acbbebc8b1dab (diff)
downloadandroid_packages_apps_Trebuchet-f6eb789016fdf56ca6721b4ebed37d2df0a33dfa.tar.gz
android_packages_apps_Trebuchet-f6eb789016fdf56ca6721b4ebed37d2df0a33dfa.tar.bz2
android_packages_apps_Trebuchet-f6eb789016fdf56ca6721b4ebed37d2df0a33dfa.zip
Extracting search algorithm in an interface to make it easier to change the search behavior
Change-Id: I0b1d1387c78d13ef749aac39d5c8167c2909716a
Diffstat (limited to 'src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java')
-rw-r--r--src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java b/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java
index 06097d0e6..8a0fd46f7 100644
--- a/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java
+++ b/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java
@@ -26,7 +26,7 @@ import java.util.List;
/**
* The default search implementation.
*/
-public class DefaultAppSearchAlgorithm {
+public class DefaultAppSearchAlgorithm implements SearchAlgorithm {
private final List<AppInfo> mApps;
protected final Handler mResultHandler;
@@ -36,12 +36,14 @@ public class DefaultAppSearchAlgorithm {
mResultHandler = new Handler();
}
+ @Override
public void cancel(boolean interruptActiveRequests) {
if (interruptActiveRequests) {
mResultHandler.removeCallbacksAndMessages(null);
}
}
+ @Override
public void doSearch(final String query,
final AllAppsSearchBarController.Callbacks callback) {
final ArrayList<ComponentKey> result = getTitleMatchResult(query);
@@ -54,7 +56,7 @@ public class DefaultAppSearchAlgorithm {
});
}
- public ArrayList<ComponentKey> getTitleMatchResult(String query) {
+ private ArrayList<ComponentKey> getTitleMatchResult(String query) {
// Do an intersection of the words in the query and each title, and filter out all the
// apps that don't match all of the words in the query.
final String queryTextLower = query.toLowerCase();
@@ -67,7 +69,7 @@ public class DefaultAppSearchAlgorithm {
return result;
}
- public boolean matches(AppInfo info, String query) {
+ public static boolean matches(AppInfo info, String query) {
int queryLength = query.length();
String title = info.title.toString();
@@ -103,7 +105,7 @@ public class DefaultAppSearchAlgorithm {
* 3) Any capital character after a digit or small character
* 4) Any capital character before a small character
*/
- protected boolean isBreak(int thisType, int prevType, int nextType) {
+ private static boolean isBreak(int thisType, int prevType, int nextType) {
switch (thisType) {
case Character.UPPERCASE_LETTER:
if (nextType == Character.UPPERCASE_LETTER) {