Search in sources :

Example 1 with Marker

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

the class LottieCompositionMoshiParser method parseMarkers.

private static void parseMarkers(JsonReader reader, List<Marker> markers) throws IOException {
    reader.beginArray();
    while (reader.hasNext()) {
        String comment = null;
        float frame = 0f;
        float durationFrames = 0f;
        reader.beginObject();
        while (reader.hasNext()) {
            switch(reader.selectName(MARKER_NAMES)) {
                case 0:
                    comment = reader.nextString();
                    break;
                case 1:
                    frame = (float) reader.nextDouble();
                    break;
                case 2:
                    durationFrames = (float) reader.nextDouble();
                    break;
                default:
                    reader.skipName();
                    reader.skipValue();
            }
        }
        reader.endObject();
        markers.add(new Marker(comment, frame, durationFrames));
    }
    reader.endArray();
}
Also used : Marker(com.airbnb.lottie.model.Marker)

Example 2 with Marker

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

the class LottieDrawableTest method createComposition.

@SuppressWarnings("SameParameterValue")
private LottieComposition createComposition(int startFrame, int endFrame) {
    LottieComposition composition = new LottieComposition();
    composition.init(new Rect(), startFrame, endFrame, 1000, new ArrayList<Layer>(), new LongSparseArray<Layer>(0), new HashMap<String, List<Layer>>(0), new HashMap<String, LottieImageAsset>(0), new SparseArrayCompat<FontCharacter>(0), new HashMap<String, Font>(0), new ArrayList<Marker>());
    return composition;
}
Also used : Rect(android.graphics.Rect) Marker(com.airbnb.lottie.model.Marker) Layer(com.airbnb.lottie.model.layer.Layer) FontCharacter(com.airbnb.lottie.model.FontCharacter) Font(com.airbnb.lottie.model.Font) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with Marker

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

the class LottieValueAnimatorUnitTest method createComposition.

private LottieComposition createComposition(int startFrame, int endFrame) {
    LottieComposition composition = new LottieComposition();
    composition.init(new Rect(), startFrame, endFrame, 1000, new ArrayList<Layer>(), new LongSparseArray<Layer>(0), new HashMap<String, List<Layer>>(0), new HashMap<String, LottieImageAsset>(0), new SparseArrayCompat<FontCharacter>(0), new HashMap<String, Font>(0), new ArrayList<Marker>());
    return composition;
}
Also used : Rect(android.graphics.Rect) Marker(com.airbnb.lottie.model.Marker) Layer(com.airbnb.lottie.model.layer.Layer) FontCharacter(com.airbnb.lottie.model.FontCharacter) Font(com.airbnb.lottie.model.Font) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with Marker

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

the class LottieDrawable method setMaxFrame.

/**
 * Sets the maximum frame to the start time + duration of the specified marker.
 *
 * @throws IllegalArgumentException if the marker is not found.
 */
public void setMaxFrame(final String markerName) {
    if (composition == null) {
        lazyCompositionTasks.add(c -> setMaxFrame(markerName));
        return;
    }
    Marker marker = composition.getMarker(markerName);
    if (marker == null) {
        throw new IllegalArgumentException("Cannot find marker with name " + markerName + ".");
    }
    setMaxFrame((int) (marker.startFrame + marker.durationFrames));
}
Also used : Marker(com.airbnb.lottie.model.Marker)

Example 5 with Marker

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

the class LottieDrawable method setMinAndMaxFrame.

/**
 * Sets the minimum and maximum frame to the start marker start and the maximum frame to the end marker start.
 * playEndMarkerStartFrame determines whether or not to play the frame that the end marker is on. If the end marker
 * represents the end of the section that you want, it should be true. If the marker represents the beginning of the
 * next section, it should be false.
 *
 * @throws IllegalArgumentException if either marker is not found.
 */
public void setMinAndMaxFrame(final String startMarkerName, final String endMarkerName, final boolean playEndMarkerStartFrame) {
    if (composition == null) {
        lazyCompositionTasks.add(c -> setMinAndMaxFrame(startMarkerName, endMarkerName, playEndMarkerStartFrame));
        return;
    }
    Marker startMarker = composition.getMarker(startMarkerName);
    if (startMarker == null) {
        throw new IllegalArgumentException("Cannot find marker with name " + startMarkerName + ".");
    }
    int startFrame = (int) startMarker.startFrame;
    final Marker endMarker = composition.getMarker(endMarkerName);
    if (endMarker == null) {
        throw new IllegalArgumentException("Cannot find marker with name " + endMarkerName + ".");
    }
    int endFrame = (int) (endMarker.startFrame + (playEndMarkerStartFrame ? 1f : 0f));
    setMinAndMaxFrame(startFrame, endFrame);
}
Also used : Marker(com.airbnb.lottie.model.Marker) SuppressLint(android.annotation.SuppressLint) LPaint(com.airbnb.lottie.animation.LPaint) Paint(android.graphics.Paint)

Aggregations

Marker (com.airbnb.lottie.model.Marker)8 Rect (android.graphics.Rect)3 Font (com.airbnb.lottie.model.Font)3 FontCharacter (com.airbnb.lottie.model.FontCharacter)3 Layer (com.airbnb.lottie.model.layer.Layer)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 SuppressLint (android.annotation.SuppressLint)2 Paint (android.graphics.Paint)2 LPaint (com.airbnb.lottie.animation.LPaint)2 LongSparseArray (androidx.collection.LongSparseArray)1 SparseArrayCompat (androidx.collection.SparseArrayCompat)1 LottieComposition (com.airbnb.lottie.LottieComposition)1 LottieImageAsset (com.airbnb.lottie.LottieImageAsset)1 HashMap (java.util.HashMap)1