diff options
4 files changed, 2 insertions, 187 deletions
diff --git a/api/current.txt b/api/current.txt index 60618d4..9acf72a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -11231,19 +11231,11 @@ package android.graphics.drawable { public class VectorDrawable extends android.graphics.drawable.Drawable { ctor public VectorDrawable(); method public void draw(android.graphics.Canvas); - method public float geAnimationFraction(); method public int getOpacity(); - method public int getRepeatCount(); method public void setAlpha(int); - method public void setAnimationFraction(float); method public void setColorFilter(android.graphics.ColorFilter); - method public void setDuration(long); method public void setPadding(android.graphics.Rect); method public void setPadding(int, int, int, int); - method public void setRepeatCount(int); - method public void setRepeatMode(int); - method public void start(); - method public void stop(); } } diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java index 0992717..77712b6 100644 --- a/graphics/java/android/graphics/drawable/VectorDrawable.java +++ b/graphics/java/android/graphics/drawable/VectorDrawable.java @@ -182,28 +182,14 @@ public class VectorDrawable extends Drawable { public VectorDrawable() { mVectorState = new VectorDrawableState(null); - mVectorState.mBasicAnimator = ObjectAnimator.ofFloat(this, "AnimationFraction", 0, 0); - - setDuration(DEFAULT_DURATION); } private VectorDrawable(VectorDrawableState state, Resources res, Theme theme) { mVectorState = new VectorDrawableState(state); - mVectorState.mBasicAnimator = ObjectAnimator.ofFloat(this, "AnimationFraction", 0, 0); if (theme != null && canApplyTheme()) { applyTheme(theme); } - - long duration = mVectorState.mVAnimatedPath.getTotalAnimationDuration(); - if (duration == -1) { - // If duration is infinite, set to 1 hour. - // TODO: Define correct approach for infinite. - duration = DEFAULT_INFINITE_DURATION; - mVectorState.mBasicAnimator.setFloatValues(0, duration / 1000); - mVectorState.mBasicAnimator.setInterpolator(new LinearInterpolator()); - } - setDuration(duration); } @Override @@ -212,118 +198,6 @@ public class VectorDrawable extends Drawable { } @Override - public void jumpToCurrentState() { - stop(); - } - - /** - * Starts the animation. - */ - public void start() { - mVectorState.mBasicAnimator.start(); - } - - /** - * Stops the animation and moves to the end state. - */ - public void stop() { - mVectorState.mBasicAnimator.end(); - } - - /** - * Returns the current completion value for the animation. - * - * @return the current point on the animation, typically between 0 and 1 - */ - public float geAnimationFraction() { - return mVectorState.mVAnimatedPath.getValue(); - } - - /** - * Set the current completion value for the animation. - * - * @param value the point along the animation, typically between 0 and 1 - */ - public void setAnimationFraction(float value) { - mVectorState.mVAnimatedPath.setAnimationFraction(value); - invalidateSelf(); - } - - /** - * set the amount of time the animation will take - * - * @param duration amount of time in milliseconds - */ - public void setDuration(long duration) { - mVectorState.mBasicAnimator.setDuration(duration); - } - - /** - * Defines what this animation should do when it reaches the end. This - * setting is applied only when the repeat count is either greater than 0 or - * {@link ValueAnimator#INFINITE}. - * - * @param mode the animation mode, either {@link ValueAnimator#RESTART} or - * {@link ValueAnimator#REVERSE} - */ - public void setRepeatMode(int mode) { - mVectorState.mBasicAnimator.setRepeatMode(mode); - } - - /** - * Sets animation to repeat - * - * @param repeat True if this drawable repeats its animation - */ - public void setRepeatCount(int repeat) { - mVectorState.mBasicAnimator.setRepeatCount(repeat); - } - - /** - * @return the animation repeat count, either a value greater than 0 or - * {@link ValueAnimator#INFINITE} - */ - public int getRepeatCount() { - return mVectorState.mBasicAnimator.getRepeatCount(); - } - - @Override - public boolean isStateful() { - return true; - } - - @Override - protected boolean onStateChange(int[] state) { - super.onStateChange(state); - - mVectorState.mVAnimatedPath.setState(state); - - final int direction = mVectorState.mVAnimatedPath.getTrigger(state); - if (direction > 0) { - animateForward(); - } else if (direction < 0) { - animateBackward(); - } - - invalidateSelf(); - return true; - } - - private void animateForward() { - if (!mVectorState.mBasicAnimator.isStarted()) { - mVectorState.mBasicAnimator.setFloatValues(0, 1); - start(); - } - } - - private void animateBackward() { - if (!mVectorState.mBasicAnimator.isStarted()) { - mVectorState.mBasicAnimator.setFloatValues(1, 0); - start(); - } - } - - @Override public void draw(Canvas canvas) { final int saveCount = canvas.save(); final Rect bounds = getBounds(); @@ -432,7 +306,6 @@ public class VectorDrawable extends Drawable { final VectorDrawable drawable = new VectorDrawable(); drawable.inflate(resources, xpp, attrs); - drawable.setAnimationFraction(0); return drawable; } catch (XmlPullParserException e) { @@ -536,35 +409,10 @@ public class VectorDrawable extends Drawable { private void setAnimatedPath(VAnimatedPath animatedPath) { mVectorState.mVAnimatedPath = animatedPath; - - long duration = mVectorState.mVAnimatedPath.getTotalAnimationDuration(); - if (duration == -1) { // if it set to infinite set to 1 hour - duration = DEFAULT_INFINITE_DURATION; // TODO define correct - // approach for infinite - mVectorState.mBasicAnimator.setFloatValues(0, duration / 1000); - mVectorState.mBasicAnimator.setInterpolator(new LinearInterpolator()); - } - - setDuration(duration); - setAnimationFraction(0); - } - - @Override - public boolean setVisible(boolean visible, boolean restart) { - boolean changed = super.setVisible(visible, restart); - if (visible) { - if (changed || restart) { - setAnimationFraction(0); - } - } else { - stop(); - } - return changed; } private static class VectorDrawableState extends ConstantState { int mChangingConfigurations; - ValueAnimator mBasicAnimator; VAnimatedPath mVAnimatedPath; Rect mPadding; diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawable01.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawable01.java index 88ae398..7ba01b1 100644 --- a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawable01.java +++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawable01.java @@ -22,7 +22,7 @@ import android.widget.Button; import android.widget.GridLayout; @SuppressWarnings({"UnusedDeclaration"}) -public class VectorDrawable01 extends Activity implements View.OnClickListener { +public class VectorDrawable01 extends Activity { private static final String LOGCAT = "VectorDrawable1"; int[] icon = { R.drawable.vector_drawable01, @@ -61,28 +61,10 @@ public class VectorDrawable01 extends Activity implements View.OnClickListener { button.setWidth(200); button.setBackgroundResource(icon[i]); container.addView(button); - button.setOnClickListener(this); } - Button b = new Button(this); - b.setText("Run All"); - b.setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v) { - for (int i = 0; i < bArray.length; i++) { - VectorDrawable d = (VectorDrawable) bArray[i].getBackground(); - d.start(); - } - }}); - container.addView(b); setContentView(container); } - @Override - public void onClick(View v) { - VectorDrawable d = (VectorDrawable) v.getBackground(); - d.start(); - } - } diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java index 3929298..b918cdd 100644 --- a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java +++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java @@ -25,7 +25,7 @@ import android.widget.ScrollView; import java.text.DecimalFormat; @SuppressWarnings({"UnusedDeclaration"}) -public class VectorDrawablePerformance extends Activity implements View.OnClickListener { +public class VectorDrawablePerformance extends Activity { private static final String LOGCAT = "VectorDrawable1"; protected int[] icon = { R.drawable.vector_drawable01, @@ -76,7 +76,6 @@ public class VectorDrawablePerformance extends Activity implements View.OnClickL button.setWidth(200); button.setBackgroundResource(icon[i]); container.addView(button); - button.setOnClickListener(this); } setContentView(scrollView); time = android.os.SystemClock.elapsedRealtimeNanos()-time; @@ -85,10 +84,4 @@ public class VectorDrawablePerformance extends Activity implements View.OnClickL t.setBackgroundColor(0xFF000000); container.addView(t); } - - @Override - public void onClick(View v) { - VectorDrawable d = (VectorDrawable) v.getBackground(); - d.start(); - } } |