Commit 771ef750 authored by Tommy Martino's avatar Tommy Martino Committed by Commit Bot

[AF Android] Include footer when calculating width

When initially adding the footer functionality to the dropdown, the
possibility that the footer would have a greater width than the rest
of the dropdown was not considered. This CL updates the width
calculation in the base level dropdown class.

Screenshots:
https://docs.google.com/presentation/d/168Uk8_itrZTvf5RfsmCmpkFUebMJo2h61bBZBYQ70i8/edit?usp=sharing

Bug: 874077
Change-Id: I08051ac7302f476ee82ac5e077e49c4cdd00ef88
Reviewed-on: https://chromium-review.googlesource.com/c/1258051Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Commit-Queue: Tommy Martino <tmartino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596348}
parent 9e5619a8
......@@ -9,7 +9,9 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.AdapterView;
import android.widget.FrameLayout;
......@@ -258,6 +260,16 @@ class DropdownPopupWindowImpl
*/
private int measureContentWidth() {
assert mAdapter != null : "Set the adapter before showing the popup.";
return UiUtils.computeMaxWidthOfListAdapterItems(mAdapter);
int adapterWidth = UiUtils.computeMaxWidthOfListAdapterItems(mAdapter);
if (mFooterView.getChildCount() > 0) {
if (mFooterView.getLayoutParams() == null) {
mFooterView.setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
int measureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
mFooterView.measure(measureSpec, measureSpec);
return Math.max(mFooterView.getMeasuredWidth(), adapterWidth);
}
return adapterWidth;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment