Search in sources :

Example 1 with ShapeFill

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

the class ShapeFillParser method parse.

static ShapeFill parse(JsonReader reader, LottieComposition composition) throws IOException {
    AnimatableColorValue color = null;
    boolean fillEnabled = false;
    AnimatableIntegerValue opacity = null;
    String name = null;
    int fillTypeInt = 1;
    boolean hidden = false;
    while (reader.hasNext()) {
        switch(reader.selectName(NAMES)) {
            case 0:
                name = reader.nextString();
                break;
            case 1:
                color = AnimatableValueParser.parseColor(reader, composition);
                break;
            case 2:
                opacity = AnimatableValueParser.parseInteger(reader, composition);
                break;
            case 3:
                fillEnabled = reader.nextBoolean();
                break;
            case 4:
                fillTypeInt = reader.nextInt();
                break;
            case 5:
                hidden = reader.nextBoolean();
                break;
            default:
                reader.skipName();
                reader.skipValue();
        }
    }
    // Telegram sometimes omits opacity.
    // https://github.com/airbnb/lottie-android/issues/1600
    opacity = opacity == null ? new AnimatableIntegerValue(Collections.singletonList(new Keyframe<>(100))) : opacity;
    Path.FillType fillType = fillTypeInt == 1 ? Path.FillType.WINDING : Path.FillType.EVEN_ODD;
    return new ShapeFill(name, fillEnabled, fillType, color, opacity, hidden);
}
Also used : Path(android.graphics.Path) ShapeFill(com.airbnb.lottie.model.content.ShapeFill) AnimatableColorValue(com.airbnb.lottie.model.animatable.AnimatableColorValue) Keyframe(com.airbnb.lottie.value.Keyframe) AnimatableIntegerValue(com.airbnb.lottie.model.animatable.AnimatableIntegerValue)

Aggregations

Path (android.graphics.Path)1 AnimatableColorValue (com.airbnb.lottie.model.animatable.AnimatableColorValue)1 AnimatableIntegerValue (com.airbnb.lottie.model.animatable.AnimatableIntegerValue)1 ShapeFill (com.airbnb.lottie.model.content.ShapeFill)1 Keyframe (com.airbnb.lottie.value.Keyframe)1