summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2014-05-05 16:26:22 -0700
committerztenghui <ztenghui@google.com>2014-05-05 17:27:24 -0700
commit498213a265e05134b4a4fbf93dce69de1a47973c (patch)
treeb7e3ac490cefbc916c55dd84c60f37507c06b2bc /graphics
parent9f5957989ef8d1e2219b624d731acfbf61a366d2 (diff)
downloadframeworks_base-498213a265e05134b4a4fbf93dce69de1a47973c.zip
frameworks_base-498213a265e05134b4a4fbf93dce69de1a47973c.tar.gz
frameworks_base-498213a265e05134b4a4fbf93dce69de1a47973c.tar.bz2
First step on API cleaning on the VectorDrawable to disable animation support
Cleaning on the API level, and related tests. The animated icon will be only showing the initial state. TODO: Deep clean on the functionality part and attributes. Change-Id: I5723bc5b64f796c3a273d74bde02095751160a88
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/VectorDrawable.java152
1 files changed, 0 insertions, 152 deletions
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;