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();
}
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;
}
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;
}
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));
}
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);
}
Aggregations