use of com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem in project android_packages_apps_Launcher3 by crdroidandroid.
the class AlphabeticalAppsList method updateSearchAdapterItems.
void updateSearchAdapterItems(ArrayList<AdapterItem> list, int offset) {
for (int i = 0; i < list.size(); i++) {
AdapterItem adapterItem = list.get(i);
adapterItem.position = offset + i;
mAdapterItems.add(adapterItem);
if (adapterItem.isCountedForAccessibility()) {
mAccessibilityResultsCount++;
}
}
}
use of com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem in project android_packages_apps_Launcher3 by crdroidandroid.
the class AlphabeticalAppsList method refillAdapterItems.
private void refillAdapterItems() {
String lastSectionName = null;
FastScrollSectionInfo lastFastScrollerSectionInfo = null;
int position = 0;
int appIndex = 0;
// Prepare to update the list of sections, filtered apps, etc.
mAccessibilityResultsCount = 0;
mFastScrollerSections.clear();
mAdapterItems.clear();
if (!hasFilter()) {
mAccessibilityResultsCount = mApps.size();
if (mWorkAdapterProvider != null) {
position += mWorkAdapterProvider.addWorkItems(mAdapterItems);
if (!mWorkAdapterProvider.shouldShowWorkApps()) {
return;
}
}
for (AppInfo info : mApps) {
String sectionName = info.sectionName;
// Create a new section if the section names do not match
if (!sectionName.equals(lastSectionName)) {
lastSectionName = sectionName;
lastFastScrollerSectionInfo = new FastScrollSectionInfo(sectionName);
mFastScrollerSections.add(lastFastScrollerSectionInfo);
}
// Create an app item
AdapterItem appItem = AdapterItem.asApp(position++, sectionName, info, appIndex++);
if (lastFastScrollerSectionInfo.fastScrollToItem == null) {
lastFastScrollerSectionInfo.fastScrollToItem = appItem;
}
mAdapterItems.add(appItem);
}
} else {
updateSearchAdapterItems(mSearchResults, 0);
if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
// Append the search market item
if (hasNoFilteredResults()) {
mAdapterItems.add(AdapterItem.asEmptySearch(position++));
} else {
mAdapterItems.add(AdapterItem.asAllAppsDivider(position++));
}
mAdapterItems.add(AdapterItem.asMarketSearch(position++));
}
}
if (mNumAppsPerRow != 0) {
// Update the number of rows in the adapter after we do all the merging (otherwise, we
// would have to shift the values again)
int numAppsInSection = 0;
int numAppsInRow = 0;
int rowIndex = -1;
for (AdapterItem item : mAdapterItems) {
item.rowIndex = 0;
if (AllAppsGridAdapter.isDividerViewType(item.viewType)) {
numAppsInSection = 0;
} else if (AllAppsGridAdapter.isIconViewType(item.viewType)) {
if (numAppsInSection % mNumAppsPerRow == 0) {
numAppsInRow = 0;
rowIndex++;
}
item.rowIndex = rowIndex;
item.rowAppIndex = numAppsInRow;
numAppsInSection++;
numAppsInRow++;
}
}
mNumAppRowsInAdapter = rowIndex + 1;
// Pre-calculate all the fast scroller fractions
switch(mFastScrollDistributionMode) {
case FAST_SCROLL_FRACTION_DISTRIBUTE_BY_ROWS_FRACTION:
float rowFraction = 1f / mNumAppRowsInAdapter;
for (FastScrollSectionInfo info : mFastScrollerSections) {
AdapterItem item = info.fastScrollToItem;
if (!AllAppsGridAdapter.isIconViewType(item.viewType)) {
info.touchFraction = 0f;
continue;
}
float subRowFraction = item.rowAppIndex * (rowFraction / mNumAppsPerRow);
info.touchFraction = item.rowIndex * rowFraction + subRowFraction;
}
break;
case FAST_SCROLL_FRACTION_DISTRIBUTE_BY_NUM_SECTIONS:
float perSectionTouchFraction = 1f / mFastScrollerSections.size();
float cumulativeTouchFraction = 0f;
for (FastScrollSectionInfo info : mFastScrollerSections) {
AdapterItem item = info.fastScrollToItem;
if (!AllAppsGridAdapter.isIconViewType(item.viewType)) {
info.touchFraction = 0f;
continue;
}
info.touchFraction = cumulativeTouchFraction;
cumulativeTouchFraction += perSectionTouchFraction;
}
break;
}
}
}
use of com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem in project Neo-Launcher by NeoApplications.
the class AlphabeticalAppsList method refillAdapterItems.
private void refillAdapterItems() {
String lastSectionName = null;
FastScrollSectionInfo lastFastScrollerSectionInfo = null;
int position = 0;
int appIndex = 0;
int folderIndex = 0;
// Prepare to update the list of sections, filtered apps, etc.
mFilteredApps.clear();
mFastScrollerSections.clear();
mAdapterItems.clear();
// Search suggestions should be all the way to the top
if (hasFilter() && hasSuggestions()) {
for (String suggestion : mSearchSuggestions) {
mAdapterItems.add(AdapterItem.asSearchSuggestion(position++, suggestion));
}
}
// Drawer folders are arranged before all the apps
if (!hasFilter()) {
for (DrawerFolderInfo info : getFolderInfos()) {
String sectionName = "#";
// Create a new section if the section names do not match
if (!sectionName.equals(lastSectionName)) {
lastSectionName = sectionName;
lastFastScrollerSectionInfo = new FastScrollSectionInfo(sectionName, Color.WHITE);
mFastScrollerSections.add(lastFastScrollerSectionInfo);
}
info.setAppsStore(mAllAppsStore);
// Create an folder item
AdapterItem appItem = AdapterItem.asFolder(position++, sectionName, info, folderIndex++);
if (lastFastScrollerSectionInfo.fastScrollToItem == null) {
lastFastScrollerSectionInfo.fastScrollToItem = appItem;
}
mAdapterItems.add(appItem);
}
}
Set<ComponentKey> folderFilters = getFolderFilteredApps();
// ordered set of sections
for (AppInfo info : getFiltersAppInfos()) {
if (!hasFilter() && folderFilters.contains(info.toComponentKey())) {
continue;
}
String sectionName = getAndUpdateCachedSectionName(info);
// Create a new section if the section names do not match
if (!sectionName.equals(lastSectionName)) {
lastSectionName = sectionName;
int color = 0;
if (prefs.getSortMode() == SORT_BY_COLOR) {
color = info.iconColor;
}
lastFastScrollerSectionInfo = new FastScrollSectionInfo(sectionName, color);
mFastScrollerSections.add(lastFastScrollerSectionInfo);
}
// Create an app item
AdapterItem appItem = AdapterItem.asApp(position++, sectionName, info, appIndex++);
if (lastFastScrollerSectionInfo.fastScrollToItem == null) {
lastFastScrollerSectionInfo.fastScrollToItem = appItem;
}
mAdapterItems.add(appItem);
mFilteredApps.add(info);
}
if (hasFilter()) {
// Append the search market item
if (hasNoFilteredResults() && !hasSuggestions()) {
mAdapterItems.add(AdapterItem.asEmptySearch(position++));
} else {
mAdapterItems.add(AdapterItem.asAllAppsDivider(position++));
}
mAdapterItems.add(AdapterItem.asMarketSearch(position++));
}
if (mNumAppsPerRow != 0) {
// Update the number of rows in the adapter after we do all the merging (otherwise, we
// would have to shift the values again)
int numAppsInSection = 0;
int numAppsInRow = 0;
int rowIndex = -1;
for (AdapterItem item : mAdapterItems) {
item.rowIndex = 0;
if (AllAppsGridAdapter.isDividerViewType(item.viewType)) {
numAppsInSection = 0;
} else if (AllAppsGridAdapter.isIconViewType(item.viewType)) {
if (numAppsInSection % mNumAppsPerRow == 0) {
numAppsInRow = 0;
rowIndex++;
}
item.rowIndex = rowIndex;
item.rowAppIndex = numAppsInRow;
numAppsInSection++;
numAppsInRow++;
}
}
mNumAppRowsInAdapter = rowIndex + 1;
// Pre-calculate all the fast scroller fractions
switch(mFastScrollDistributionMode) {
case FAST_SCROLL_FRACTION_DISTRIBUTE_BY_ROWS_FRACTION:
float rowFraction = 1f / mNumAppRowsInAdapter;
for (FastScrollSectionInfo info : mFastScrollerSections) {
AdapterItem item = info.fastScrollToItem;
if (!AllAppsGridAdapter.isIconViewType(item.viewType)) {
info.touchFraction = 0f;
continue;
}
float subRowFraction = item.rowAppIndex * (rowFraction / mNumAppsPerRow);
info.touchFraction = item.rowIndex * rowFraction + subRowFraction;
}
break;
case FAST_SCROLL_FRACTION_DISTRIBUTE_BY_NUM_SECTIONS:
float perSectionTouchFraction = 1f / mFastScrollerSections.size();
float cumulativeTouchFraction = 0f;
for (FastScrollSectionInfo info : mFastScrollerSections) {
AdapterItem item = info.fastScrollToItem;
if (!AllAppsGridAdapter.isIconViewType(item.viewType)) {
info.touchFraction = 0f;
continue;
}
info.touchFraction = cumulativeTouchFraction;
cumulativeTouchFraction += perSectionTouchFraction;
}
break;
}
}
// Add the work profile footer if required.
if (shouldShowWorkFooter()) {
mAdapterItems.add(AdapterItem.asWorkTabFooter(position++));
}
}
use of com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem in project android_packages_apps_Launcher3 by ArrowOS.
the class AlphabeticalAppsList method updateSearchAdapterItems.
void updateSearchAdapterItems(ArrayList<AdapterItem> list, int offset) {
for (int i = 0; i < list.size(); i++) {
AdapterItem adapterItem = list.get(i);
adapterItem.position = offset + i;
mAdapterItems.add(adapterItem);
if (adapterItem.isCountedForAccessibility()) {
mAccessibilityResultsCount++;
}
}
}
use of com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem in project android_packages_apps_Launcher3 by ArrowOS.
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);
}
}
}
Aggregations