Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java |
| index 640aabe91a27fc70069f04302a0b1facb4ccb1db..713ac0372352f106b24ef29806db53cd53885477 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java |
| @@ -16,6 +16,7 @@ import org.chromium.chrome.R; |
| * pager. |
| */ |
| public class TabularContextMenuViewPager extends ViewPager { |
| + |
| public TabularContextMenuViewPager(Context context) { |
| super(context); |
| } |
| @@ -30,24 +31,29 @@ public class TabularContextMenuViewPager extends ViewPager { |
| */ |
| @Override |
| protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| - int maxHeight = 0; |
| + int menuHeight = 0; |
| int tabHeight = 0; |
| + //getCurrentItem() does not take into account the tab layout unlike getChildCount() |
|
gone
2017/04/27 18:14:14
space after //
end with a period
https://google.g
gone
2017/05/02 17:15:41
Welp, that's required because that's how ViewPager
Daniel Park
2017/05/02 17:32:24
Done.
|
| + int currentItemsIndex = getCurrentItem() + 1; |
| + |
| for (int i = 0; i < getChildCount(); i++) { |
| View child = getChildAt(i); |
| child.measure(widthMeasureSpec, |
| - MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.UNSPECIFIED)); |
| + MeasureSpec.makeMeasureSpec(menuHeight, MeasureSpec.UNSPECIFIED)); |
|
gone
2017/04/27 18:14:14
makeMeasureSpec(0, MeasureSpec.UNSPECIFIED). Sett
Daniel Park
2017/05/02 17:32:24
Done.
|
| int measuredHeight = child.getMeasuredHeight(); |
| - |
|
gone
2017/04/27 18:14:14
Put this line back. It' a comment sandwich otherw
Daniel Park
2017/05/02 17:57:58
Done.
|
| // The ViewPager also considers the tab layout one of its children, and needs to be |
| // treated separately from getting the largest height. |
| if (child.getId() == R.id.tab_layout && child.getVisibility() != GONE) { |
| tabHeight = measuredHeight; |
| - } else { |
| - maxHeight = Math.max(maxHeight, child.getMeasuredHeight()); |
| + } else if (i == currentItemsIndex) { |
| + menuHeight = child.getMeasuredHeight(); |
| + break; |
| } |
| } |
| - maxHeight += tabHeight; |
| - heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY); |
| + menuHeight += tabHeight; |
|
gone
2017/04/27 18:14:14
int fullHeight = menuHeight + tabHeight?
Daniel Park
2017/05/02 17:32:24
Done.
|
| + |
| + heightMeasureSpec = MeasureSpec.makeMeasureSpec(menuHeight, MeasureSpec.EXACTLY); |
| super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| } |
| + |
| } |