com.airbnb.lottie.LottieProperty Java Examples

The following examples show how to use com.airbnb.lottie.LottieProperty. 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: GradientStrokeContent.java    From lottie-android with Apache License 2.0 6 votes vote down vote up
@Override
public <T> void addValueCallback(T property, @Nullable LottieValueCallback<T> callback) {
  super.addValueCallback(property, callback);
  if (property == LottieProperty.GRADIENT_COLOR) {
    if (colorCallbackAnimation != null) {
      layer.removeAnimation(colorCallbackAnimation);
    }

    if (callback == null) {
      colorCallbackAnimation = null;
    } else {
      colorCallbackAnimation = new ValueCallbackKeyframeAnimation<>(callback);
      colorCallbackAnimation.addUpdateListener(this);
      layer.addAnimation(colorCallbackAnimation);
    }
  }
}
 
Example #3
Source File: StrokeContent.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) {
  super.addValueCallback(property, callback);
  if (property == STROKE_COLOR) {
    colorAnimation.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(colorAnimation);
    }
  }
}
 
Example #4
Source File: PolystarContent.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.POLYSTAR_POINTS) {
    pointsAnimation.setValueCallback((LottieValueCallback<Float>) callback);
  } else if (property == LottieProperty.POLYSTAR_ROTATION) {
    rotationAnimation.setValueCallback((LottieValueCallback<Float>) callback);
  } else if (property == LottieProperty.POSITION) {
    positionAnimation.setValueCallback((LottieValueCallback<PointF>) callback);
  } else if (property == LottieProperty.POLYSTAR_INNER_RADIUS && innerRadiusAnimation != null) {
    innerRadiusAnimation.setValueCallback((LottieValueCallback<Float>) callback);
  } else if (property == LottieProperty.POLYSTAR_OUTER_RADIUS) {
    outerRadiusAnimation.setValueCallback((LottieValueCallback<Float>) callback);
  } else if (property == LottieProperty.POLYSTAR_INNER_ROUNDEDNESS && innerRoundednessAnimation != null) {
    innerRoundednessAnimation.setValueCallback((LottieValueCallback<Float>) callback);
  } else if (property == LottieProperty.POLYSTAR_OUTER_ROUNDEDNESS) {
    outerRoundednessAnimation.setValueCallback((LottieValueCallback<Float>) callback);
  }
}
 
Example #5
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 #6
Source File: CompositionLayer.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) {
  super.addValueCallback(property, callback);

  if (property == LottieProperty.TIME_REMAP) {
    if (callback == null) {
      if (timeRemapping != null) {
        timeRemapping.setValueCallback(null);
      }
    } else {
      timeRemapping = new ValueCallbackKeyframeAnimation<>((LottieValueCallback<Float>) callback);
      timeRemapping.addUpdateListener(this);
      addAnimation(timeRemapping);
    }
  }
}
 
Example #7
Source File: AudioView.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public void setTint(int foregroundTint) {
  post(()-> this.playPauseButton.addValueCallback(new KeyPath("**"),
                                                  LottieProperty.COLOR_FILTER,
                                                  new LottieValueCallback<>(new SimpleColorFilter(foregroundTint))));

  this.downloadButton.setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
  this.circleProgress.setBarColor(foregroundTint);

  if (this.duration != null) {
    this.duration.setTextColor(foregroundTint);
  }
  this.seekBar.getProgressDrawable().setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
  this.seekBar.getThumb().setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
}
 
Example #8
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);
     }
  }
}
 
Example #9
Source File: RectangleContent.java    From lottie-android with Apache License 2.0 5 votes vote down vote up
@Override
public <T> void addValueCallback(T property, @Nullable LottieValueCallback<T> callback) {
  if (property == LottieProperty.RECTANGLE_SIZE) {
    sizeAnimation.setValueCallback((LottieValueCallback<PointF>) callback);
  } else if (property == LottieProperty.POSITION) {
    positionAnimation.setValueCallback((LottieValueCallback<PointF>) callback);
  } else if (property == LottieProperty.CORNER_RADIUS) {
    cornerRadiusAnimation.setValueCallback((LottieValueCallback<Float>) callback);
  }
}
 
Example #10
Source File: EllipseContent.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.ELLIPSE_SIZE) {
    sizeAnimation.setValueCallback((LottieValueCallback<PointF>) callback);
  } else if (property == LottieProperty.POSITION) {
    positionAnimation.setValueCallback((LottieValueCallback<PointF>) callback);
  }
}
 
Example #11
Source File: RepeaterContent.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 (transform.applyValueCallback(property, callback)) {
    return;
  }

  if (property == LottieProperty.REPEATER_COPIES) {
    copies.setValueCallback((LottieValueCallback<Float>) callback);
  } else if (property == LottieProperty.REPEATER_OFFSET) {
    offset.setValueCallback((LottieValueCallback<Float>) callback);
  }
}
 
Example #12
Source File: SolidLayer.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) {
  super.addValueCallback(property, callback);
  if (property == LottieProperty.COLOR_FILTER) {
    if (callback == null) {
      colorFilterAnimation = null;
    } else {
      colorFilterAnimation =
          new ValueCallbackKeyframeAnimation<>((LottieValueCallback<ColorFilter>) callback);
    }
  }
}
 
