use of com.airbnb.lottie.model.KeyPath in project lottie-android by airbnb.
the class BaseLayer method resolveKeyPath.
@Override
public void resolveKeyPath(KeyPath keyPath, int depth, List<KeyPath> accumulator, KeyPath currentPartialKeyPath) {
if (matteLayer != null) {
KeyPath matteCurrentPartialKeyPath = currentPartialKeyPath.addKey(matteLayer.getName());
if (keyPath.fullyResolvesTo(matteLayer.getName(), depth)) {
accumulator.add(matteCurrentPartialKeyPath.resolve(matteLayer));
}
if (keyPath.propagateToChildren(getName(), depth)) {
int newDepth = depth + keyPath.incrementDepthBy(matteLayer.getName(), depth);
matteLayer.resolveChildKeyPath(keyPath, newDepth, accumulator, matteCurrentPartialKeyPath);
}
}
if (!keyPath.matches(getName(), depth)) {
return;
}
if (!"__container".equals(getName())) {
currentPartialKeyPath = currentPartialKeyPath.addKey(getName());
if (keyPath.fullyResolvesTo(getName(), depth)) {
accumulator.add(currentPartialKeyPath.resolve(this));
}
}
if (keyPath.propagateToChildren(getName(), depth)) {
int newDepth = depth + keyPath.incrementDepthBy(getName(), depth);
resolveChildKeyPath(keyPath, newDepth, accumulator, currentPartialKeyPath);
}
}
use of com.airbnb.lottie.model.KeyPath in project lottie-android by airbnb.
the class KeyPathTest method assertSize.
// </editor-fold>
private void assertSize(int size, String... keys) {
KeyPath keyPath = new KeyPath(keys);
List<KeyPath> resolvedKeyPaths = lottieDrawable.resolveKeyPath(keyPath);
assertEquals(size, resolvedKeyPaths.size());
}
use of com.airbnb.lottie.model.KeyPath in project lottie-android by airbnb.
the class LottieAnimationView method init.
private void init(@Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.LottieAnimationView, defStyleAttr, 0);
cacheComposition = ta.getBoolean(R.styleable.LottieAnimationView_lottie_cacheComposition, true);
boolean hasRawRes = ta.hasValue(R.styleable.LottieAnimationView_lottie_rawRes);
boolean hasFileName = ta.hasValue(R.styleable.LottieAnimationView_lottie_fileName);
boolean hasUrl = ta.hasValue(R.styleable.LottieAnimationView_lottie_url);
if (hasRawRes && hasFileName) {
throw new IllegalArgumentException("lottie_rawRes and lottie_fileName cannot be used at " + "the same time. Please use only one at once.");
} else if (hasRawRes) {
int rawResId = ta.getResourceId(R.styleable.LottieAnimationView_lottie_rawRes, 0);
if (rawResId != 0) {
setAnimation(rawResId);
}
} else if (hasFileName) {
String fileName = ta.getString(R.styleable.LottieAnimationView_lottie_fileName);
if (fileName != null) {
setAnimation(fileName);
}
} else if (hasUrl) {
String url = ta.getString(R.styleable.LottieAnimationView_lottie_url);
if (url != null) {
setAnimationFromUrl(url);
}
}
setFallbackResource(ta.getResourceId(R.styleable.LottieAnimationView_lottie_fallbackRes, 0));
if (ta.getBoolean(R.styleable.LottieAnimationView_lottie_autoPlay, false)) {
autoPlay = true;
}
if (ta.getBoolean(R.styleable.LottieAnimationView_lottie_loop, false)) {
lottieDrawable.setRepeatCount(LottieDrawable.INFINITE);
}
if (ta.hasValue(R.styleable.LottieAnimationView_lottie_repeatMode)) {
setRepeatMode(ta.getInt(R.styleable.LottieAnimationView_lottie_repeatMode, LottieDrawable.RESTART));
}
if (ta.hasValue(R.styleable.LottieAnimationView_lottie_repeatCount)) {
setRepeatCount(ta.getInt(R.styleable.LottieAnimationView_lottie_repeatCount, LottieDrawable.INFINITE));
}
if (ta.hasValue(R.styleable.LottieAnimationView_lottie_speed)) {
setSpeed(ta.getFloat(R.styleable.LottieAnimationView_lottie_speed, 1f));
}
if (ta.hasValue(R.styleable.LottieAnimationView_lottie_clipToCompositionBounds)) {
setClipToCompositionBounds(ta.getBoolean(R.styleable.LottieAnimationView_lottie_clipToCompositionBounds, true));
}
setImageAssetsFolder(ta.getString(R.styleable.LottieAnimationView_lottie_imageAssetsFolder));
setProgress(ta.getFloat(R.styleable.LottieAnimationView_lottie_progress, 0));
enableMergePathsForKitKatAndAbove(ta.getBoolean(R.styleable.LottieAnimationView_lottie_enableMergePathsForKitKatAndAbove, false));
if (ta.hasValue(R.styleable.LottieAnimationView_lottie_colorFilter)) {
int colorRes = ta.getResourceId(R.styleable.LottieAnimationView_lottie_colorFilter, -1);
ColorStateList csl = AppCompatResources.getColorStateList(getContext(), colorRes);
SimpleColorFilter filter = new SimpleColorFilter(csl.getDefaultColor());
KeyPath keyPath = new KeyPath("**");
LottieValueCallback<ColorFilter> callback = new LottieValueCallback<>(filter);
addValueCallback(keyPath, LottieProperty.COLOR_FILTER, callback);
}
if (ta.hasValue(R.styleable.LottieAnimationView_lottie_renderMode)) {
int renderModeOrdinal = ta.getInt(R.styleable.LottieAnimationView_lottie_renderMode, RenderMode.AUTOMATIC.ordinal());
if (renderModeOrdinal >= RenderMode.values().length) {
renderModeOrdinal = RenderMode.AUTOMATIC.ordinal();
}
setRenderMode(RenderMode.values()[renderModeOrdinal]);
}
setIgnoreDisabledSystemAnimations(ta.getBoolean(R.styleable.LottieAnimationView_lottie_ignoreDisabledSystemAnimations, false));
ta.recycle();
lottieDrawable.setSystemAnimationsAreEnabled(Utils.getAnimationScale(getContext()) != 0f);
}
use of com.airbnb.lottie.model.KeyPath in project lottie-android by airbnb.
the class LottieDrawable method resolveKeyPath.
/**
* Takes a {@link KeyPath}, potentially with wildcards or globstars and resolve it to a list of
* zero or more actual {@link KeyPath Keypaths} that exist in the current animation.
* <p>
* If you want to set value callbacks for any of these values, it is recommend to use the
* returned {@link KeyPath} objects because they will be internally resolved to their content
* and won't trigger a tree walk of the animation contents when applied.
*/
public List<KeyPath> resolveKeyPath(KeyPath keyPath) {
if (compositionLayer == null) {
Logger.warning("Cannot resolve KeyPath. Composition is not set yet.");
return Collections.emptyList();
}
List<KeyPath> keyPaths = new ArrayList<>();
compositionLayer.resolveKeyPath(keyPath, 0, keyPaths, new KeyPath());
return keyPaths;
}
use of com.airbnb.lottie.model.KeyPath in project Signal-Android by WhisperSystems.
the class AudioView method setTint.
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);
if (circleProgress != null) {
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);
}
Aggregations