summaryrefslogtreecommitdiff
path: root/java/com/android/newbubble
diff options
context:
space:
mode:
authoryueg <yueg@google.com>2018-01-17 09:02:45 -0800
committerCopybara-Service <copybara-piper@google.com>2018-01-17 11:24:05 -0800
commit349ac6070be667aa73c0df3077f3662e46c26c36 (patch)
treebee70213d7b0a6b05a12b714aaf7c8faf66da584 /java/com/android/newbubble
parent594a9bfeaa1109f40d62c15bcfe3037077d2151d (diff)
Handle hiding bubble right after showing it.
If hide bubble right after showing it, we should cancel animation, remove view and set visibility to HIDEN. Otherwise we can't retrieve correct bubble status later, thus hide/show bubble unexpectedly. It at least fix some cases of IllegalArgumentException. Bug: 71746139 Test: NewBubbleTest PiperOrigin-RevId: 182222155 Change-Id: If020b83cfffd9c643fd6fe3d2879a05e5969281f
Diffstat (limited to 'java/com/android/newbubble')
-rw-r--r--java/com/android/newbubble/NewBubble.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/java/com/android/newbubble/NewBubble.java b/java/com/android/newbubble/NewBubble.java
index cb7a09469..65f7a0aab 100644
--- a/java/com/android/newbubble/NewBubble.java
+++ b/java/com/android/newbubble/NewBubble.java
@@ -103,7 +103,7 @@ public class NewBubble {
@NonNull
private NewBubbleInfo currentInfo;
- @Visibility private int visibility;
+ @VisibleForTesting @Visibility int visibility;
private boolean expanded;
private CharSequence textAfterShow;
private int collapseEndAction;
@@ -112,6 +112,7 @@ public class NewBubble {
private AnimatorSet collapseAnimatorSet;
private Integer overrideGravity;
@VisibleForTesting AnimatorSet exitAnimatorSet;
+ @VisibleForTesting AnimatorSet enterAnimatorSet;
private final int primaryIconMoveDistance;
private final int leftBoundary;
@@ -120,15 +121,15 @@ public class NewBubble {
/** Type of action after bubble collapse */
@Retention(RetentionPolicy.SOURCE)
@IntDef({CollapseEnd.NOTHING, CollapseEnd.HIDE})
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
- public @interface CollapseEnd {
+ private @interface CollapseEnd {
int NOTHING = 0;
int HIDE = 1;
}
@Retention(RetentionPolicy.SOURCE)
+ @VisibleForTesting
@IntDef({Visibility.ENTERING, Visibility.SHOWING, Visibility.EXITING, Visibility.HIDDEN})
- private @interface Visibility {
+ @interface Visibility {
int HIDDEN = 0;
int ENTERING = 1;
int SHOWING = 2;
@@ -440,7 +441,7 @@ public class NewBubble {
ObjectAnimator.ofFloat(viewHolder.getPrimaryAvatar(), "alpha", 1);
ObjectAnimator iconAlphaAnimator =
ObjectAnimator.ofFloat(viewHolder.getPrimaryIcon(), "alpha", 1);
- AnimatorSet enterAnimatorSet = new AnimatorSet();
+ enterAnimatorSet = new AnimatorSet();
enterAnimatorSet.playTogether(
scaleXAnimator, scaleYAnimator, avatarAlphaAnimator, iconAlphaAnimator);
enterAnimatorSet.setInterpolator(new OvershootInterpolator());
@@ -609,6 +610,14 @@ public class NewBubble {
// Make bubble non clickable to prevent further buggy actions
viewHolder.setChildClickable(false);
+ if (visibility == Visibility.ENTERING) {
+ enterAnimatorSet.removeAllListeners();
+ enterAnimatorSet.cancel();
+ enterAnimatorSet = null;
+ afterHiding.run();
+ return;
+ }
+
if (collapseAnimatorSet != null) {
collapseEndAction = CollapseEnd.HIDE;
return;