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);
}
}
}
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;
}
Aggregations