Fixes for AnimationDrawable

Set up AnimationDrawable with an initial frame when it is
constructed from code (via addFrame()). This is equivalent to
what is done when it is constructed via xml resources.

Change-Id: I86784a241268aa2d03af8edecbc80a7cc3548e19
diff --git a/graphics/java/android/graphics/drawable/AnimationDrawable.java b/graphics/java/android/graphics/drawable/AnimationDrawable.java
index e275ba8..2220f96 100644
--- a/graphics/java/android/graphics/drawable/AnimationDrawable.java
+++ b/graphics/java/android/graphics/drawable/AnimationDrawable.java
@@ -62,7 +62,7 @@
  * AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
  *
  * // Start the animation (looped playback by default).
- * frameAnimation.start()
+ * frameAnimation.start();
  * </pre>
  * <p>For more information, see the guide to <a
  * href="{@docRoot}guide/topics/resources/animation-resource.html">Animation Resources</a>.</p>
@@ -192,6 +192,9 @@
      */
     public void addFrame(Drawable frame, int duration) {
         mAnimationState.addFrame(frame, duration);
+        if (mCurFrame < 0) {
+            setFrame(0, true, false);
+        }
     }
     
     private void nextFrame(boolean unschedule) {