com.airbnb.lottie.LottieDrawable Java Examples
The following examples show how to use
com.airbnb.lottie.LottieDrawable.
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: BaseLayer.java From lottie-android with Apache License 2.0 | 6 votes |
@Nullable static BaseLayer forModel( Layer layerModel, LottieDrawable drawable, LottieComposition composition) { switch (layerModel.getLayerType()) { case SHAPE: return new ShapeLayer(drawable, layerModel); case PRE_COMP: return new CompositionLayer(drawable, layerModel, composition.getPrecomps(layerModel.getRefId()), composition); case SOLID: return new SolidLayer(drawable, layerModel); case IMAGE: return new ImageLayer(drawable, layerModel); case NULL: return new NullLayer(drawable, layerModel); case TEXT: return new TextLayer(drawable, layerModel); case UNKNOWN: default: // Do nothing Logger.warning("Unknown layer type " + layerModel.getLayerType()); return null; } }
Example #2
Source File: GradientStrokeContent.java From lottie-android with Apache License 2.0 | 6 votes |
public GradientStrokeContent( final LottieDrawable lottieDrawable, BaseLayer layer, GradientStroke stroke) { super(lottieDrawable, layer, stroke.getCapType().toPaintCap(), stroke.getJoinType().toPaintJoin(), stroke.getMiterLimit(), stroke.getOpacity(), stroke.getWidth(), stroke.getLineDashPattern(), stroke.getDashOffset()); name = stroke.getName(); type = stroke.getGradientType(); hidden = stroke.isHidden(); cacheSteps = (int) (lottieDrawable.getComposition().getDuration() / CACHE_STEPS_MS); colorAnimation = stroke.getGradientColor().createAnimation(); colorAnimation.addUpdateListener(this); layer.addAnimation(colorAnimation); startPointAnimation = stroke.getStartPoint().createAnimation(); startPointAnimation.addUpdateListener(this); layer.addAnimation(startPointAnimation); endPointAnimation = stroke.getEndPoint().createAnimation(); endPointAnimation.addUpdateListener(this); layer.addAnimation(endPointAnimation); }
Example #3
Source File: ContentGroup.java From lottie-android with Apache License 2.0 | 6 votes |
ContentGroup(final LottieDrawable lottieDrawable, BaseLayer layer, String name, boolean hidden, List<Content> contents, @Nullable AnimatableTransform transform) { this.name = name; this.lottieDrawable = lottieDrawable; this.hidden = hidden; this.contents = contents; if (transform != null) { transformAnimation = transform.createAnimation(); transformAnimation.addAnimationsToLayer(layer); transformAnimation.addListener(this); } List<GreedyContent> greedyContents = new ArrayList<>(); for (int i = contents.size() - 1; i >= 0; i--) { Content content = contents.get(i); if (content instanceof GreedyContent) { greedyContents.add((GreedyContent) content); } } for (int i = greedyContents.size() - 1; i >= 0; i--) { greedyContents.get(i).absorbContent(contents.listIterator(contents.size())); } }
Example #4
Source File: RepeaterContent.java From lottie-android with Apache License 2.0 | 6 votes |
public RepeaterContent(LottieDrawable lottieDrawable, BaseLayer layer, Repeater repeater) { this.lottieDrawable = lottieDrawable; this.layer = layer; name = repeater.getName(); this.hidden = repeater.isHidden(); copies = repeater.getCopies().createAnimation(); layer.addAnimation(copies); copies.addUpdateListener(this); offset = repeater.getOffset().createAnimation(); layer.addAnimation(offset); offset.addUpdateListener(this); transform = repeater.getTransform().createAnimation(); transform.addAnimationsToLayer(layer); transform.addListener(this); }
Example #5
Source File: FillContent.java From lottie-android with Apache License 2.0 | 6 votes |
public FillContent(final LottieDrawable lottieDrawable, BaseLayer layer, ShapeFill fill) { this.layer = layer; name = fill.getName(); hidden = fill.isHidden(); this.lottieDrawable = lottieDrawable; if (fill.getColor() == null || fill.getOpacity() == null ) { colorAnimation = null; opacityAnimation = null; return; } path.setFillType(fill.getFillType()); colorAnimation = fill.getColor().createAnimation(); colorAnimation.addUpdateListener(this); layer.addAnimation(colorAnimation); opacityAnimation = fill.getOpacity().createAnimation(); opacityAnimation.addUpdateListener(this); layer.addAnimation(opacityAnimation); }
Example #6
Source File: GradientFillContent.java From lottie-android with Apache License 2.0 | 6 votes |
public GradientFillContent(final LottieDrawable lottieDrawable, BaseLayer layer, GradientFill fill) { this.layer = layer; name = fill.getName(); hidden = fill.isHidden(); this.lottieDrawable = lottieDrawable; type = fill.getGradientType(); path.setFillType(fill.getFillType()); cacheSteps = (int) (lottieDrawable.getComposition().getDuration() / CACHE_STEPS_MS); colorAnimation = fill.getGradientColor().createAnimation(); colorAnimation.addUpdateListener(this); layer.addAnimation(colorAnimation); opacityAnimation = fill.getOpacity().createAnimation(); opacityAnimation.addUpdateListener(this); layer.addAnimation(opacityAnimation); startPointAnimation = fill.getStartPoint().createAnimation(); startPointAnimation.addUpdateListener(this); layer.addAnimation(startPointAnimation); endPointAnimation = fill.getEndPoint().createAnimation(); endPointAnimation.addUpdateListener(this); layer.addAnimation(endPointAnimation); }
Example #7
Source File: RectangleContent.java From lottie-android with Apache License 2.0 | 6 votes |
public RectangleContent(LottieDrawable lottieDrawable, BaseLayer layer, RectangleShape rectShape) { name = rectShape.getName(); hidden = rectShape.isHidden(); this.lottieDrawable = lottieDrawable; positionAnimation = rectShape.getPosition().createAnimation(); sizeAnimation = rectShape.getSize().createAnimation(); cornerRadiusAnimation = rectShape.getCornerRadius().createAnimation(); layer.addAnimation(positionAnimation); layer.addAnimation(sizeAnimation); layer.addAnimation(cornerRadiusAnimation); positionAnimation.addUpdateListener(this); sizeAnimation.addUpdateListener(this); cornerRadiusAnimation.addUpdateListener(this); }
Example #8
Source File: CustomLottieHeader.java From SmoothRefreshLayout with MIT License | 5 votes |
@Override public void onRefreshBegin(SmoothRefreshLayout layout, IIndicator indicator) { setRenderMode(RenderMode.HARDWARE); setRepeatMode(LottieDrawable.RESTART); setRepeatCount(LottieDrawable.INFINITE); playAnimation(); }
Example #9
Source File: MergePaths.java From lottie-android with Apache License 2.0 | 5 votes |
@Override @Nullable public Content toContent(LottieDrawable drawable, BaseLayer layer) { if (!drawable.enableMergePathsForKitKatAndAbove()) { Logger.warning("Animation contains merge paths but they are disabled."); return null; } return new MergePathsContent(this); }
Example #10
Source File: ShapeLayer.java From lottie-android with Apache License 2.0 | 5 votes |
ShapeLayer(LottieDrawable lottieDrawable, Layer layerModel) { super(lottieDrawable, layerModel); // Naming this __container allows it to be ignored in KeyPath matching. ShapeGroup shapeGroup = new ShapeGroup("__container", layerModel.getShapes(), false); contentGroup = new ContentGroup(lottieDrawable, this, shapeGroup); contentGroup.setContents(Collections.<Content>emptyList(), Collections.<Content>emptyList()); }
Example #11
Source File: TextLayer.java From lottie-android with Apache License 2.0 | 5 votes |
TextLayer(LottieDrawable lottieDrawable, Layer layerModel) { super(lottieDrawable, layerModel); this.lottieDrawable = lottieDrawable; composition = layerModel.getComposition(); //noinspection ConstantConditions textAnimation = layerModel.getText().createAnimation(); textAnimation.addUpdateListener(this); addAnimation(textAnimation); AnimatableTextProperties textProperties = layerModel.getTextProperties(); if (textProperties != null && textProperties.color != null) { colorAnimation = textProperties.color.createAnimation(); colorAnimation.addUpdateListener(this); addAnimation(colorAnimation); } if (textProperties != null && textProperties.stroke != null) { strokeColorAnimation = textProperties.stroke.createAnimation(); strokeColorAnimation.addUpdateListener(this); addAnimation(strokeColorAnimation); } if (textProperties != null && textProperties.strokeWidth != null) { strokeWidthAnimation = textProperties.strokeWidth.createAnimation(); strokeWidthAnimation.addUpdateListener(this); addAnimation(strokeWidthAnimation); } if (textProperties != null && textProperties.tracking != null) { trackingAnimation = textProperties.tracking.createAnimation(); trackingAnimation.addUpdateListener(this); addAnimation(trackingAnimation); } }
Example #12
Source File: SolidLayer.java From lottie-android with Apache License 2.0 | 5 votes |
SolidLayer(LottieDrawable lottieDrawable, Layer layerModel) { super(lottieDrawable, layerModel); this.layerModel = layerModel; paint.setAlpha(0); paint.setStyle(Paint.Style.FILL); paint.setColor(layerModel.getSolidColor()); }
Example #13
Source File: EllipseContent.java From lottie-android with Apache License 2.0 | 5 votes |
public EllipseContent(LottieDrawable lottieDrawable, BaseLayer layer, CircleShape circleShape) { name = circleShape.getName(); this.lottieDrawable = lottieDrawable; sizeAnimation = circleShape.getSize().createAnimation(); positionAnimation = circleShape.getPosition().createAnimation(); this.circleShape = circleShape; layer.addAnimation(sizeAnimation); layer.addAnimation(positionAnimation); sizeAnimation.addUpdateListener(this); positionAnimation.addUpdateListener(this); }
Example #14
Source File: ShapeContent.java From lottie-android with Apache License 2.0 | 5 votes |
public ShapeContent(LottieDrawable lottieDrawable, BaseLayer layer, ShapePath shape) { name = shape.getName(); hidden = shape.isHidden(); this.lottieDrawable = lottieDrawable; shapeAnimation = shape.getShapePath().createAnimation(); layer.addAnimation(shapeAnimation); shapeAnimation.addUpdateListener(this); }
Example #15
Source File: PolystarContent.java From lottie-android with Apache License 2.0 | 5 votes |
public PolystarContent(LottieDrawable lottieDrawable, BaseLayer layer, PolystarShape polystarShape) { this.lottieDrawable = lottieDrawable; name = polystarShape.getName(); type = polystarShape.getType(); hidden = polystarShape.isHidden(); pointsAnimation = polystarShape.getPoints().createAnimation(); positionAnimation = polystarShape.getPosition().createAnimation(); rotationAnimation = polystarShape.getRotation().createAnimation(); outerRadiusAnimation = polystarShape.getOuterRadius().createAnimation(); outerRoundednessAnimation = polystarShape.getOuterRoundedness().createAnimation(); if (type == PolystarShape.Type.STAR) { innerRadiusAnimation = polystarShape.getInnerRadius().createAnimation(); innerRoundednessAnimation = polystarShape.getInnerRoundedness().createAnimation(); } else { innerRadiusAnimation = null; innerRoundednessAnimation = null; } layer.addAnimation(pointsAnimation); layer.addAnimation(positionAnimation); layer.addAnimation(rotationAnimation); layer.addAnimation(outerRadiusAnimation); layer.addAnimation(outerRoundednessAnimation); if (type == PolystarShape.Type.STAR) { layer.addAnimation(innerRadiusAnimation); layer.addAnimation(innerRoundednessAnimation); } pointsAnimation.addUpdateListener(this); positionAnimation.addUpdateListener(this); rotationAnimation.addUpdateListener(this); outerRadiusAnimation.addUpdateListener(this); outerRoundednessAnimation.addUpdateListener(this); if (type == PolystarShape.Type.STAR) { innerRadiusAnimation.addUpdateListener(this); innerRoundednessAnimation.addUpdateListener(this); } }
Example #16
Source File: StrokeContent.java From lottie-android with Apache License 2.0 | 5 votes |
public StrokeContent(final LottieDrawable lottieDrawable, BaseLayer layer, ShapeStroke stroke) { super(lottieDrawable, layer, stroke.getCapType().toPaintCap(), stroke.getJoinType().toPaintJoin(), stroke.getMiterLimit(), stroke.getOpacity(), stroke.getWidth(), stroke.getLineDashPattern(), stroke.getDashOffset()); this.layer = layer; name = stroke.getName(); hidden = stroke.isHidden(); colorAnimation = stroke.getColor().createAnimation(); colorAnimation.addUpdateListener(this); layer.addAnimation(colorAnimation); }
Example #17
Source File: ContentGroup.java From lottie-android with Apache License 2.0 | 5 votes |
private static List<Content> contentsFromModels(LottieDrawable drawable, BaseLayer layer, List<ContentModel> contentModels) { List<Content> contents = new ArrayList<>(contentModels.size()); for (int i = 0; i < contentModels.size(); i++) { Content content = contentModels.get(i).toContent(drawable, layer); if (content != null) { contents.add(content); } } return contents; }
Example #18
Source File: SyncActivity.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onStart() { super.onStart(); if (binding.lottieView != null) { binding.lottieView.setRepeatCount(LottieDrawable.INFINITE); binding.lottieView.setRepeatMode(LottieDrawable.RESTART); binding.lottieView.enableMergePathsForKitKatAndAbove(true); binding.lottieView.playAnimation(); } }
Example #19
Source File: ImageLayer.java From lottie-android with Apache License 2.0 | 4 votes |
ImageLayer(LottieDrawable lottieDrawable, Layer layerModel) { super(lottieDrawable, layerModel); }
Example #20
Source File: NullLayer.java From lottie-android with Apache License 2.0 | 4 votes |
NullLayer(LottieDrawable lottieDrawable, Layer layerModel) { super(lottieDrawable, layerModel); }
Example #21
Source File: AnimatableTransform.java From lottie-android with Apache License 2.0 | 4 votes |
@Nullable @Override public Content toContent(LottieDrawable drawable, BaseLayer layer) { return null; }
Example #22
Source File: ShapeTrimPath.java From lottie-android with Apache License 2.0 | 4 votes |
@Override public Content toContent(LottieDrawable drawable, BaseLayer layer) { return new TrimPathContent(layer, this); }
Example #23
Source File: CompositionLayer.java From lottie-android with Apache License 2.0 | 4 votes |
public CompositionLayer(LottieDrawable lottieDrawable, Layer layerModel, List<Layer> layerModels, LottieComposition composition) { super(lottieDrawable, layerModel); AnimatableFloatValue timeRemapping = layerModel.getTimeRemapping(); if (timeRemapping != null) { this.timeRemapping = timeRemapping.createAnimation(); addAnimation(this.timeRemapping); //noinspection ConstantConditions this.timeRemapping.addUpdateListener(this); } else { this.timeRemapping = null; } LongSparseArray<BaseLayer> layerMap = new LongSparseArray<>(composition.getLayers().size()); BaseLayer mattedLayer = null; for (int i = layerModels.size() - 1; i >= 0; i--) { Layer lm = layerModels.get(i); BaseLayer layer = BaseLayer.forModel(lm, lottieDrawable, composition); if (layer == null) { continue; } layerMap.put(layer.getLayerModel().getId(), layer); if (mattedLayer != null) { mattedLayer.setMatteLayer(layer); mattedLayer = null; } else { layers.add(0, layer); switch (lm.getMatteType()) { case ADD: case INVERT: mattedLayer = layer; break; } } } for (int i = 0; i < layerMap.size(); i++) { long key = layerMap.keyAt(i); BaseLayer layerView = layerMap.get(key); // This shouldn't happen but it appears as if sometimes on pre-lollipop devices when // compiled with d8, layerView is null sometimes. // https://github.com/airbnb/lottie-android/issues/524 if (layerView == null) { continue; } BaseLayer parentLayer = layerMap.get(layerView.getLayerModel().getParentId()); if (parentLayer != null) { layerView.setParentLayer(parentLayer); } } }
Example #24
Source File: PolystarShape.java From lottie-android with Apache License 2.0 | 4 votes |
@Override public Content toContent(LottieDrawable drawable, BaseLayer layer) { return new PolystarContent(drawable, layer, this); }
Example #25
Source File: GradientStroke.java From lottie-android with Apache License 2.0 | 4 votes |
@Override public Content toContent(LottieDrawable drawable, BaseLayer layer) { return new GradientStrokeContent(drawable, layer, this); }
Example #26
Source File: ShapeStroke.java From lottie-android with Apache License 2.0 | 4 votes |
@Override public Content toContent(LottieDrawable drawable, BaseLayer layer) { return new StrokeContent(drawable, layer, this); }
Example #27
Source File: Repeater.java From lottie-android with Apache License 2.0 | 4 votes |
@Nullable @Override public Content toContent(LottieDrawable drawable, BaseLayer layer) { return new RepeaterContent(drawable, layer, this); }
Example #28
Source File: GradientFill.java From lottie-android with Apache License 2.0 | 4 votes |
@Override public Content toContent(LottieDrawable drawable, BaseLayer layer) { return new GradientFillContent(drawable, layer, this); }
Example #29
Source File: ShapeFill.java From lottie-android with Apache License 2.0 | 4 votes |
@Override public Content toContent(LottieDrawable drawable, BaseLayer layer) { return new FillContent(drawable, layer, this); }
Example #30
Source File: RectangleShape.java From lottie-android with Apache License 2.0 | 4 votes |
@Override public Content toContent(LottieDrawable drawable, BaseLayer layer) { return new RectangleContent(drawable, layer, this); }