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

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

Issue 2848453002: dynamic context menu resizing (Closed)
Patch Set: 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..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);
}
+
}
« 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