Merge "Removing unnecessary abstraction of AdapterProvider" into tm-qpr-dev

This commit is contained in:
Sunny Goyal
2023-01-27 21:40:27 +00:00
committed by Android (Google) Code Review
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.
@@ -627,10 +630,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.
@@ -1001,10 +1003,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.
*/
@@ -1155,15 +1153,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();
}