Removing unnecessary abstraction of AdapterProvider

Bug: 266605714
Test: Presubmit
Change-Id: Ib5ccecc33e66e61cb27d083591c8fb7c13a96698
Merged-In: Ib5ccecc33e66e61cb27d083591c8fb7c13a96698
This commit is contained in:
Sunny Goyal
2023-01-25 10:24:18 -08:00
parent dbc5e56e07
commit 49d153e4bf
6 changed files with 64 additions and 121 deletions

View File

@@ -143,7 +143,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
private boolean mRebindAdaptersAfterSearchAnimation;
private int mNavBarScrimHeight = 0;
private SearchRecyclerView mSearchRecyclerView;
private SearchAdapterProvider<?> mMainAdapterProvider;
protected SearchAdapterProvider<?> mMainAdapterProvider;
private View mBottomSheetHandleArea;
private boolean mHasWorkApps;
private float[] mBottomSheetCornerRadii;
@@ -202,9 +202,12 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
protected void initContent() {
mMainAdapterProvider = createMainAdapterProvider();
mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN));
mAH.set(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK));
mAH.set(SEARCH, new AdapterHolder(SEARCH));
mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN,
new AlphabeticalAppsList<>(mActivityContext, mAllAppsStore, null)));
mAH.set(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK,
new AlphabeticalAppsList<>(mActivityContext, mAllAppsStore, mWorkManager)));
mAH.set(SEARCH, new AdapterHolder(SEARCH,
new AlphabeticalAppsList<>(mActivityContext, null, null)));
getLayoutInflater().inflate(R.layout.all_apps_content, this);
mHeader = findViewById(R.id.all_apps_header);
@@ -344,7 +347,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
mAH.get(i).mRecyclerView.scrollToTop();
}
}
if (isHeaderVisible()) {
if (mHeader != null && mHeader.getVisibility() == VISIBLE) {
mHeader.reset(animate);
}
// Reset the base recycler view after transitioning home.
@@ -625,10 +628,9 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_TOP);
}
protected BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> appsList,
BaseAdapterProvider[] adapterProviders) {
protected BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> appsList) {
return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList,
adapterProviders);
mMainAdapterProvider);
}
// TODO(b/216683257): Remove when Taskbar All Apps supports search.
@@ -999,10 +1001,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
return rv == null ? null : rv.getScrollbar();
}
public boolean isHeaderVisible() {
return mHeader != null && mHeader.getVisibility() == View.VISIBLE;
}
/**
* Adds an update listener to animator that adds springs to the animation.
*/
@@ -1153,15 +1151,10 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
final Rect mPadding = new Rect();
AllAppsRecyclerView mRecyclerView;
AdapterHolder(int type) {
AdapterHolder(int type, AlphabeticalAppsList<T> appsList) {
mType = type;
mAppsList = new AlphabeticalAppsList<>(mActivityContext,
isSearch() ? null : mAllAppsStore,
isWork() ? mWorkManager : null);
BaseAdapterProvider[] adapterProviders =
new BaseAdapterProvider[]{mMainAdapterProvider};
mAdapter = createAdapter(mAppsList, adapterProviders);
mAppsList = appsList;
mAdapter = createAdapter(mAppsList);
mAppsList.setAdapter(mAdapter);
mLayoutManager = mAdapter.getLayoutManager();
}