Skip to content

Commit 5274d2c

Browse files
committed
Works
1 parent f3d84db commit 5274d2c

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java

+28-11
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@
7070
*/
7171
@SuppressWarnings({"WeakerAccess"})
7272
public class LottieDrawable extends Drawable implements Drawable.Callback, Animatable {
73+
7374
private interface LazyCompositionTask {
75+
7476
void run(LottieComposition composition);
7577
}
7678

@@ -96,10 +98,10 @@ private enum OnVisibleAction {
9698
/**
9799
* The marker to use if "reduced motion" is enabled.
98100
* Supported marker names are case insensitive, and include:
99-
* - reduced motion
100-
* - reducedMotion
101-
* - reduced_motion
102-
* - reduced-motion
101+
* - reduced motion
102+
* - reducedMotion
103+
* - reduced_motion
104+
* - reduced-motion
103105
*/
104106
private static final List<String> ALLOWED_REDUCED_MOTION_MARKERS = Arrays.asList(
105107
"reduced motion",
@@ -179,7 +181,9 @@ private enum OnVisibleAction {
179181
*/
180182
private boolean isDirty = false;
181183

182-
/** Use the getter so that it can fall back to {@link L#getDefaultAsyncUpdates()}. */
184+
/**
185+
* Use the getter so that it can fall back to {@link L#getDefaultAsyncUpdates()}.
186+
*/
183187
@Nullable private AsyncUpdates asyncUpdates;
184188
private final ValueAnimator.AnimatorUpdateListener progressUpdateListener = animation -> {
185189
if (getAsyncUpdatesEnabled()) {
@@ -250,6 +254,7 @@ private enum OnVisibleAction {
250254
@IntDef({RESTART, REVERSE})
251255
@Retention(RetentionPolicy.SOURCE)
252256
public @interface RepeatMode {
257+
253258
}
254259

255260
/**
@@ -766,13 +771,14 @@ public void draw(Canvas canvas, Matrix matrix) {
766771
}
767772
}
768773

769-
if (useSoftwareRendering) {
770-
canvas.save();
771-
canvas.concat(matrix);
772-
renderAndDrawAsBitmap(canvas, compositionLayer);
773-
canvas.restore();
774+
if (safeMode) {
775+
try {
776+
draw(canvas, matrix, compositionLayer, alpha);
777+
} catch (Throwable e) {
778+
Logger.error("Lottie crashed in draw!", e);
779+
}
774780
} else {
775-
compositionLayer.draw(canvas, matrix, alpha);
781+
draw(canvas, matrix, compositionLayer, alpha);
776782
}
777783
isDirty = false;
778784
} catch (InterruptedException e) {
@@ -787,6 +793,17 @@ public void draw(Canvas canvas, Matrix matrix) {
787793
}
788794
}
789795

796+
private void draw(Canvas canvas, Matrix matrix, CompositionLayer compositionLayer, int alpha) {
797+
if (useSoftwareRendering) {
798+
canvas.save();
799+
canvas.concat(matrix);
800+
renderAndDrawAsBitmap(canvas, compositionLayer);
801+
canvas.restore();
802+
} else {
803+
compositionLayer.draw(canvas, matrix, alpha);
804+
}
805+
}
806+
790807
// <editor-fold desc="animator">
791808

792809
@MainThread

0 commit comments

Comments
 (0)