Java Code Examples for com.airbnb.lottie.LottieProperty#OPACITY

The following examples show how to use com.airbnb.lottie.LottieProperty#OPACITY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseStrokeContent.java    From lottie-android with Apache License 2.0 7 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
@CallSuper
public <T> void addValueCallback(T property, @Nullable LottieValueCallback<T> callback) {
  if (property == LottieProperty.OPACITY) {
    opacityAnimation.setValueCallback((LottieValueCallback<Integer>) callback);
  } else if (property == LottieProperty.STROKE_WIDTH) {
    widthAnimation.setValueCallback((LottieValueCallback<Float>) callback);
  } else if (property == LottieProperty.COLOR_FILTER) {
    if (colorFilterAnimation != null) {
      layer.removeAnimation(colorFilterAnimation);
    }

    if (callback == null) {
      colorFilterAnimation = null;
    } else {
      colorFilterAnimation =
          new ValueCallbackKeyframeAnimation<>((LottieValueCallback<ColorFilter>) callback);
      colorFilterAnimation.addUpdateListener(this);
      layer.addAnimation(colorFilterAnimation);
    }
  }
}
 
Example 2
Source File: FillContent.java    From lottie-android with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <T> void addValueCallback(T property, @Nullable LottieValueCallback<T> callback) {
  if (property == LottieProperty.COLOR) {
    colorAnimation.setValueCallback((LottieValueCallback<Integer>) callback);
  } else if (property == LottieProperty.OPACITY) {
    opacityAnimation.setValueCallback((LottieValueCallback<Integer>) callback);
  } else if (property == LottieProperty.COLOR_FILTER) {
    if (colorFilterAnimation != null) {
      layer.removeAnimation(colorFilterAnimation);
    }

    if (callback == null) {
      colorFilterAnimation = null;
    } else {
      colorFilterAnimation =
          new ValueCallbackKeyframeAnimation<>((LottieValueCallback<ColorFilter>) callback);
      colorFilterAnimation.addUpdateListener(this);
      layer.addAnimation(colorFilterAnimation);
    }
  }
}
 
Example 3
Source File: GradientFillContent.java    From lottie-android with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <T> void addValueCallback(T property, @Nullable LottieValueCallback<T> callback) {
  if (property == LottieProperty.OPACITY) {
    opacityAnimation.setValueCallback((LottieValueCallback<Integer>) callback);
  } else if (property == LottieProperty.COLOR_FILTER) {
    if (colorFilterAnimation != null) {
      layer.removeAnimation(colorFilterAnimation);
    }

     if (callback == null) {
       colorFilterAnimation = null;
     } else {
       colorFilterAnimation =
           new ValueCallbackKeyframeAnimation<>((LottieValueCallback<ColorFilter>) callback);
       colorFilterAnimation.addUpdateListener(this);
       layer.addAnimation(colorFilterAnimation);
     }
   } else if (property == LottieProperty.GRADIENT_COLOR) {
    if (colorCallbackAnimation != null) {
      layer.removeAnimation(colorCallbackAnimation);
    }

     if (callback == null) {
       colorCallbackAnimation = null;
     } else {
       //noinspection rawtypes
       colorCallbackAnimation = new ValueCallbackKeyframeAnimation<>(callback);
       colorCallbackAnimation.addUpdateListener(this);
       layer.addAnimation(colorCallbackAnimation);
     }
  }
}