Search in sources :

Example 1 with StringMatcherUtility.matches

use of com.android.launcher3.search.StringMatcherUtility.matches in project android_packages_apps_Launcher3 by crdroidandroid.

the class DefaultAppSearchAlgorithm method getTitleMatchResult.

/**
 * Filters {@link AppInfo}s matching specified query
 */
@AnyThread
public static ArrayList<AdapterItem> getTitleMatchResult(List<AppInfo> apps, 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();
    final ArrayList<AdapterItem> result = new ArrayList<>();
    StringMatcherUtility.StringMatcher matcher = StringMatcherUtility.StringMatcher.getInstance();
    int resultCount = 0;
    int total = apps.size();
    for (int i = 0; i < total && resultCount < MAX_RESULTS_COUNT; i++) {
        AppInfo info = apps.get(i);
        if (StringMatcherUtility.matches(queryTextLower, info.title.toString(), matcher)) {
            AdapterItem appItem = AdapterItem.asApp(resultCount, "", info, resultCount);
            result.add(appItem);
            resultCount++;
        }
    }
    return result;
}
Also used : StringMatcherUtility(com.android.launcher3.search.StringMatcherUtility) ArrayList(java.util.ArrayList) AdapterItem(com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem) AppInfo(com.android.launcher3.model.data.AppInfo) AnyThread(androidx.annotation.AnyThread)

Example 2 with StringMatcherUtility.matches

use of com.android.launcher3.search.StringMatcherUtility.matches in project android_packages_apps_Launcher3 by ArrowOS.

the class DefaultAppSearchAlgorithm method getTitleMatchResult.

/**
 * Filters {@link AppInfo}s matching specified query
 */
@AnyThread
public static ArrayList<AdapterItem> getTitleMatchResult(List<AppInfo> apps, 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();
    final ArrayList<AdapterItem> result = new ArrayList<>();
    StringMatcherUtility.StringMatcher matcher = StringMatcherUtility.StringMatcher.getInstance();
    int resultCount = 0;
    int total = apps.size();
    for (int i = 0; i < total && resultCount < MAX_RESULTS_COUNT; i++) {
        AppInfo info = apps.get(i);
        if (StringMatcherUtility.matches(queryTextLower, info.title.toString(), matcher)) {
            AdapterItem appItem = AdapterItem.asApp(resultCount, "", info, resultCount);
            result.add(appItem);
            resultCount++;
        }
    }
    return result;
}
Also used : StringMatcherUtility(com.android.launcher3.search.StringMatcherUtility) ArrayList(java.util.ArrayList) AdapterItem(com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem) AppInfo(com.android.launcher3.model.data.AppInfo) AnyThread(androidx.annotation.AnyThread)

Example 3 with StringMatcherUtility.matches

use of com.android.launcher3.search.StringMatcherUtility.matches in project android_packages_apps_Launcher3 by ProtonAOSP.

the class DefaultAppSearchAlgorithm method getTitleMatchResult.

/**
 * Filters {@link AppInfo}s matching specified query
 */
@AnyThread
public static ArrayList<AdapterItem> getTitleMatchResult(List<AppInfo> apps, 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();
    final ArrayList<AdapterItem> result = new ArrayList<>();
    StringMatcherUtility.StringMatcher matcher = StringMatcherUtility.StringMatcher.getInstance();
    int resultCount = 0;
    int total = apps.size();
    for (int i = 0; i < total && resultCount < MAX_RESULTS_COUNT; i++) {
        AppInfo info = apps.get(i);
        if (StringMatcherUtility.matches(queryTextLower, info.title.toString(), matcher)) {
            AdapterItem appItem = AdapterItem.asApp(resultCount, "", info, resultCount);
            result.add(appItem);
            resultCount++;
        }
    }
    return result;
}
Also used : StringMatcherUtility(com.android.launcher3.search.StringMatcherUtility) ArrayList(java.util.ArrayList) AdapterItem(com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem) AppInfo(com.android.launcher3.model.data.AppInfo) AnyThread(androidx.annotation.AnyThread)

Example 4 with StringMatcherUtility.matches

use of com.android.launcher3.search.StringMatcherUtility.matches in project android_packages_apps_404Launcher by P-404.

the class DefaultAppSearchAlgorithm method getTitleMatchResult.

/**
 * Filters {@link AppInfo}s matching specified query
 */
@AnyThread
public static ArrayList<AdapterItem> getTitleMatchResult(List<AppInfo> apps, 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();
    final ArrayList<AdapterItem> result = new ArrayList<>();
    StringMatcherUtility.StringMatcher matcher = StringMatcherUtility.StringMatcher.getInstance();
    int resultCount = 0;
    int total = apps.size();
    for (int i = 0; i < total && resultCount < MAX_RESULTS_COUNT; i++) {
        AppInfo info = apps.get(i);
        if (StringMatcherUtility.matches(queryTextLower, info.title.toString(), matcher)) {
            AdapterItem appItem = AdapterItem.asApp(resultCount, "", info, resultCount);
            result.add(appItem);
            resultCount++;
        }
    }
    return result;
}
Also used : StringMatcherUtility(com.android.launcher3.search.StringMatcherUtility) ArrayList(java.util.ArrayList) AdapterItem(com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem) AppInfo(com.android.launcher3.model.data.AppInfo) AnyThread(androidx.annotation.AnyThread)

Example 5 with StringMatcherUtility.matches

use of com.android.launcher3.search.StringMatcherUtility.matches in project android_packages_apps_Launcher3 by AOSPA.

the class DefaultAppSearchAlgorithm method getTitleMatchResult.

/**
 * Filters {@link AppInfo}s matching specified query
 */
@AnyThread
public static ArrayList<AdapterItem> getTitleMatchResult(List<AppInfo> apps, 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();
    final ArrayList<AdapterItem> result = new ArrayList<>();
    StringMatcherUtility.StringMatcher matcher = StringMatcherUtility.StringMatcher.getInstance();
    int resultCount = 0;
    int total = apps.size();
    for (int i = 0; i < total && resultCount < MAX_RESULTS_COUNT; i++) {
        AppInfo info = apps.get(i);
        if (StringMatcherUtility.matches(queryTextLower, info.title.toString(), matcher)) {
            AdapterItem appItem = AdapterItem.asApp(resultCount, "", info, resultCount);
            result.add(appItem);
            resultCount++;
        }
    }
    return result;
}
Also used : StringMatcherUtility(com.android.launcher3.search.StringMatcherUtility) ArrayList(java.util.ArrayList) AdapterItem(com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem) AppInfo(com.android.launcher3.model.data.AppInfo) AnyThread(androidx.annotation.AnyThread)

Aggregations

AnyThread (androidx.annotation.AnyThread)5 AdapterItem (com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem)5 AppInfo (com.android.launcher3.model.data.AppInfo)5 StringMatcherUtility (com.android.launcher3.search.StringMatcherUtility)5 ArrayList (java.util.ArrayList)5