Search in sources :

Example 1 with ShapeGroup

use of com.airbnb.lottie.model.content.ShapeGroup in project lottie-android by airbnb.

the class TextLayer method getContentsForCharacter.

private List<ContentGroup> getContentsForCharacter(FontCharacter character) {
    if (contentsForCharacter.containsKey(character)) {
        return contentsForCharacter.get(character);
    }
    List<ShapeGroup> shapes = character.getShapes();
    int size = shapes.size();
    List<ContentGroup> contents = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        ShapeGroup sg = shapes.get(i);
        contents.add(new ContentGroup(lottieDrawable, this, sg));
    }
    contentsForCharacter.put(character, contents);
    return contents;
}
Also used : ArrayList(java.util.ArrayList) ContentGroup(com.airbnb.lottie.animation.content.ContentGroup) ShapeGroup(com.airbnb.lottie.model.content.ShapeGroup) Paint(android.graphics.Paint)

Example 2 with ShapeGroup

use of com.airbnb.lottie.model.content.ShapeGroup in project lottie-android by airbnb.

the class ShapeGroupParser method parse.

static ShapeGroup parse(JsonReader reader, LottieComposition composition) throws IOException {
    String name = null;
    boolean hidden = false;
    List<ContentModel> items = new ArrayList<>();
    while (reader.hasNext()) {
        switch(reader.selectName(NAMES)) {
            case 0:
                name = reader.nextString();
                break;
            case 1:
                hidden = reader.nextBoolean();
                break;
            case 2:
                reader.beginArray();
                while (reader.hasNext()) {
                    ContentModel newItem = ContentModelParser.parse(reader, composition);
                    if (newItem != null) {
                        items.add(newItem);
                    }
                }
                reader.endArray();
                break;
            default:
                reader.skipValue();
        }
    }
    return new ShapeGroup(name, items, hidden);
}
Also used : ContentModel(com.airbnb.lottie.model.content.ContentModel) ArrayList(java.util.ArrayList) ShapeGroup(com.airbnb.lottie.model.content.ShapeGroup)

Aggregations

ShapeGroup (com.airbnb.lottie.model.content.ShapeGroup)2 ArrayList (java.util.ArrayList)2 Paint (android.graphics.Paint)1 ContentGroup (com.airbnb.lottie.animation.content.ContentGroup)1 ContentModel (com.airbnb.lottie.model.content.ContentModel)1