Search in sources :

Example 21 with AdapterItem

use of com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem in project android_packages_apps_Launcher3 by ProtonAOSP.

the class AllAppsGridAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    switch(holder.getItemViewType()) {
        case VIEW_TYPE_ICON:
            AdapterItem adapterItem = mApps.getAdapterItems().get(position);
            BubbleTextView icon = (BubbleTextView) holder.itemView;
            icon.reset();
            if (adapterItem.itemInfo instanceof AppInfo) {
                icon.applyFromApplicationInfo((AppInfo) adapterItem.itemInfo);
            } else {
                icon.applyFromItemInfoWithIcon(adapterItem.itemInfo);
            }
            break;
        case VIEW_TYPE_EMPTY_SEARCH:
            TextView emptyViewText = (TextView) holder.itemView;
            emptyViewText.setText(mEmptySearchMessage);
            emptyViewText.setGravity(mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL);
            break;
        case VIEW_TYPE_SEARCH_MARKET:
            TextView searchView = (TextView) holder.itemView;
            if (mMarketSearchIntent != null) {
                searchView.setVisibility(View.VISIBLE);
            } else {
                searchView.setVisibility(View.GONE);
            }
            break;
        case VIEW_TYPE_ALL_APPS_DIVIDER:
            // nothing to do
            break;
        default:
            BaseAdapterProvider adapterProvider = getAdapterProvider(holder.getItemViewType());
            if (adapterProvider != null) {
                adapterProvider.onBindView(holder, position);
            }
    }
}
Also used : BubbleTextView(com.android.launcher3.BubbleTextView) TextView(android.widget.TextView) BubbleTextView(com.android.launcher3.BubbleTextView) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 22 with AdapterItem

use of com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem 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

AppInfo (com.android.launcher3.model.data.AppInfo)16 AdapterItem (com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem)15 TextView (android.widget.TextView)5 AnyThread (androidx.annotation.AnyThread)5 BubbleTextView (com.android.launcher3.BubbleTextView)5 StringMatcherUtility (com.android.launcher3.search.StringMatcherUtility)5 ArrayList (java.util.ArrayList)5 AppInfo (com.android.launcher3.AppInfo)1 ComponentKey (com.android.launcher3.util.ComponentKey)1 DrawerFolderInfo (com.saggitt.omega.groups.DrawerFolderInfo)1