Commit ec08175d authored by Shakti Sahu's avatar Shakti Sahu Committed by Commit Bot

Download Home : Fixed padding for recycler view

The width of the recycler view used for computing span count and decorations
needed to account for the huge padding that is added on a wide screen
which limits the view width to 600dp. Fixed the issue.

Bug: 902369
Change-Id: Idffd31813fdfcaaac3be5a1ffbd9b5e6c0119f25
Reviewed-on: https://chromium-review.googlesource.com/c/1321576Reviewed-by: default avatarXing Liu <xingliu@chromium.org>
Reviewed-by: default avatarBecky Zhou <huayinz@chromium.org>
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605907}
parent 09a47c25
......@@ -546,7 +546,6 @@
<dimen name="download_manager_ideal_image_width">150dp</dimen>
<dimen name="download_manager_recycler_view_min_padding_wide_screen">16dp</dimen>
<dimen name="download_manager_max_image_item_width_wide_screen">300dp</dimen>
<dimen name="download_manager_wide_screen_threshold">600dp</dimen>
<dimen name="download_manager_image_padding">2dp</dimen>
<dimen name="download_manager_prefetch_horizontal_margin">16dp</dimen>
<dimen name="download_manager_prefetch_vertical_margin">12dp</dimen>
......
......@@ -41,7 +41,6 @@ class DateOrderedListView {
private final int mPrefetchVerticalPaddingPx;
private final int mPrefetchHorizontalPaddingPx;
private final int mMaxWidthImageItemPx;
private final int mWideScreenThreshold;
private final RecyclerView mView;
private final UiConfig mUiConfig;
......@@ -62,8 +61,6 @@ class DateOrderedListView {
R.dimen.download_manager_prefetch_vertical_margin);
mMaxWidthImageItemPx = context.getResources().getDimensionPixelSize(
R.dimen.download_manager_max_image_item_width_wide_screen);
mWideScreenThreshold = context.getResources().getDimensionPixelSize(
R.dimen.download_manager_wide_screen_threshold);
mView = new RecyclerView(context) {
private int mScreenOrientation = Configuration.ORIENTATION_UNDEFINED;
......@@ -130,6 +127,12 @@ class DateOrderedListView {
return padding;
}
/** @return The view width available after start and end padding. */
private int getAvailableViewWidth() {
return mView.getWidth() - ViewCompat.getPaddingStart(mView)
- ViewCompat.getPaddingEnd(mView);
}
private class GridLayoutManagerImpl extends GridLayoutManager {
/** Creates an instance of a {@link GridLayoutManagerImpl}. */
public GridLayoutManagerImpl(Context context) {
......@@ -142,7 +145,7 @@ class DateOrderedListView {
public void onLayoutChildren(Recycler recycler, State state) {
assert getOrientation() == VERTICAL;
int availableWidth = getWidth() - mImagePaddingPx;
int availableWidth = getAvailableViewWidth() - mImagePaddingPx;
int columnWidth = mIdealImageWidthPx - mImagePaddingPx;
int easyFitSpan = availableWidth / columnWidth;
......@@ -202,8 +205,10 @@ class DateOrderedListView {
break;
}
if (isFullWidthMedia && mView.getWidth() > mWideScreenThreshold) {
outRect.right += Math.max(mView.getWidth() - mMaxWidthImageItemPx, 0);
if (isFullWidthMedia
&& mUiConfig.getCurrentDisplayStyle().horizontal
== HorizontalDisplayStyle.WIDE) {
outRect.right += Math.max(getAvailableViewWidth() - mMaxWidthImageItemPx, 0);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment