diff options
author | Selim Cinek <cinek@google.com> | 2014-10-31 00:12:56 +0100 |
---|---|---|
committer | Selim Cinek <cinek@google.com> | 2014-10-31 16:11:53 +0100 |
commit | bb3d1cf11dc76543cac368486bc42efcd21d5e54 (patch) | |
tree | 348e9f987f293d694ce825a5fa084f916acff222 /packages/SystemUI/src/com/android/systemui/statusbar | |
parent | 1d59af45f699f11ee559c38698369fd6d159e87a (diff) | |
download | frameworks_base-bb3d1cf11dc76543cac368486bc42efcd21d5e54.zip frameworks_base-bb3d1cf11dc76543cac368486bc42efcd21d5e54.tar.gz frameworks_base-bb3d1cf11dc76543cac368486bc42efcd21d5e54.tar.bz2 |
Fixed a bug with the notification appear animation
This happened since the switch animation was running
even when invisible. This is fixed now and only
runs when the view is actually shown.
Bug: 18168562
Change-Id: I7fa2254411d249c23cd623cdff64524729f0817c
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java | 2 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java | 42 |
2 files changed, 40 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index 556c423..62dfeeb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -23,10 +23,8 @@ import android.graphics.drawable.Drawable; import android.service.notification.StatusBarNotification; import android.util.AttributeSet; import android.view.View; -import android.view.ViewGroup; import android.view.ViewStub; import android.view.accessibility.AccessibilityEvent; - import android.widget.ImageView; import com.android.systemui.R; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java index 502490f..9b11f9b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java @@ -27,11 +27,11 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.View; +import android.view.ViewTreeObserver; import android.view.animation.Interpolator; import android.view.animation.LinearInterpolator; import android.widget.FrameLayout; import android.widget.ImageView; - import com.android.systemui.R; /** @@ -60,6 +60,16 @@ public class NotificationContentView extends FrameLayout { private boolean mDark; private final Paint mFadePaint = new Paint(); + private boolean mAnimate; + private ViewTreeObserver.OnPreDrawListener mEnableAnimationPredrawListener + = new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + mAnimate = true; + getViewTreeObserver().removeOnPreDrawListener(this); + return true; + } + }; public NotificationContentView(Context context, AttributeSet attrs) { super(context, attrs); @@ -73,6 +83,12 @@ public class NotificationContentView extends FrameLayout { updateClipping(); } + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + updateVisibility(); + } + public void reset() { if (mContractedChild != null) { mContractedChild.animate().cancel(); @@ -117,9 +133,31 @@ public class NotificationContentView extends FrameLayout { selectLayout(false /* animate */, true /* force */); } + @Override + protected void onVisibilityChanged(View changedView, int visibility) { + super.onVisibilityChanged(changedView, visibility); + updateVisibility(); + } + + private void updateVisibility() { + setVisible(isShown()); + } + + private void setVisible(final boolean isVisible) { + if (isVisible) { + + // We only animate if we are drawn at least once, otherwise the view might animate when + // it's shown the first time + getViewTreeObserver().addOnPreDrawListener(mEnableAnimationPredrawListener); + } else { + getViewTreeObserver().removeOnPreDrawListener(mEnableAnimationPredrawListener); + mAnimate = false; + } + } + public void setActualHeight(int actualHeight) { mActualHeight = actualHeight; - selectLayout(true /* animate */, false /* force */); + selectLayout(mAnimate /* animate */, false /* force */); updateClipping(); } |