react-native-navigation的迁移库

TextChangeAnimator.java 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. package com.reactnativenavigation.views.element.animators;
  2. import android.animation.Animator;
  3. import android.graphics.Point;
  4. import android.widget.TextView;
  5. import com.facebook.react.views.text.ReactTextView;
  6. import com.reactnativenavigation.utils.ViewUtils;
  7. import com.reactnativenavigation.views.element.Element;
  8. import com.shazam.android.widget.text.reflow.ReflowTextAnimatorHelper;
  9. import static com.reactnativenavigation.utils.TextViewUtils.getTextSize;
  10. public class TextChangeAnimator extends PropertyAnimatorCreator<ReactTextView> {
  11. public TextChangeAnimator(Element from, Element to) {
  12. super(from, to);
  13. }
  14. @Override
  15. protected boolean shouldAnimateProperty(ReactTextView fromChild, ReactTextView toChild) {
  16. Point fromXy = ViewUtils.getLocationOnScreen(from.getChild());
  17. Point toXy = ViewUtils.getLocationOnScreen(to.getChild());
  18. return getTextSize(fromChild) != getTextSize(toChild) ||
  19. !fromXy.equals(toXy.x, toXy.y);
  20. }
  21. @Override
  22. public Animator create() {
  23. return new ReflowTextAnimatorHelper
  24. .Builder((TextView) from.getChild(), (TextView) to.getChild())
  25. .calculateDuration(false)
  26. .buildAnimator();
  27. }
  28. }