Measure recommendation children using the provided available height
We always want to measure the pages based on the provided height. Bug: 335715046 Test: Manual Flag: NONE BUGFIX Change-Id: I9de2ed1e0d4cc37d24435b9077e60bf5f0456091
This commit is contained in:
@@ -53,6 +53,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public final class WidgetRecommendationsView extends PagedView<PageIndicatorDots> {
|
||||
private @Px float mAvailableHeight = Float.MAX_VALUE;
|
||||
private @Px float mAvailableWidth = 0;
|
||||
private static final String INITIALLY_DISPLAYED_WIDGETS_STATE_KEY =
|
||||
"widgetRecommendationsView:mDisplayedWidgets";
|
||||
private static final int MAX_CATEGORIES = 3;
|
||||
@@ -152,6 +153,7 @@ public final class WidgetRecommendationsView extends PagedView<PageIndicatorDots
|
||||
final @Px float availableHeight, final @Px int availableWidth,
|
||||
final @Px int cellPadding) {
|
||||
this.mAvailableHeight = availableHeight;
|
||||
this.mAvailableWidth = availableWidth;
|
||||
clear();
|
||||
|
||||
Set<ComponentName> displayedWidgets = maybeDisplayInTable(recommendedWidgets,
|
||||
@@ -187,6 +189,7 @@ public final class WidgetRecommendationsView extends PagedView<PageIndicatorDots
|
||||
DeviceProfile deviceProfile, final @Px float availableHeight,
|
||||
final @Px int availableWidth, final @Px int cellPadding, final int requestedPage) {
|
||||
this.mAvailableHeight = availableHeight;
|
||||
this.mAvailableWidth = availableWidth;
|
||||
Context context = getContext();
|
||||
// For purpose of recommendations section, we don't want paging dots to be halved in two
|
||||
// pane display, so, we always provide isTwoPanels = "false".
|
||||
@@ -280,17 +283,24 @@ public final class WidgetRecommendationsView extends PagedView<PageIndicatorDots
|
||||
boolean hasMultiplePages = getChildCount() > 0;
|
||||
|
||||
if (hasMultiplePages) {
|
||||
int finalWidth = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int desiredHeight = 0;
|
||||
int desiredWidth = Math.round(mAvailableWidth);
|
||||
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View child = getChildAt(i);
|
||||
measureChild(child, widthMeasureSpec, heightMeasureSpec);
|
||||
// Measure children based on available height and width.
|
||||
measureChild(child,
|
||||
MeasureSpec.makeMeasureSpec(desiredWidth, MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(Math.round(mAvailableHeight),
|
||||
MeasureSpec.AT_MOST));
|
||||
// Use height of tallest child as we have limited height.
|
||||
desiredHeight = Math.max(desiredHeight, child.getMeasuredHeight());
|
||||
int childHeight = child.getMeasuredHeight();
|
||||
desiredHeight = Math.max(desiredHeight, childHeight);
|
||||
}
|
||||
|
||||
int finalHeight = resolveSizeAndState(desiredHeight, heightMeasureSpec, 0);
|
||||
int finalWidth = resolveSizeAndState(desiredWidth, widthMeasureSpec, 0);
|
||||
|
||||
setMeasuredDimension(finalWidth, finalHeight);
|
||||
} else {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
|
||||
|
||||
// This ratio defines the max percentage of content area that the recommendations can display
|
||||
// with respect to the bottom sheet's height.
|
||||
private static final float RECOMMENDATION_SECTION_HEIGHT_RATIO_TWO_PANE = 0.60f;
|
||||
private static final float RECOMMENDATION_SECTION_HEIGHT_RATIO_TWO_PANE = 0.70f;
|
||||
private FrameLayout mSuggestedWidgetsContainer;
|
||||
private WidgetsListHeader mSuggestedWidgetsHeader;
|
||||
private PackageUserKey mSuggestedWidgetsPackageUserKey;
|
||||
|
||||
Reference in New Issue
Block a user