Skip to content

Commit

Permalink
Return null instead of NullLayer for unsupported layers
Browse files Browse the repository at this point in the history
This should also prevent strange crashes from unsupported layers.
  • Loading branch information
Gabriel Peal committed Apr 5, 2017
1 parent edb5499 commit fb40cab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lottie/src/main/java/com/airbnb/lottie/BaseLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ abstract class BaseLayer implements DrawingContent, BaseKeyframeAnimation.Animat
private static final int SAVE_FLAGS = Canvas.CLIP_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG |
Canvas.MATRIX_SAVE_FLAG;

@Nullable
static BaseLayer forModel(
Layer layerModel, LottieDrawable drawable, LottieComposition composition) {
switch (layerModel.getLayerType()) {
Expand All @@ -40,7 +41,7 @@ static BaseLayer forModel(
default:
// Do nothing
Log.w(L.TAG, "Unknown layer type " + layerModel.getLayerType());
return new NullLayer(drawable, layerModel);
return null;
}
}

Expand Down
3 changes: 3 additions & 0 deletions lottie/src/main/java/com/airbnb/lottie/CompositionLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class CompositionLayer extends BaseLayer {
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);
Expand Down

0 comments on commit fb40cab

Please sign in to comment.