Adjust the grid size of My Photos and the featured wallpaper categories
Screenshots:
https://screenshot.googleplex.com/c7boVR5XpxEVutM.png
https://screenshot.googleplex.com/3r2EkyV8GCoawu3.png
Bug: 182344964
Test: manual
Change-Id: I2c0fcb193cf38bb6b6a18b253398a703df7b2423
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
index f5c4a99..0a0222d 100755
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
+++ b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
@@ -250,6 +250,7 @@
private CurrentWallpaperBottomSheetPresenter mCurrentWallpaperBottomSheetPresenter;
private SetIndividualHolder mPendingSetIndividualHolder;
private ContentLoadingProgressBar mLoading;
+ private CategoryProvider mCategoryProvider;
/**
* Staged error dialog fragments that were unable to be shown when the activity didn't allow
@@ -373,8 +374,8 @@
Glide.get(getContext()).clearMemory();
}
- CategoryProvider categoryProvider = injector.getCategoryProvider(appContext);
- categoryProvider.fetchCategories(new CategoryReceiver() {
+ mCategoryProvider = injector.getCategoryProvider(appContext);
+ mCategoryProvider.fetchCategories(new CategoryReceiver() {
@Override
public void onCategoryReceived(Category category) {
// Do nothing.
@@ -382,7 +383,7 @@
@Override
public void doneFetchingCategories() {
- Category category = categoryProvider.getCategory(
+ Category category = mCategoryProvider.getCategory(
getArguments().getString(ARG_CATEGORY_COLLECTION_ID));
if (category != null && !(category instanceof WallpaperCategory)) {
return;
@@ -508,8 +509,6 @@
}
}
- mTileSizePx = SizeCalculator.getIndividualTileSize(getActivity());
-
mImageGrid = (RecyclerView) view.findViewById(R.id.wallpaper_grid);
if (mFormFactor == FormFactorChecker.FORM_FACTOR_DESKTOP) {
int gridPaddingPx = getResources().getDimensionPixelSize(R.dimen.grid_padding_desktop);
@@ -518,9 +517,6 @@
}
mImageGrid.addItemDecoration(new GridPaddingDecoration(
getResources().getDimensionPixelSize(R.dimen.grid_padding)));
- mImageGrid.setAccessibilityDelegateCompat(
- new WallpaperPickerRecyclerViewAccessibilityDelegate(
- mImageGrid, (BottomSheetHost) getParentFragment(), getNumColumns()));
mLoading = view.findViewById(R.id.loading_indicator);
updateLoading();
maybeSetUpImageGrid();
@@ -576,7 +572,13 @@
if (mAdapter != null) {
return;
}
+ mTileSizePx = mCategoryProvider.isFeaturedCategory(mCategory)
+ ? SizeCalculator.getFeaturedIndividualTileSize(getActivity())
+ : SizeCalculator.getIndividualTileSize(getActivity());
setUpImageGrid();
+ mImageGrid.setAccessibilityDelegateCompat(
+ new WallpaperPickerRecyclerViewAccessibilityDelegate(
+ mImageGrid, (BottomSheetHost) getParentFragment(), getNumColumns()));
}
/**
@@ -849,7 +851,12 @@
int getNumColumns() {
Activity activity = getActivity();
- return activity == null ? 1 : SizeCalculator.getNumIndividualColumns(activity);
+ if (activity == null) {
+ return 1;
+ }
+ return mCategoryProvider.isFeaturedCategory(mCategory)
+ ? SizeCalculator.getNumFeaturedIndividualColumns(activity)
+ : SizeCalculator.getNumIndividualColumns(activity);
}
/**