Merge "Fixed a bug where systemUI would crash when swiping notifications"

This commit is contained in:
Selim Cinek
2015-12-12 00:00:27 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 3 deletions

View File

@@ -17,6 +17,7 @@
package com.android.systemui.statusbar;
import android.content.Context;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
@@ -44,6 +45,7 @@ public abstract class ExpandableView extends FrameLayout {
private static Rect mClipRect = new Rect();
private boolean mWillBeGone;
private int mMinClipTopAmount = 0;
private boolean mMeasuredTooHigh;
public ExpandableView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -54,12 +56,13 @@ public abstract class ExpandableView extends FrameLayout {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
boolean limitViewHeight = shouldLimitViewHeight();
final int givenSize = MeasureSpec.getSize(heightMeasureSpec);
int ownMaxHeight = limitViewHeight ? mMaxViewHeight : Integer.MAX_VALUE;
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
boolean hasFixedHeight = heightMode == MeasureSpec.EXACTLY;
if (hasFixedHeight) {
// We have a height set in our layout, so we want to be at most as big as given
ownMaxHeight = Math.min(MeasureSpec.getSize(heightMeasureSpec), ownMaxHeight);
ownMaxHeight = Math.min(givenSize, ownMaxHeight);
}
int newHeightSpec = MeasureSpec.makeMeasureSpec(ownMaxHeight, MeasureSpec.AT_MOST);
int maxChildHeight = 0;
@@ -97,6 +100,7 @@ public abstract class ExpandableView extends FrameLayout {
mMatchParentViews.clear();
int width = MeasureSpec.getSize(widthMeasureSpec);
setMeasuredDimension(width, ownHeight);
mMeasuredTooHigh = heightMode != MeasureSpec.UNSPECIFIED && ownHeight > givenSize;
}
protected boolean shouldLimitViewHeight() {
@@ -384,6 +388,18 @@ public abstract class ExpandableView extends FrameLayout {
mMinClipTopAmount = minClipTopAmount;
}
@Override
public void setLayerType(int layerType, Paint paint) {
if (hasOverlappingRendering()) {
super.setLayerType(layerType, paint);
}
}
@Override
public boolean hasOverlappingRendering() {
return super.hasOverlappingRendering() && !mMeasuredTooHigh;
}
/**
* A listener notifying when {@link #getActualHeight} changes.
*/

View File

@@ -90,7 +90,7 @@ public class NotificationChildrenContainer extends ViewGroup {
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int childCount = mChildren.size();
int childCount = Math.min(mChildren.size(), NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED);
for (int i = 0; i < childCount; i++) {
View child = mChildren.get(i);
if (child.getVisibility() == View.GONE) {
@@ -118,7 +118,7 @@ public class NotificationChildrenContainer extends ViewGroup {
int newHeightSpec = MeasureSpec.makeMeasureSpec(ownMaxHeight, MeasureSpec.AT_MOST);
int dividerHeightSpec = MeasureSpec.makeMeasureSpec(mDividerHeight, MeasureSpec.EXACTLY);
int height = mNotificationHeaderHeight + mNotificatonTopPadding;
int childCount = mChildren.size();
int childCount = Math.min(mChildren.size(), NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED);
for (int i = 0; i < childCount; i++) {
View child = mChildren.get(i);
child.measure(widthMeasureSpec, newHeightSpec);