use of com.airbnb.lottie.model.layer.Layer in project lottie-android by airbnb.
the class LottieCompositionMoshiParser method parseAssets.
private static void parseAssets(JsonReader reader, LottieComposition composition, Map<String, List<Layer>> precomps, Map<String, LottieImageAsset> images) throws IOException {
reader.beginArray();
while (reader.hasNext()) {
String id = null;
// For precomps
List<Layer> layers = new ArrayList<>();
LongSparseArray<Layer> layerMap = new LongSparseArray<>();
// For images
int width = 0;
int height = 0;
String imageFileName = null;
String relativeFolder = null;
reader.beginObject();
while (reader.hasNext()) {
switch(reader.selectName(ASSETS_NAMES)) {
case 0:
id = reader.nextString();
break;
case 1:
reader.beginArray();
while (reader.hasNext()) {
Layer layer = LayerParser.parse(reader, composition);
layerMap.put(layer.getId(), layer);
layers.add(layer);
}
reader.endArray();
break;
case 2:
width = reader.nextInt();
break;
case 3:
height = reader.nextInt();
break;
case 4:
imageFileName = reader.nextString();
break;
case 5:
relativeFolder = reader.nextString();
break;
default:
reader.skipName();
reader.skipValue();
}
}
reader.endObject();
if (imageFileName != null) {
LottieImageAsset image = new LottieImageAsset(width, height, id, imageFileName, relativeFolder);
images.put(image.getId(), image);
} else {
precomps.put(id, layers);
}
}
reader.endArray();
}
Aggregations