Adjust the layouts of selecting category page and selecting wallpaper page
Category selecting page:
https://screenshot.googleplex.com/zeQq6Ch64vZyGuN.png
2 column wallpaper selecting page:
https://screenshot.googleplex.com/HQcF6CgKcaTgpiz.png
3 column wallpaper selecting page:
https://screenshot.googleplex.com/3PvgzgZXEXjbnXp.png
Bug: 186005937
Test: manual
Change-Id: Ic2ab068b9ab0b8db71bacb6ee33628b310365c15
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
index 0a0222d..2277a99 100755
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
+++ b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
@@ -515,8 +515,6 @@
updateImageGridPadding(false /* addExtraBottomSpace */);
mImageGrid.setScrollBarSize(gridPaddingPx);
}
- mImageGrid.addItemDecoration(new GridPaddingDecoration(
- getResources().getDimensionPixelSize(R.dimen.grid_padding)));
mLoading = view.findViewById(R.id.loading_indicator);
updateLoading();
maybeSetUpImageGrid();
@@ -572,6 +570,11 @@
if (mAdapter != null) {
return;
}
+ mImageGrid.addItemDecoration(new GridPaddingDecoration(getGridItemPaddingHorizontal(),
+ getGridItemPaddingBottom()));
+ int edgePadding = getEdgePadding();
+ mImageGrid.setPadding(edgePadding, mImageGrid.getPaddingTop(), edgePadding,
+ mImageGrid.getPaddingBottom());
mTileSizePx = mCategoryProvider.isFeaturedCategory(mCategory)
? SizeCalculator.getFeaturedIndividualTileSize(getActivity())
: SizeCalculator.getIndividualTileSize(getActivity());
@@ -581,6 +584,27 @@
mImageGrid, (BottomSheetHost) getParentFragment(), getNumColumns()));
}
+ private int getGridItemPaddingHorizontal() {
+ return mCategoryProvider.isFeaturedCategory(mCategory)
+ ? getResources().getDimensionPixelSize(
+ R.dimen.grid_item_featured_individual_padding_horizontal)
+ : getResources().getDimensionPixelSize(
+ R.dimen.grid_item_individual_padding_horizontal);
+ }
+
+ private int getGridItemPaddingBottom() {
+ return mCategoryProvider.isFeaturedCategory(mCategory)
+ ? getResources().getDimensionPixelSize(
+ R.dimen.grid_item_featured_individual_padding_bottom)
+ : getResources().getDimensionPixelSize(R.dimen.grid_item_individual_padding_bottom);
+ }
+
+ private int getEdgePadding() {
+ return mCategoryProvider.isFeaturedCategory(mCategory)
+ ? getResources().getDimensionPixelSize(R.dimen.featured_wallpaper_grid_edge_space)
+ : getResources().getDimensionPixelSize(R.dimen.wallpaper_grid_edge_space);
+ }
+
/**
* Create the adapter and assign it to mImageGrid.
* Both mImageGrid and mCategory are guaranteed to not be null when this method is called.
@@ -1370,10 +1394,12 @@
private class GridPaddingDecoration extends RecyclerView.ItemDecoration {
- private int mPadding;
+ private final int mPaddingHorizontal;
+ private final int mPaddingBottom;
- GridPaddingDecoration(int padding) {
- mPadding = padding;
+ GridPaddingDecoration(int paddingHorizontal, int paddingBottom) {
+ mPaddingHorizontal = paddingHorizontal;
+ mPaddingBottom = paddingBottom;
}
@Override
@@ -1381,8 +1407,9 @@
RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
if (position >= 0) {
- outRect.left = mPadding;
- outRect.right = mPadding;
+ outRect.left = mPaddingHorizontal;
+ outRect.right = mPaddingHorizontal;
+ outRect.bottom = mPaddingBottom;
}
}
}