Merge "Constrain width and height to >= 0 in FastScroller layout" into mnc-dev

This commit is contained in:
Alan Viverette
2015-06-25 17:08:41 +00:00
committed by Android (Google) Code Review

View File

@@ -660,10 +660,11 @@ class FastScroller {
maxWidth = containerWidth - adjacent.getRight();
}
final int adjMaxHeight = Math.max(0, container.height());
final int adjMaxWidth = Math.max(0, maxWidth - marginLeft - marginRight);
final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(adjMaxWidth, MeasureSpec.AT_MOST);
final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(container.height(),
MeasureSpec.UNSPECIFIED);
final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(
adjMaxHeight, MeasureSpec.UNSPECIFIED);
view.measure(widthMeasureSpec, heightMeasureSpec);
// Align to the left or right.
@@ -700,10 +701,11 @@ class FastScroller {
final Rect container = mContainerRect;
final int containerWidth = container.width();
final int adjMaxWidth = containerWidth - marginLeft - marginRight;
final int adjMaxHeight = Math.max(0, container.height());
final int adjMaxWidth = Math.max(0, containerWidth - marginLeft - marginRight);
final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(adjMaxWidth, MeasureSpec.AT_MOST);
final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(container.height(),
MeasureSpec.UNSPECIFIED);
final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(
adjMaxHeight, MeasureSpec.UNSPECIFIED);
preview.measure(widthMeasureSpec, heightMeasureSpec);
// Align at the vertical center, 10% from the top.
@@ -766,10 +768,11 @@ class FastScroller {
final View track = mTrackImage;
final View thumb = mThumbImage;
final Rect container = mContainerRect;
final int maxWidth = container.width();
final int maxWidth = Math.max(0, container.width());
final int maxHeight = Math.max(0, container.height());
final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.AT_MOST);
final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(container.height(),
MeasureSpec.UNSPECIFIED);
final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(
maxHeight, MeasureSpec.UNSPECIFIED);
track.measure(widthMeasureSpec, heightMeasureSpec);
final int top;