Merge "Fix stale transformations" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ea16efd52c
@@ -20,6 +20,7 @@ import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -194,7 +195,7 @@ public class ViewTransformationHelper implements TransformableView {
|
||||
for (Integer viewType : mTransformedViews.keySet()) {
|
||||
TransformState ownState = getCurrentState(viewType);
|
||||
if (ownState != null) {
|
||||
ownState.setVisible(visible);
|
||||
ownState.setVisible(visible, false /* force */);
|
||||
ownState.recycle();
|
||||
}
|
||||
}
|
||||
@@ -252,6 +253,19 @@ public class ViewTransformationHelper implements TransformableView {
|
||||
}
|
||||
}
|
||||
|
||||
public void resetTransformedView(View view) {
|
||||
TransformState state = TransformState.createFrom(view);
|
||||
state.setVisible(true /* visible */, true /* force */);
|
||||
state.recycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a set of all views are being transformed.
|
||||
*/
|
||||
public ArraySet<View> getAllTransformingViews() {
|
||||
return new ArraySet<>(mTransformedViews.values());
|
||||
}
|
||||
|
||||
public static abstract class CustomTransformation {
|
||||
/**
|
||||
* Transform a state to the given view
|
||||
|
||||
@@ -123,8 +123,9 @@ public class HeaderTransformState extends TransformState {
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
super.setVisible(visible);
|
||||
@Override
|
||||
public void setVisible(boolean visible, boolean force) {
|
||||
super.setVisible(visible, force);
|
||||
if (!(mTransformedView instanceof NotificationHeaderView)) {
|
||||
return;
|
||||
}
|
||||
@@ -132,11 +133,13 @@ public class HeaderTransformState extends TransformState {
|
||||
int childCount = header.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View headerChild = header.getChildAt(i);
|
||||
if (headerChild.getVisibility() == View.GONE) {
|
||||
if (!force && headerChild.getVisibility() == View.GONE) {
|
||||
continue;
|
||||
}
|
||||
headerChild.animate().cancel();
|
||||
headerChild.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
|
||||
if (headerChild.getVisibility() != View.GONE) {
|
||||
headerChild.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
if (headerChild == mExpandButton) {
|
||||
headerChild.setAlpha(visible ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
@@ -22,18 +22,17 @@ import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.util.ArraySet;
|
||||
import android.view.NotificationHeaderView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.android.systemui.Interpolators;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.ViewInvertHelper;
|
||||
import com.android.systemui.statusbar.ExpandableNotificationRow;
|
||||
@@ -92,12 +91,25 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper {
|
||||
@Override
|
||||
public void notifyContentUpdated(StatusBarNotification notification) {
|
||||
super.notifyContentUpdated(notification);
|
||||
|
||||
ArraySet<View> previousViews = mTransformationHelper.getAllTransformingViews();
|
||||
|
||||
// Reinspect the notification.
|
||||
resolveHeaderViews();
|
||||
updateInvertHelper();
|
||||
updateTransformedTypes();
|
||||
addRemainingTransformTypes();
|
||||
updateCropToPaddingForImageViews();
|
||||
|
||||
// We need to reset all views that are no longer transforming in case a view was previously
|
||||
// transformed, but now we decided to transform its container instead.
|
||||
ArraySet<View> currentViews = mTransformationHelper.getAllTransformingViews();
|
||||
for (int i = 0; i < previousViews.size(); i++) {
|
||||
View view = previousViews.valueAt(i);
|
||||
if (!currentViews.contains(view)) {
|
||||
mTransformationHelper.resetTransformedView(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -301,6 +301,9 @@ public class TransformState {
|
||||
}
|
||||
|
||||
public static void setClippingDeactivated(final View transformedView, boolean deactivated) {
|
||||
if (!(transformedView.getParent() instanceof ViewGroup)) {
|
||||
return;
|
||||
}
|
||||
ViewGroup view = (ViewGroup) transformedView.getParent();
|
||||
while (true) {
|
||||
ArraySet<View> clipSet = (ArraySet<View>) view.getTag(CLIP_CLIPPING_SET);
|
||||
@@ -456,12 +459,14 @@ public class TransformState {
|
||||
mTransformationEndY = UNDEFINED;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
if (mTransformedView.getVisibility() == View.GONE) {
|
||||
public void setVisible(boolean visible, boolean force) {
|
||||
if (!force && mTransformedView.getVisibility() == View.GONE) {
|
||||
return;
|
||||
}
|
||||
if (mTransformedView.getVisibility() != View.GONE) {
|
||||
mTransformedView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
mTransformedView.animate().cancel();
|
||||
mTransformedView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
|
||||
mTransformedView.setAlpha(visible ? 1.0f : 0.0f);
|
||||
resetTransformedView();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user