Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3304)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java

Issue 2848453002: dynamic context menu resizing (Closed)
Patch Set: comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a42332357e082bd914cdcfb43eaab5ba098c1d1c 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
@@ -30,24 +30,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().
+ int currentItemsIndex = getCurrentItem() + 1;
+
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
- child.measure(widthMeasureSpec,
- MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.UNSPECIFIED));
+ child.measure(
+ widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int measuredHeight = child.getMeasuredHeight();
// 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);
+ int fullHeight = menuHeight + tabHeight;
+
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(fullHeight, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698