diff options
author | Selim Cinek <cinek@google.com> | 2014-10-31 15:23:13 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2014-10-31 15:23:13 +0000 |
commit | 067d8877069930dcfcd0dad2ef4f6bdbecd0b306 (patch) | |
tree | a6f608de9516da56e4ae703149cc7f6a5e29de94 /packages/SystemUI/src/com/android/systemui/statusbar | |
parent | 1250aa31af2741f03756bb83a1a9de68af6d686f (diff) | |
parent | 0f22af9955f23a02ff2413556823f5708d8d967b (diff) | |
download | frameworks_base-067d8877069930dcfcd0dad2ef4f6bdbecd0b306.zip frameworks_base-067d8877069930dcfcd0dad2ef4f6bdbecd0b306.tar.gz frameworks_base-067d8877069930dcfcd0dad2ef4f6bdbecd0b306.tar.bz2 |
am aed002f8: Merge "Fixed a bug with the notification appear animation" into lmp-mr1-dev
automerge: 0f22af9
* commit '0f22af9955f23a02ff2413556823f5708d8d967b':
Fixed a bug with the notification appear animation
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(); } |