summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Klaassen <justinklaassen@google.com>2014-12-08 19:15:51 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-12-08 19:15:51 +0000
commit75124fbaf11aa849721f314a04f7effbe18de662 (patch)
tree3abf23345937c35d52ca7d5b30b4641152a30d5f
parentd61b039d67720ac522ca0cf40d738baee3cfc326 (diff)
parent2320c8ac44e6851c76c233426fa6848906eaf38a (diff)
downloadCalculator-75124fbaf11aa849721f314a04f7effbe18de662.tar.gz
am 2320c8ac: am 1283ee74: Stop using RenderNodeAnimator callbacks
* commit '2320c8ac44e6851c76c233426fa6848906eaf38a': Stop using RenderNodeAnimator callbacks
-rw-r--r--src/com/android/calculator2/Calculator.java31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
index 5dd04bf..a2bcad1 100644
--- a/src/com/android/calculator2/Calculator.java
+++ b/src/com/android/calculator2/Calculator.java
@@ -86,7 +86,6 @@ public class Calculator extends Activity
case KeyEvent.KEYCODE_NUMPAD_ENTER:
case KeyEvent.KEYCODE_ENTER:
if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
- mCurrentButton = mEqualButton;
onEquals();
}
// ignore all other actions
@@ -114,10 +113,9 @@ public class Calculator extends Activity
private CalculatorEditText mResultEditText;
private ViewPager mPadViewPager;
private View mDeleteButton;
- private View mEqualButton;
private View mClearButton;
+ private View mEqualButton;
- private View mCurrentButton;
private Animator mCurrentAnimator;
@Override
@@ -156,9 +154,10 @@ public class Calculator extends Activity
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
- // If there's an animation in progress, cancel it first to ensure our state is up-to-date.
+ // If there's an animation in progress, end it immediately to ensure the state is
+ // up-to-date before it is serialized.
if (mCurrentAnimator != null) {
- mCurrentAnimator.cancel();
+ mCurrentAnimator.end();
}
super.onSaveInstanceState(outState);
@@ -212,16 +211,14 @@ public class Calculator extends Activity
public void onUserInteraction() {
super.onUserInteraction();
- // If there's an animation in progress, cancel it so the user interaction can be handled
- // immediately.
+ // If there's an animation in progress, end it immediately to ensure the state is
+ // up-to-date before the pending user interaction is handled.
if (mCurrentAnimator != null) {
- mCurrentAnimator.cancel();
+ mCurrentAnimator.end();
}
}
public void onButtonClick(View view) {
- mCurrentButton = view;
-
switch (view.getId()) {
case R.id.eq:
onEquals();
@@ -248,8 +245,6 @@ public class Calculator extends Activity
@Override
public boolean onLongClick(View view) {
- mCurrentButton = view;
-
if (view.getId() == R.id.del) {
onClear();
return true;
@@ -348,11 +343,11 @@ public class Calculator extends Activity
revealCenterX, revealCenterY, 0.0f, revealRadius);
revealAnimator.setDuration(
getResources().getInteger(android.R.integer.config_longAnimTime));
- revealAnimator.addListener(listener);
final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
alphaAnimator.setDuration(
getResources().getInteger(android.R.integer.config_mediumAnimTime));
+ alphaAnimator.addListener(listener);
final AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(revealAnimator).before(alphaAnimator);
@@ -374,9 +369,11 @@ public class Calculator extends Activity
return;
}
- reveal(mCurrentButton, R.color.calculator_accent_color, new AnimatorListenerAdapter() {
+ final View sourceView = mClearButton.getVisibility() == View.VISIBLE
+ ? mClearButton : mDeleteButton;
+ reveal(sourceView, R.color.calculator_accent_color, new AnimatorListenerAdapter() {
@Override
- public void onAnimationEnd(Animator animation) {
+ public void onAnimationStart(Animator animation) {
mFormulaEditText.getEditableText().clear();
}
});
@@ -389,9 +386,9 @@ public class Calculator extends Activity
return;
}
- reveal(mCurrentButton, R.color.calculator_error_color, new AnimatorListenerAdapter() {
+ reveal(mEqualButton, R.color.calculator_error_color, new AnimatorListenerAdapter() {
@Override
- public void onAnimationEnd(Animator animation) {
+ public void onAnimationStart(Animator animation) {
setState(CalculatorState.ERROR);
mResultEditText.setText(errorResourceId);
}