mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 17:36:49 +00:00
Extract out common adapter logic to support different AllApps layouts
Test: Manual tests. Refactoring, all existing tests should pass. Bug: 216150568 Change-Id: I1068e75d0b4a33d402a7d68e237d2484ab3a1e01
This commit is contained in:
@@ -44,7 +44,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
@@ -697,18 +696,21 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
return ColorUtils.blendARGB(mScrimColor, mHeaderProtectionColor, blendRatio);
|
||||
}
|
||||
|
||||
protected abstract BaseAllAppsAdapter getAdapter(AlphabeticalAppsList<T> mAppsList,
|
||||
BaseAdapterProvider[] adapterProviders);
|
||||
|
||||
protected int getHeaderBottom() {
|
||||
return (int) getTranslationY();
|
||||
}
|
||||
|
||||
/** Holds a {@link AllAppsGridAdapter} and related fields. */
|
||||
/** Holds a {@link BaseAllAppsAdapter} and related fields. */
|
||||
public class AdapterHolder {
|
||||
public static final int MAIN = 0;
|
||||
public static final int WORK = 1;
|
||||
|
||||
private final boolean mIsWork;
|
||||
public final AllAppsGridAdapter<T> adapter;
|
||||
final LinearLayoutManager mLayoutManager;
|
||||
public final BaseAllAppsAdapter<T> adapter;
|
||||
final RecyclerView.LayoutManager mLayoutManager;
|
||||
final AlphabeticalAppsList<T> mAppsList;
|
||||
final Rect mPadding = new Rect();
|
||||
AllAppsRecyclerView mRecyclerView;
|
||||
@@ -724,8 +726,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
mWorkManager.getAdapterProvider()}
|
||||
: new BaseAdapterProvider[]{mMainAdapterProvider};
|
||||
|
||||
adapter = new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList,
|
||||
adapterProviders);
|
||||
adapter = getAdapter(mAppsList, adapterProviders);
|
||||
mAppsList.setAdapter(adapter);
|
||||
mLayoutManager = adapter.getLayoutManager();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user