[Search] Support flexible results-per-row in AllApps

Bug: 181987314
Test: Manual
Change-Id: Idc3d24dafc42944a7cc925e0991118c86a89b318
This commit is contained in:
Samuel Fufa
2021-03-05 14:59:13 -06:00
parent 9cde419ee0
commit e2358949d4
2 changed files with 19 additions and 11 deletions

View File

@@ -240,20 +240,18 @@ public class AllAppsGridAdapter extends
@Override
public int getSpanSize(int position) {
int viewType = mApps.getAdapterItems().get(position).viewType;
int totalSpans = mGridLayoutMgr.getSpanCount();
if (isIconViewType(viewType)) {
return 1 * SPAN_MULTIPLIER;
return totalSpans / mAppsPerRow;
} else if (mSearchAdapterProvider.isSearchView(viewType)) {
return mSearchAdapterProvider.getGridSpanSize(viewType, mAppsPerRow);
return totalSpans / mSearchAdapterProvider.getItemsPerRow(viewType, mAppsPerRow);
} else {
// Section breaks span the full width
return mAppsPerRow * SPAN_MULTIPLIER;
return totalSpans;
}
}
}
// multiplier to support adapter item column count that is not mAppsPerRow.
public static final int SPAN_MULTIPLIER = 3;
private final BaseDraggingActivity mLauncher;
private final LayoutInflater mLayoutInflater;
private final AlphabeticalAppsList mApps;
@@ -285,14 +283,17 @@ public class AllAppsGridAdapter extends
mOnIconClickListener = launcher.getItemOnClickListener();
setAppsPerRow(mLauncher.getDeviceProfile().inv.numAllAppsColumns);
mSearchAdapterProvider = searchAdapterProvider;
setAppsPerRow(mLauncher.getDeviceProfile().inv.numAllAppsColumns);
}
public void setAppsPerRow(int appsPerRow) {
mAppsPerRow = appsPerRow;
mGridLayoutMgr.setSpanCount(mAppsPerRow * SPAN_MULTIPLIER);
int totalSpans = mAppsPerRow;
for (int itemPerRow : mSearchAdapterProvider.getSupportedItemsPerRow()) {
totalSpans *= itemPerRow;
}
mGridLayoutMgr.setSpanCount(totalSpans);
}
/**