70
70
*/
71
71
@ SuppressWarnings ({"WeakerAccess" })
72
72
public class LottieDrawable extends Drawable implements Drawable .Callback , Animatable {
73
+
73
74
private interface LazyCompositionTask {
75
+
74
76
void run (LottieComposition composition );
75
77
}
76
78
@@ -96,10 +98,10 @@ private enum OnVisibleAction {
96
98
/**
97
99
* The marker to use if "reduced motion" is enabled.
98
100
* 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
103
105
*/
104
106
private static final List <String > ALLOWED_REDUCED_MOTION_MARKERS = Arrays .asList (
105
107
"reduced motion" ,
@@ -179,7 +181,9 @@ private enum OnVisibleAction {
179
181
*/
180
182
private boolean isDirty = false ;
181
183
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
+ */
183
187
@ Nullable private AsyncUpdates asyncUpdates ;
184
188
private final ValueAnimator .AnimatorUpdateListener progressUpdateListener = animation -> {
185
189
if (getAsyncUpdatesEnabled ()) {
@@ -250,6 +254,7 @@ private enum OnVisibleAction {
250
254
@ IntDef ({RESTART , REVERSE })
251
255
@ Retention (RetentionPolicy .SOURCE )
252
256
public @interface RepeatMode {
257
+
253
258
}
254
259
255
260
/**
@@ -766,13 +771,14 @@ public void draw(Canvas canvas, Matrix matrix) {
766
771
}
767
772
}
768
773
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
+ }
774
780
} else {
775
- compositionLayer . draw (canvas , matrix , alpha );
781
+ draw (canvas , matrix , compositionLayer , alpha );
776
782
}
777
783
isDirty = false ;
778
784
} catch (InterruptedException e ) {
@@ -787,6 +793,17 @@ public void draw(Canvas canvas, Matrix matrix) {
787
793
}
788
794
}
789
795
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
+
790
807
// <editor-fold desc="animator">
791
808
792
809
@ MainThread
0 commit comments