| Index: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuUi.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuUi.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuUi.java
|
| index 7a7e5c125a29017108dab2dbfb3e6060d42b70d0..36284a63312a337f2965ee20b0c8ac04a77b6cb8 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuUi.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuUi.java
|
| @@ -122,18 +122,12 @@ public class TabularContextMenuUi implements ContextMenuUi, AdapterView.OnItemCl
|
| List<Pair<Integer, List<ContextMenuItem>>> itemGroups,
|
| TabularContextMenuViewPager viewPager) {
|
| List<Pair<String, ViewGroup>> viewGroups = new ArrayList<>();
|
| - int maxCount = 0;
|
| - for (int i = 0; i < itemGroups.size(); i++) {
|
| - Pair<Integer, List<ContextMenuItem>> itemGroup = itemGroups.get(i);
|
| - maxCount = Math.max(maxCount, itemGroup.second.size());
|
| - }
|
| for (int i = 0; i < itemGroups.size(); i++) {
|
| Pair<Integer, List<ContextMenuItem>> itemGroup = itemGroups.get(i);
|
| // TODO(tedchoc): Pass the ContextMenuGroup identifier to determine if it's an image.
|
| boolean isImageTab = itemGroup.first == R.string.contextmenu_image_title;
|
| viewGroups.add(new Pair<>(activity.getString(itemGroup.first),
|
| - createContextMenuPageUi(
|
| - activity, params, itemGroup.second, isImageTab, maxCount)));
|
| + createContextMenuPageUi(activity, params, itemGroup.second, isImageTab)));
|
| }
|
|
|
| viewPager.setAdapter(new TabularContextMenuPagerAdapter(viewGroups));
|
| @@ -163,7 +157,7 @@ public class TabularContextMenuUi implements ContextMenuUi, AdapterView.OnItemCl
|
| */
|
| @VisibleForTesting
|
| ViewGroup createContextMenuPageUi(Activity activity, ContextMenuParams params,
|
| - List<ContextMenuItem> items, boolean isImage, int maxCount) {
|
| + List<ContextMenuItem> items, boolean isImage) {
|
| ViewGroup baseLayout = (ViewGroup) LayoutInflater.from(activity).inflate(
|
| R.layout.tabular_context_menu_page, null);
|
| ListView listView = (ListView) baseLayout.findViewById(R.id.selectable_items);
|
| @@ -188,7 +182,7 @@ public class TabularContextMenuUi implements ContextMenuUi, AdapterView.OnItemCl
|
| TabularContextMenuListAdapter listAdapter =
|
| new TabularContextMenuListAdapter(items, activity, onDirectShare);
|
| ViewGroup.LayoutParams layoutParams = listView.getLayoutParams();
|
| - layoutParams.height = measureApproximateListViewHeight(listView, listAdapter, maxCount);
|
| + layoutParams.height = measureApproximateListViewHeight(listView, listAdapter, items.size());
|
| listView.setLayoutParams(layoutParams);
|
| listView.setAdapter(listAdapter);
|
| listView.setOnItemClickListener(this);
|
| @@ -262,7 +256,7 @@ public class TabularContextMenuUi implements ContextMenuUi, AdapterView.OnItemCl
|
| * of the ListView based off the an item.
|
| */
|
| private int measureApproximateListViewHeight(
|
| - ListView listView, BaseAdapter listAdapter, int maxCount) {
|
| + ListView listView, BaseAdapter listAdapter, int itemCount) {
|
| int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom();
|
| if (mMenuItemHeight == 0 && !listAdapter.isEmpty()) {
|
| View view = listAdapter.getView(0, null, listView);
|
| @@ -270,7 +264,7 @@ public class TabularContextMenuUi implements ContextMenuUi, AdapterView.OnItemCl
|
| View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
|
| mMenuItemHeight = view.getMeasuredHeight();
|
| }
|
| - return totalHeight + mMenuItemHeight * maxCount;
|
| + return totalHeight + mMenuItemHeight * itemCount;
|
| }
|
|
|
| /**
|
|
|