Fix bug 2838426 - timing issue with starting/finishing action bar context modes
Change-Id: Ie29b0bea96be02675a2104f07c912700c2823abc
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 6cf455c..c6be7c2 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -70,6 +70,8 @@
private int mContextDisplayMode;
+ private boolean mClosingContext;
+
final Handler mHandler = new Handler();
final Runnable mCloseContext = new Runnable() {
public void run() {
@@ -77,6 +79,7 @@
if (mLowerContextView != null) {
mLowerContextView.removeAllViews();
}
+ mClosingContext = false;
}
};
@@ -195,6 +198,14 @@
if (mContextMode != null) {
mContextMode.finish();
}
+
+ // Don't wait for the close context mode animation to finish.
+ if (mClosingContext) {
+ mAnimatorView.clearAnimation();
+ mHandler.removeCallbacks(mCloseContext);
+ mCloseContext.run();
+ }
+
mContextMode = new ContextMode(callback);
if (callback.onCreateContextMode(mContextMode, mContextMode.getMenu())) {
mContextMode.invalidate();
@@ -344,6 +355,7 @@
mAnimatorView.setDisplayedChild(NORMAL_VIEW);
// Clear out the context mode views after the animation finishes
+ mClosingContext = true;
mHandler.postDelayed(mCloseContext, mAnimatorView.getOutAnimation().getDuration());
if (mLowerContextView != null && mLowerContextView.getVisibility() != View.GONE) {