Example #13
Source File: ImageLayer.java    From lottie-android with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("SingleStatementInBlock")
@Override
public <T> void addValueCallback(T property, @Nullable LottieValueCallback<T> callback) {
  super.addValueCallback(property, callback);
   if (property == LottieProperty.COLOR_FILTER) {
     if (callback == null) {
       colorFilterAnimation = null;
     } else {
       //noinspection unchecked
       colorFilterAnimation =
           new ValueCallbackKeyframeAnimation<>((LottieValueCallback<ColorFilter>) callback);
     }
  }
}
 
Example #14
Source File: LottieAnimationViewPropertyManager.java    From lottie-react-native with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the view with changed fields.
 * Majority of the properties here are independent so they are has to be reset to null
 * as soon as view is updated with the value.
 *
 * The only exception from this rule is the group of the properties for the animation.
 * For now this is animationName and cacheStrategy. These two properties are should be set
 * simultaneously if the dirty flag is set.
 */
public void commitChanges() {
  LottieAnimationView view = viewWeakReference.get();
  if (view == null) {
    return;
  }

  if (animationJson != null) {
    view.setAnimationFromJson(animationJson, Integer.toString(animationJson.hashCode()));
    animationJson = null;
  }

  if (animationNameDirty) {
    view.setAnimation(animationName);
    animationNameDirty = false;
  }

  if (progress != null) {
    view.setProgress(progress);
    progress = null;
  }

  if (loop != null) {
    view.setRepeatCount(loop ? LottieDrawable.INFINITE : 0);
    loop = null;
  }

  if (speed != null) {
    view.setSpeed(speed);
    speed = null;
  }

  if (scaleType != null) {
    view.setScaleType(scaleType);
    scaleType = null;
  }

  if (renderMode != null) {
    view.setRenderMode(renderMode);
    renderMode = null;
  }

  if (imageAssetsFolder != null) {
    view.setImageAssetsFolder(imageAssetsFolder);
    imageAssetsFolder = null;
  }

  if (enableMergePaths != null) {
    view.enableMergePathsForKitKatAndAbove(enableMergePaths);
    enableMergePaths = null;
  }

  if (colorFilters != null && colorFilters.size() > 0) {
    for (int i = 0 ; i < colorFilters.size() ; i++) {
      ReadableMap current = colorFilters.getMap(i);
      String color = current.getString("color");
      String path = current.getString("keypath");
      SimpleColorFilter colorFilter = new SimpleColorFilter(Color.parseColor(color));
      KeyPath keyPath = new KeyPath(path, "**");
      LottieValueCallback<ColorFilter> callback = new LottieValueCallback<>(colorFilter);
      view.addValueCallback(keyPath, LottieProperty.COLOR_FILTER, callback);
    }
  }
}
 
Example #15
Source File: TextLayer.java    From lottie-android with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <T> void addValueCallback(T property, @Nullable LottieValueCallback<T> callback) {
  super.addValueCallback(property, callback);
  if (property == LottieProperty.COLOR) {
    if (colorCallbackAnimation != null) {
      removeAnimation(colorCallbackAnimation);
    }

    if (callback == null) {
        colorCallbackAnimation = null;
    } else {
      colorCallbackAnimation = new ValueCallbackKeyframeAnimation<>((LottieValueCallback<Integer>) callback);
      colorCallbackAnimation.addUpdateListener(this);
      addAnimation(colorCallbackAnimation);
    }
  } else if (property == LottieProperty.STROKE_COLOR) {
    if (strokeColorCallbackAnimation != null) {
      removeAnimation(strokeColorCallbackAnimation);
    }

    if (callback == null) {
      strokeColorCallbackAnimation = null;
    } else {
      strokeColorCallbackAnimation = new ValueCallbackKeyframeAnimation<>((LottieValueCallback<Integer>) callback);
      strokeColorCallbackAnimation.addUpdateListener(this);
      addAnimation(strokeColorCallbackAnimation);
    }
  } else if (property == LottieProperty.STROKE_WIDTH) {
    if (strokeWidthCallbackAnimation != null) {
      removeAnimation(strokeWidthCallbackAnimation);
    }

    if (callback == null) {
      strokeWidthCallbackAnimation = null;
    } else {
      strokeWidthCallbackAnimation = new ValueCallbackKeyframeAnimation<>((LottieValueCallback<Float>) callback);
      strokeWidthCallbackAnimation.addUpdateListener(this);
      addAnimation(strokeWidthCallbackAnimation);
    }
  } else if (property == LottieProperty.TEXT_TRACKING) {
    if (trackingCallbackAnimation != null) {
      removeAnimation(trackingCallbackAnimation);
    }

    if (callback == null) {
      trackingCallbackAnimation = null;
    } else {
      trackingCallbackAnimation = new ValueCallbackKeyframeAnimation<>((LottieValueCallback<Float>) callback);
      trackingCallbackAnimation.addUpdateListener(this);
      addAnimation(trackingCallbackAnimation);
    }
  } else if (property == LottieProperty.TEXT_SIZE) {
    if (textSizeCallbackAnimation != null) {
      removeAnimation(textSizeCallbackAnimation);
    }

    if (callback == null) {
      textSizeCallbackAnimation = null;
    } else {
      textSizeCallbackAnimation = new ValueCallbackKeyframeAnimation<>((LottieValueCallback<Float>) callback);
      textSizeCallbackAnimation.addUpdateListener(this);
      addAnimation(textSizeCallbackAnimation);
    }
  }
}