Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SpacingListItem.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SpacingListItem.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SpacingListItem.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8541fac8707b3a46d2d0d11d891b4997a453de45 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SpacingListItem.java |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.ntp.cards; |
| + |
| +import android.content.Context; |
| +import android.view.View; |
| +import android.view.ViewGroup; |
| + |
| +/** |
| + * Placeholder item to let the snippets flow to the top of the scroll list even when it does not |
| + * contain enough of them. It is displayed as a dummy item with variable height that just occupies |
| + * the remaining space between the last item in the RecyclerView and the bottom of the screen. |
| + */ |
| +public class SpacingListItem implements NewTabPageListItem { |
| + private static class SpacingListItemView extends View { |
| + public SpacingListItemView(Context context) { |
| + super(context); |
| + } |
| + |
| + @Override |
| + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| + assert getParent() instanceof NewTabPageRecyclerView; |
|
Bernhard Bauer
2016/05/12 11:21:00
You'll get an exception anyway if this isn't the c
dgn
2016/05/13 13:49:59
Removed.
|
| + setMeasuredDimension( |
| + 0, ((NewTabPageRecyclerView) getParent()).calculateBottomSpacing()); |
|
Bernhard Bauer
2016/05/12 11:21:00
So, stupid question: If all we are doing here is s
dgn
2016/05/13 13:49:59
The places where we manually request a recalculati
|
| + } |
| + } |
| + |
| + /** Creates the View object for displaying the variable spacing. */ |
| + public static View createView(ViewGroup parent) { |
| + return new SpacingListItemView(parent.getContext()); |
| + } |
| + |
| + @Override |
| + public int getType() { |
| + return NewTabPageListItem.VIEW_TYPE_SPACING; |
| + } |
| +} |