summaryrefslogtreecommitdiff
path: root/src/com/android/calculator2/Calculator.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/calculator2/Calculator.java')
-rw-r--r--src/com/android/calculator2/Calculator.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
index 392447c..81ab1f6 100644
--- a/src/com/android/calculator2/Calculator.java
+++ b/src/com/android/calculator2/Calculator.java
@@ -535,9 +535,6 @@ public class Calculator extends Activity
}
public boolean isResultLayout() {
- if (mCurrentState == CalculatorState.ANIMATE) {
- throw new AssertionError("impossible state");
- }
// Note that ERROR has INPUT, not RESULT layout.
return mCurrentState == CalculatorState.INIT_FOR_RESULT
|| mCurrentState == CalculatorState.RESULT;
@@ -1339,7 +1336,14 @@ public class Calculator extends Activity
*/
private boolean prepareForHistory() {
if (mCurrentState == CalculatorState.ANIMATE) {
- throw new AssertionError("onUserInteraction should have ended animation");
+ // End the current animation and signal that preparation has failed.
+ // onUserInteraction is unreliable and onAnimationEnd() is asynchronous, so we
+ // aren't guaranteed to be out of the ANIMATE state by the time prepareForHistory is
+ // called.
+ if (mCurrentAnimator != null) {
+ mCurrentAnimator.end();
+ }
+ return false;
} else if (mCurrentState == CalculatorState.EVALUATE) {
// Cancel current evaluation
cancelIfEvaluating(true /* quiet */ );
@@ -1366,12 +1370,15 @@ public class Calculator extends Activity
}
private void showHistoryFragment() {
- final FragmentManager manager = getFragmentManager();
- if (manager == null || manager.isDestroyed()) {
+ if (getHistoryFragment() != null) {
+ // If the fragment already exists, do nothing.
return;
}
- if (getHistoryFragment() != null || !prepareForHistory()) {
+ final FragmentManager manager = getFragmentManager();
+ if (manager == null || manager.isDestroyed() || !prepareForHistory()) {
+ // If the history fragment can not be shown, close the draglayout.
+ mDragLayout.setClosed();
return;
}