OSDN Git Service

Add the ability to autoStart AID from xml
authorLeon Scroggins III <scroggo@google.com>
Wed, 21 Mar 2018 18:42:09 +0000 (14:42 -0400)
committerLeon Scroggins III <scroggo@google.com>
Thu, 22 Mar 2018 13:05:42 +0000 (09:05 -0400)
Bug: 73529437
Test: Ic818bbf1091d12631aedd6475d225fa4a708b29c
Change-Id: I4807409895a057e775bfee5dea407e8dc1af94be

core/res/res/values/attrs.xml
graphics/java/android/graphics/drawable/AnimatedImageDrawable.java

index 4a72bf9..f17c463 100644 (file)
              in the encoded data. Setting this to infinite (-1) will result in the
              animation repeating as long as it is displayed (once start() is called). -->
         <attr name="repeatCount"/>
+        <!-- When true, automatically start animating. The default is false, meaning
+             that the animation will not start until start() is called. -->
+        <attr name="autoStart" />
     </declare-styleable>
 
     <!-- Drawable used to draw bitmaps. -->
index c0f4920..598b5ee 100644 (file)
@@ -261,6 +261,12 @@ public class AnimatedImageDrawable extends Drawable implements Animatable2 {
         if (repeatCount != REPEAT_UNDEFINED) {
             this.setRepeatCount(repeatCount);
         }
+
+        boolean autoStart = a.getBoolean(
+                R.styleable.AnimatedImageDrawable_autoStart, false);
+        if (autoStart && mState.mNativePtr != 0) {
+            this.start();
+        }
     }
 
     /**