• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.airbnb.lottie.configurations.reducemotion;
2 
3 import android.content.Context;
4 import androidx.annotation.Nullable;
5 import com.airbnb.lottie.utils.Utils;
6 
7 /**
8  * Lottie animations with a "reduced motion" marker will play that marker instead of any other animations.
9  * This class uses {@link com.airbnb.lottie.utils.Utils#getAnimationScale(Context)} to determine if animations are disabled
10  * and if it should play the reduced motion marker.
11  *
12  * If the animation is provided a "reduced motion"
13  * marker name, they will be shown instead of the first or last frame. Supported marker names are case insensitive, and include:
14  * - reduced motion
15  * - reducedMotion
16  * - reduced_motion
17  * - reduced-motion
18  */
19 public class SystemReducedMotionOption implements ReducedMotionOption {
20 
21   @Override
getCurrentReducedMotionMode(@ullable Context context)22   public ReducedMotionMode getCurrentReducedMotionMode(@Nullable Context context) {
23     if (context == null || Utils.getAnimationScale(context) != 0f) {
24       return ReducedMotionMode.STANDARD_MOTION;
25     } else {
26       return ReducedMotionMode.REDUCED_MOTION;
27     }
28   }
29 }
30