Loading core/java/android/widget/TextViewTranslationCallback.java +12 −6 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { originalTranslationMethod); } final TransformationMethod transformation = mTranslationTransformation; runWithAnimation( runChangeTextWithAnimationIfNeeded( (TextView) view, () -> { mIsShowingTranslation = true; Loading Loading @@ -122,7 +122,7 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { if (mTranslationTransformation != null) { final TransformationMethod transformation = mTranslationTransformation.getOriginalTransformationMethod(); runWithAnimation( runChangeTextWithAnimationIfNeeded( (TextView) view, () -> { mIsShowingTranslation = false; Loading Loading @@ -232,10 +232,16 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { * Applies a simple text alpha animation when toggling between original and translated text. The * text is fully faded out, then swapped to the new text, then the fading is reversed. * * @param runnable the operation to run on the view after the text is faded out, to change to * displaying the original or translated text. * @param changeTextRunnable the operation to run on the view after the text is faded out, to * change to displaying the original or translated text. */ private void runWithAnimation(TextView view, Runnable runnable) { private void runChangeTextWithAnimationIfNeeded(TextView view, Runnable changeTextRunnable) { boolean areAnimatorsEnabled = ValueAnimator.areAnimatorsEnabled(); if (!areAnimatorsEnabled) { // The animation is disabled, just change display text changeTextRunnable.run(); return; } if (mAnimator != null) { mAnimator.end(); // Note: mAnimator is now null; do not use again here. Loading Loading @@ -269,7 +275,7 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { @Override public void onAnimationRepeat(Animator animation) { runnable.run(); changeTextRunnable.run(); } }); mAnimator.start(); Loading Loading
core/java/android/widget/TextViewTranslationCallback.java +12 −6 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { originalTranslationMethod); } final TransformationMethod transformation = mTranslationTransformation; runWithAnimation( runChangeTextWithAnimationIfNeeded( (TextView) view, () -> { mIsShowingTranslation = true; Loading Loading @@ -122,7 +122,7 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { if (mTranslationTransformation != null) { final TransformationMethod transformation = mTranslationTransformation.getOriginalTransformationMethod(); runWithAnimation( runChangeTextWithAnimationIfNeeded( (TextView) view, () -> { mIsShowingTranslation = false; Loading Loading @@ -232,10 +232,16 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { * Applies a simple text alpha animation when toggling between original and translated text. The * text is fully faded out, then swapped to the new text, then the fading is reversed. * * @param runnable the operation to run on the view after the text is faded out, to change to * displaying the original or translated text. * @param changeTextRunnable the operation to run on the view after the text is faded out, to * change to displaying the original or translated text. */ private void runWithAnimation(TextView view, Runnable runnable) { private void runChangeTextWithAnimationIfNeeded(TextView view, Runnable changeTextRunnable) { boolean areAnimatorsEnabled = ValueAnimator.areAnimatorsEnabled(); if (!areAnimatorsEnabled) { // The animation is disabled, just change display text changeTextRunnable.run(); return; } if (mAnimator != null) { mAnimator.end(); // Note: mAnimator is now null; do not use again here. Loading Loading @@ -269,7 +275,7 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { @Override public void onAnimationRepeat(Animator animation) { runnable.run(); changeTextRunnable.run(); } }); mAnimator.start(); Loading