Skip to content

Commit

Permalink
computeMaxWidthOfListAdapterItems method seems redundant and can be r…
Browse files Browse the repository at this point in the history
…emoved

Bug: None
Change-Id: I8f566d251a97631d8d0ec278b3bbb635f610d285
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4881241
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by: David Trainor <dtrainor@chromium.org>
Reviewed-by: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1201689}
  • Loading branch information
Leena Kaushik authored and Chromium LUCI CQ committed Sep 26, 2023
1 parent 5f7fe6f commit ecd832a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ Lauren Yeun Kim <lauren.yeun.kim@gmail.com>
Lauri Oherd <lauri.oherd@gmail.com>
Lavar Askew <open.hyperion@gmail.com>
Le Hoang Quyen <le.hoang.q@gmail.com>
Leena Kaushik <l1.kaushik@samsung.com>
Legend Lee <guanxian.li@intel.com>
Leith Bade <leith@leithalweapon.geek.nz>
Lei Gao <leigao@huawei.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ public View getView(int position, View convertView, ViewGroup parent) {

private void measureContent() {
// Make the menu wide enough to fit its widest item.
int width = UiUtils.computeMaxWidthOfListAdapterItems(mSuggestionListView.getAdapter());
int width =
UiUtils.computeMaxWidthOfListAdapterItems(mSuggestionListView.getAdapter(), null);
width += mContentView.getPaddingLeft() + mContentView.getPaddingRight();

final int verticalMeasure = View.MeasureSpec.makeMeasureSpec(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,6 @@ public boolean isShowing() {
*/
private int measureContentWidth() {
assert mAdapter != null : "Set the adapter before showing the popup.";
return UiUtils.computeMaxWidthOfListAdapterItems(mAdapter);
return UiUtils.computeMaxWidthOfListAdapterItems(mAdapter, null);
}
}
17 changes: 1 addition & 16 deletions ui/android/java/src/org/chromium/ui/UiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public static Typeface createRobotoMediumTypeface() {
* will be terrible since it measures every single item.
*
* @param adapter The ListAdapter whose widest item's width will be returned.
* @param parentView The parent view.
* @param parentView The parent view. This can be null.
* @return The measured width (in pixels) of the widest item in the passed-in ListAdapter.
*/
public static int computeMaxWidthOfListAdapterItems(ListAdapter adapter, ViewGroup parentView) {
Expand Down Expand Up @@ -319,21 +319,6 @@ public static int computeMaxWidthOfListAdapterItems(ListAdapter adapter, ViewGro
return maxWidth;
}

/**
* Iterates through all items in the specified ListAdapter (including header and footer views)
* and returns the width of the widest item (when laid out with height and width set to
* WRAP_CONTENT).
*
* WARNING: do not call this on a ListAdapter with more than a handful of items, the performance
* will be terrible since it measures every single item.
*
* @param adapter The ListAdapter whose widest item's width will be returned.
* @return The measured width (in pixels) of the widest item in the passed-in ListAdapter.
*/
public static int computeMaxWidthOfListAdapterItems(ListAdapter adapter) {
return computeMaxWidthOfListAdapterItems(adapter, null);
}

/**
* Get the index of a child {@link View} in a {@link ViewGroup}.
* @param child The child to find the index of.
Expand Down

0 comments on commit ecd832a

Please sign in to comment.