List of usage examples for android.animation AnimatorSet AnimatorSet
public AnimatorSet()
From source file:com.customdatepicker.time.RadialPickerLayout.java
/** * Set either seconds, minutes or hours as showing. * @param animate True to animate the transition, false to show with no animation. *///from w ww .jav a 2 s . c om public void setCurrentItemShowing(int index, boolean animate) { if (index != HOUR_INDEX && index != MINUTE_INDEX && index != SECOND_INDEX) { Log.e(TAG, "TimePicker does not support view at index " + index); return; } int lastIndex = getCurrentItemShowing(); mCurrentItemShowing = index; reselectSelector(getTime(), true, index); if (animate && (index != lastIndex)) { ObjectAnimator[] anims = new ObjectAnimator[4]; if (index == MINUTE_INDEX && lastIndex == HOUR_INDEX) { anims[0] = mHourRadialTextsView.getDisappearAnimator(); anims[1] = mHourRadialSelectorView.getDisappearAnimator(); anims[2] = mMinuteRadialTextsView.getReappearAnimator(); anims[3] = mMinuteRadialSelectorView.getReappearAnimator(); } else if (index == HOUR_INDEX && lastIndex == MINUTE_INDEX) { anims[0] = mHourRadialTextsView.getReappearAnimator(); anims[1] = mHourRadialSelectorView.getReappearAnimator(); anims[2] = mMinuteRadialTextsView.getDisappearAnimator(); anims[3] = mMinuteRadialSelectorView.getDisappearAnimator(); } else if (index == MINUTE_INDEX && lastIndex == SECOND_INDEX) { anims[0] = mSecondRadialTextsView.getDisappearAnimator(); anims[1] = mSecondRadialSelectorView.getDisappearAnimator(); anims[2] = mMinuteRadialTextsView.getReappearAnimator(); anims[3] = mMinuteRadialSelectorView.getReappearAnimator(); } else if (index == HOUR_INDEX && lastIndex == SECOND_INDEX) { anims[0] = mSecondRadialTextsView.getDisappearAnimator(); anims[1] = mSecondRadialSelectorView.getDisappearAnimator(); anims[2] = mHourRadialTextsView.getReappearAnimator(); anims[3] = mHourRadialSelectorView.getReappearAnimator(); } else if (index == SECOND_INDEX && lastIndex == MINUTE_INDEX) { anims[0] = mSecondRadialTextsView.getReappearAnimator(); anims[1] = mSecondRadialSelectorView.getReappearAnimator(); anims[2] = mMinuteRadialTextsView.getDisappearAnimator(); anims[3] = mMinuteRadialSelectorView.getDisappearAnimator(); } else if (index == SECOND_INDEX && lastIndex == HOUR_INDEX) { anims[0] = mSecondRadialTextsView.getReappearAnimator(); anims[1] = mSecondRadialSelectorView.getReappearAnimator(); anims[2] = mHourRadialTextsView.getDisappearAnimator(); anims[3] = mHourRadialSelectorView.getDisappearAnimator(); } if (anims[0] != null && anims[1] != null && anims[2] != null && anims[3] != null) { if (mTransition != null && mTransition.isRunning()) { mTransition.end(); } mTransition = new AnimatorSet(); mTransition.playTogether(anims); mTransition.start(); } else { transitionWithoutAnimation(index); } } else { transitionWithoutAnimation(index); } }
From source file:ir.besteveryeverapp.ui.ActionBar.BottomSheet.java
public void dismissWithButtonClick(final int item) { if (dismissed) { return;/*from w w w .j av a 2 s . c o m*/ } dismissed = true; cancelSheetAnimation(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationY", containerView.getMeasuredHeight() + AndroidUtilities.dp(10)), ObjectAnimator.ofInt(backDrawable, "alpha", 0)); animatorSet.setDuration(180); animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; if (onClickListener != null) { onClickListener.onClick(BottomSheet.this, item); } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { BottomSheet.super.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); } } @Override public void onAnimationCancel(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; }
From source file:com.jarklee.materialdatetimepicker.time.RadialPickerLayout.java
/** * Set either seconds, minutes or hours as showing. * * @param animate True to animate the transition, false to show with no animation. *//*from www. java2 s . c om*/ public void setCurrentItemShowing(int index, boolean animate) { if (index != HOUR_INDEX && index != MINUTE_INDEX && index != SECOND_INDEX) { Log.e(TAG, "TimePicker does not support view at index " + index); return; } int lastIndex = getCurrentItemShowing(); mCurrentItemShowing = index; if (animate && (index != lastIndex)) { ObjectAnimator[] anims = new ObjectAnimator[4]; if (index == MINUTE_INDEX && lastIndex == HOUR_INDEX) { anims[0] = mHourRadialTextsView.getDisappearAnimator(); anims[1] = mHourRadialSelectorView.getDisappearAnimator(); anims[2] = mMinuteRadialTextsView.getReappearAnimator(); anims[3] = mMinuteRadialSelectorView.getReappearAnimator(); } else if (index == HOUR_INDEX && lastIndex == MINUTE_INDEX) { anims[0] = mHourRadialTextsView.getReappearAnimator(); anims[1] = mHourRadialSelectorView.getReappearAnimator(); anims[2] = mMinuteRadialTextsView.getDisappearAnimator(); anims[3] = mMinuteRadialSelectorView.getDisappearAnimator(); } else if (index == MINUTE_INDEX && lastIndex == SECOND_INDEX) { anims[0] = mSecondRadialTextsView.getDisappearAnimator(); anims[1] = mSecondRadialSelectorView.getDisappearAnimator(); anims[2] = mMinuteRadialTextsView.getReappearAnimator(); anims[3] = mMinuteRadialSelectorView.getReappearAnimator(); } else if (index == HOUR_INDEX && lastIndex == SECOND_INDEX) { anims[0] = mSecondRadialTextsView.getDisappearAnimator(); anims[1] = mSecondRadialSelectorView.getDisappearAnimator(); anims[2] = mHourRadialTextsView.getReappearAnimator(); anims[3] = mHourRadialSelectorView.getReappearAnimator(); } else if (index == SECOND_INDEX && lastIndex == MINUTE_INDEX) { anims[0] = mSecondRadialTextsView.getReappearAnimator(); anims[1] = mSecondRadialSelectorView.getReappearAnimator(); anims[2] = mMinuteRadialTextsView.getDisappearAnimator(); anims[3] = mMinuteRadialSelectorView.getDisappearAnimator(); } else if (index == SECOND_INDEX && lastIndex == HOUR_INDEX) { anims[0] = mSecondRadialTextsView.getReappearAnimator(); anims[1] = mSecondRadialSelectorView.getReappearAnimator(); anims[2] = mHourRadialTextsView.getDisappearAnimator(); anims[3] = mHourRadialSelectorView.getDisappearAnimator(); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (mTransition != null && mTransition.isRunning()) { mTransition.end(); } mTransition = new AnimatorSet(); mTransition.playTogether(anims); mTransition.start(); } } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { int hourAlpha = (index == HOUR_INDEX) ? 1 : 0; int minuteAlpha = (index == MINUTE_INDEX) ? 1 : 0; int secondAlpha = (index == SECOND_INDEX) ? 1 : 0; mHourRadialTextsView.setAlpha(hourAlpha); mHourRadialSelectorView.setAlpha(hourAlpha); mMinuteRadialTextsView.setAlpha(minuteAlpha); mMinuteRadialSelectorView.setAlpha(minuteAlpha); mSecondRadialTextsView.setAlpha(secondAlpha); mSecondRadialSelectorView.setAlpha(secondAlpha); } } }
From source file:com.saarang.samples.apps.iosched.ui.BaseActivity.java
private void setupAccountBoxToggle() { int selfItem = getSelfNavDrawerItem(); if (mDrawerLayout == null || selfItem == NAVDRAWER_ITEM_INVALID) { // this Activity does not have a nav drawer return;/*from w w w . j av a 2 s .c om*/ } mExpandAccountBoxIndicator.setImageResource( mAccountBoxExpanded ? com.saarang.samples.apps.iosched.R.drawable.ic_drawer_accounts_collapse : com.saarang.samples.apps.iosched.R.drawable.ic_drawer_accounts_expand); int hideTranslateY = -mAccountListContainer.getHeight() / 4; // last 25% of animation if (mAccountBoxExpanded && mAccountListContainer.getTranslationY() == 0) { // initial setup mAccountListContainer.setAlpha(0); mAccountListContainer.setTranslationY(hideTranslateY); } AnimatorSet set = new AnimatorSet(); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mDrawerItemsListContainer.setVisibility(mAccountBoxExpanded ? View.INVISIBLE : View.VISIBLE); mAccountListContainer.setVisibility(mAccountBoxExpanded ? View.VISIBLE : View.INVISIBLE); } @Override public void onAnimationCancel(Animator animation) { onAnimationEnd(animation); } }); if (mAccountBoxExpanded) { mAccountListContainer.setVisibility(View.VISIBLE); AnimatorSet subSet = new AnimatorSet(); subSet.playTogether( ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 1) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, 0) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION)); set.playSequentially(ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 0) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), subSet); set.start(); } else { mDrawerItemsListContainer.setVisibility(View.VISIBLE); AnimatorSet subSet = new AnimatorSet(); subSet.playTogether( ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 0) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, hideTranslateY) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION)); set.playSequentially(subSet, ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 1) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION)); set.start(); } set.start(); }
From source file:com.b44t.ui.ActionBar.BottomSheet.java
public void dismissWithButtonClick(final int item) { if (dismissed) { return;// w w w . j a v a 2 s . c om } dismissed = true; cancelSheetAnimation(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationY", containerView.getMeasuredHeight() + AndroidUtilities.dp(10)), ObjectAnimator.ofInt(backDrawable, "alpha", 0)); animatorSet.setDuration(180); animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; if (onClickListener != null) { onClickListener.onClick(BottomSheet.this, item); } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { BottomSheet.super.dismiss(); } catch (Exception e) { FileLog.e("messenger", e); } } }); } } @Override public void onAnimationCancel(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; }
From source file:org.telegram.ui.ActionBar.ActionBarLayout.java
public boolean presentFragment(final BaseFragment fragment, final boolean removeLast, boolean forceWithoutAnimation, boolean check) { if (checkTransitionAnimation() || delegate != null && check && !delegate.needPresentFragment(fragment, removeLast, forceWithoutAnimation, this) || !fragment.onFragmentCreate()) { return false; }/*from w w w. j a va 2 s . co m*/ if (parentActivity.getCurrentFocus() != null) { AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus()); } boolean needAnimation = !forceWithoutAnimation && parentActivity .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true); final BaseFragment currentFragment = !fragmentsStack.isEmpty() ? fragmentsStack.get(fragmentsStack.size() - 1) : null; fragment.setParentLayout(this); View fragmentView = fragment.fragmentView; if (fragmentView == null) { fragmentView = fragment.createView(parentActivity); } else { ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { parent.removeView(fragmentView); } } if (fragment.actionBar != null && fragment.actionBar.getAddToContainer()) { if (removeActionBarExtraHeight) { fragment.actionBar.setOccupyStatusBar(false); } ViewGroup parent = (ViewGroup) fragment.actionBar.getParent(); if (parent != null) { parent.removeView(fragment.actionBar); } containerViewBack.addView(fragment.actionBar); fragment.actionBar.setTitleOverlayText(titleOverlayText); } containerViewBack.addView(fragmentView); ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; fragmentView.setLayoutParams(layoutParams); fragmentsStack.add(fragment); fragment.onResume(); currentActionBar = fragment.actionBar; if (!fragment.hasOwnBackground && fragmentView.getBackground() == null) { fragmentView.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.background)); } LinearLayoutContainer temp = containerView; containerView = containerViewBack; containerViewBack = temp; containerView.setVisibility(View.VISIBLE); setInnerTranslationX(0); bringChildToFront(containerView); if (!needAnimation) { presentFragmentInternalRemoveOld(removeLast, currentFragment); if (backgroundView != null) { backgroundView.setVisibility(VISIBLE); } } if (needAnimation) { if (useAlphaAnimations && fragmentsStack.size() == 1) { presentFragmentInternalRemoveOld(removeLast, currentFragment); transitionAnimationStartTime = System.currentTimeMillis(); transitionAnimationInProgress = true; onOpenAnimationEndRunnable = new Runnable() { @Override public void run() { fragment.onTransitionAnimationEnd(true, false); fragment.onBecomeFullyVisible(); } }; ArrayList<Animator> animators = new ArrayList<>(); animators.add(ObjectAnimator.ofFloat(this, "alpha", 0.0f, 1.0f)); if (backgroundView != null) { backgroundView.setVisibility(VISIBLE); animators.add(ObjectAnimator.ofFloat(backgroundView, "alpha", 0.0f, 1.0f)); } fragment.onTransitionAnimationStart(true, false); currentAnimation = new AnimatorSet(); currentAnimation.playTogether(animators); currentAnimation.setInterpolator(accelerateDecelerateInterpolator); currentAnimation.setDuration(200); currentAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { onAnimationEndCheck(false); } }); currentAnimation.start(); } else { transitionAnimationStartTime = System.currentTimeMillis(); transitionAnimationInProgress = true; onOpenAnimationEndRunnable = new Runnable() { @Override public void run() { if (Build.VERSION.SDK_INT > 15) { containerView.setLayerType(LAYER_TYPE_NONE, null); containerViewBack.setLayerType(LAYER_TYPE_NONE, null); } presentFragmentInternalRemoveOld(removeLast, currentFragment); fragment.onTransitionAnimationEnd(true, false); fragment.onBecomeFullyVisible(); containerView.setTranslationX(0); } }; fragment.onTransitionAnimationStart(true, false); AnimatorSet animation = fragment.onCustomTransitionAnimation(true, new Runnable() { @Override public void run() { onAnimationEndCheck(false); } }); if (animation == null) { containerView.setAlpha(0.0f); containerView.setTranslationX(48.0f); if (containerView.isKeyboardVisible || containerViewBack.isKeyboardVisible) { waitingForKeyboardCloseRunnable = new Runnable() { @Override public void run() { if (waitingForKeyboardCloseRunnable != this) { return; } startLayoutAnimation(true, true); } }; AndroidUtilities.runOnUIThread(waitingForKeyboardCloseRunnable, 200); } else if (fragment.needDelayOpenAnimation()) { delayedOpenAnimationRunnable = new Runnable() { @Override public void run() { if (delayedOpenAnimationRunnable != this) { return; } delayedOpenAnimationRunnable = null; startLayoutAnimation(true, true); } }; AndroidUtilities.runOnUIThread(delayedOpenAnimationRunnable, 200); } else { startLayoutAnimation(true, true); } } else { if (Build.VERSION.SDK_INT > 15) { //containerView.setLayerType(LAYER_TYPE_HARDWARE, null); //containerViewBack.setLayerType(LAYER_TYPE_HARDWARE, null); } containerView.setAlpha(1.0f); containerView.setTranslationX(0.0f); currentAnimation = animation; } } } else { if (backgroundView != null) { backgroundView.setAlpha(1.0f); backgroundView.setVisibility(VISIBLE); } fragment.onTransitionAnimationStart(true, false); fragment.onTransitionAnimationEnd(true, false); fragment.onBecomeFullyVisible(); } return true; }
From source file:org.michaelbel.bottomsheet.BottomSheet.java
private void startOpenAnimation() { containerView.setVisibility(View.VISIBLE); if (Build.VERSION.SDK_INT >= 20) { container.setLayerType(View.LAYER_TYPE_HARDWARE, null); }//w w w . j a v a 2 s . com containerView.setTranslationY(containerView.getMeasuredHeight()); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationY", 0), ObjectAnimator.ofInt(backDrawable, "alpha", 51)); animatorSet.setDuration(200); animatorSet.setStartDelay(20); animatorSet.setInterpolator(new DecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; container.setLayerType(View.LAYER_TYPE_NONE, null); } } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; }
From source file:ir.besteveryeverapp.ui.ActionBar.BottomSheet.java
@Override public void dismiss() { if (dismissed) { return;/*ww w . j a v a 2 s . c om*/ } dismissed = true; cancelSheetAnimation(); if (!allowCustomAnimation || !onCustomCloseAnimation()) { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationY", containerView.getMeasuredHeight() + AndroidUtilities.dp(10)), ObjectAnimator.ofInt(backDrawable, "alpha", 0)); if (useFastDismiss) { int height = containerView.getMeasuredHeight(); animatorSet.setDuration( Math.max(60, (int) (180 * (height - containerView.getTranslationY()) / (float) height))); useFastDismiss = false; } else { animatorSet.setDuration(180); } animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { dismissInternal(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); } } @Override public void onAnimationCancel(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; } }
From source file:ir.besteveryeverapp.ui.Components.PasscodeView.java
private void processDone(boolean fingerprint) { if (!fingerprint) { String password = ""; if (UserConfig.passcodeType == 0) { password = passwordEditText2.getString(); } else if (UserConfig.passcodeType == 1) { password = passwordEditText.getText().toString(); }// w w w . j av a 2 s.c o m if (password.length() == 0) { onPasscodeError(); return; } if (!UserConfig.checkPasscode(password)) { passwordEditText.setText(""); passwordEditText2.eraseAllCharacters(true); onPasscodeError(); return; } } passwordEditText.clearFocus(); AndroidUtilities.hideKeyboard(passwordEditText); AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.setDuration(200); AnimatorSet.playTogether(ObjectAnimator.ofFloat(this, "translationY", AndroidUtilities.dp(20)), ObjectAnimator.ofFloat(this, "alpha", AndroidUtilities.dp(0.0f))); AnimatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { setVisibility(View.GONE); } }); AnimatorSet.start(); UserConfig.appLocked = false; UserConfig.saveConfig(false); NotificationCenter.getInstance().postNotificationName(NotificationCenter.didSetPasscode); setOnTouchListener(null); if (delegate != null) { delegate.didAcceptedPassword(); } }
From source file:com.android.calculator2.Calculator.java
private void onResult(boolean animate) { // Calculate the textSize that would be used to display the result in the formula. // For scrollable results just use the minimum textSize to maximize the number of digits // that are visible on screen. float textSize = mFormulaText.getMinimumTextSize(); if (!mResultText.isScrollable()) { textSize = mFormulaText.getVariableTextSize(mResultText.getText().toString()); }/*from w w w.j a v a 2s.co m*/ // Scale the result to match the calculated textSize, minimizing the jump-cut transition // when a result is reused in a subsequent expression. final float resultScale = textSize / mResultText.getTextSize(); // Set the result's pivot to match its gravity. mResultText.setPivotX(mResultText.getWidth() - mResultText.getPaddingRight()); mResultText.setPivotY(mResultText.getHeight() - mResultText.getPaddingBottom()); // Calculate the necessary translations so the result takes the place of the formula and // the formula moves off the top of the screen. final float resultTranslationY = (mFormulaText.getBottom() - mResultText.getBottom()) - (mFormulaText.getPaddingBottom() - mResultText.getPaddingBottom()); final float formulaTranslationY = -mFormulaText.getBottom(); // Change the result's textColor to match the formula. final int formulaTextColor = mFormulaText.getCurrentTextColor(); if (animate) { mResultText.announceForAccessibility(getResources().getString(R.string.desc_eq)); mResultText.announceForAccessibility(mResultText.getText()); setState(CalculatorState.ANIMATE); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofPropertyValuesHolder(mResultText, PropertyValuesHolder.ofFloat(View.SCALE_X, resultScale), PropertyValuesHolder.ofFloat(View.SCALE_Y, resultScale), PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, resultTranslationY)), ObjectAnimator.ofArgb(mResultText, TEXT_COLOR, formulaTextColor), ObjectAnimator.ofFloat(mFormulaText, View.TRANSLATION_Y, formulaTranslationY)); animatorSet.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setState(CalculatorState.RESULT); mCurrentAnimator = null; } }); mCurrentAnimator = animatorSet; animatorSet.start(); } else /* No animation desired; get there fast, e.g. when restarting */ { mResultText.setScaleX(resultScale); mResultText.setScaleY(resultScale); mResultText.setTranslationY(resultTranslationY); mResultText.setTextColor(formulaTextColor); mFormulaText.setTranslationY(formulaTranslationY); setState(CalculatorState.RESULT); } }