react-native-navigation的迁移库

TextColorAnimator.java 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. package com.reactnativenavigation.views.element.animators;
  2. import android.animation.Animator;
  3. import android.animation.ObjectAnimator;
  4. import android.widget.TextView;
  5. import com.facebook.react.views.text.ReactTextView;
  6. import com.reactnativenavigation.utils.ColorUtils;
  7. import com.reactnativenavigation.utils.TextViewUtils;
  8. import com.reactnativenavigation.views.element.Element;
  9. import static com.reactnativenavigation.utils.TextViewUtils.getTextColor;
  10. public class TextColorAnimator extends PropertyAnimatorCreator<ReactTextView> {
  11. public TextColorAnimator(Element from, Element to) {
  12. super(from, to);
  13. }
  14. @Override
  15. protected boolean shouldAnimateProperty(ReactTextView fromChild, ReactTextView toChild) {
  16. return getTextColor(fromChild) != getTextColor(toChild);
  17. }
  18. @Override
  19. public Animator create() {
  20. return ObjectAnimator.ofObject(
  21. to,
  22. "textColor",
  23. new LabColorEvaluator(),
  24. ColorUtils.colorToLAB(TextViewUtils.getTextColor((TextView) from.getChild())),
  25. ColorUtils.colorToLAB(TextViewUtils.getTextColor((TextView) to.getChild()))
  26. );
  27. }
  28. }