Skip to content

Commit

Permalink
Internalize FakeR into AnimatorInflater and use actual constants from…
Browse files Browse the repository at this point in the history
… the platform R class.
  • Loading branch information
JakeWharton committed Dec 12, 2011
1 parent bc2c8f3 commit 34f275f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 72 deletions.
2 changes: 1 addition & 1 deletion library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<groupId>android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion library/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

android.library=true
# Project target.
target=android-4
target=android-14
59 changes: 44 additions & 15 deletions library/src/com/jakewharton/nineoldandroids/AnimatorInflater.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,35 @@
* <em>something</em> file.)
*/
public class AnimatorInflater {
private static final int[] AnimatorSet = new int[] {
/* 0 */ android.R.attr.ordering,
};
private static final int AnimatorSet_ordering = 0;

private static final int[] PropertyAnimator = new int[] {
/* 0 */ android.R.attr.propertyName,
};
private static final int PropertyAnimator_propertyName = 0;

private static final int[] Animator = new int[] {
/* 0 */ android.R.attr.duration,
/* 1 */ android.R.attr.startOffset,
/* 2 */ android.R.attr.valueType,
/* 3 */ android.R.attr.valueFrom,
/* 4 */ android.R.attr.valueTo,
/* 5 */ android.R.attr.repeatCount,
/* 6 */ android.R.attr.repeatMode,
/* 7 */ android.R.attr.interpolator,
};
private static final int Animator_duration = 0;
private static final int Animator_startOffset = 1;
private static final int Animator_valueType = 2;
private static final int Animator_valueFrom = 3;
private static final int Animator_valueTo = 4;
private static final int Animator_repeatCount = 5;
private static final int Animator_repeatMode = 6;
private static final int Animator_interpolator = 7;

/**
* These flags are used when parsing AnimatorSet objects
*/
Expand Down Expand Up @@ -119,8 +148,8 @@ private static Animator createAnimatorFromXml(Context c, XmlPullParser parser,
} else if (name.equals("set")) {
anim = new AnimatorSet();
TypedArray a = c.obtainStyledAttributes(attrs,
com.jakewharton.nineoldandroids.internal.FakeR.styleable.AnimatorSet);
int ordering = a.getInt(com.jakewharton.nineoldandroids.internal.FakeR.styleable.AnimatorSet_ordering,
/*com.android.internal.R.styleable.*/AnimatorSet);
int ordering = a.getInt(/*com.android.internal.R.styleable.*/AnimatorSet_ordering,
TOGETHER);
createAnimatorFromXml(c, parser, attrs, (AnimatorSet) anim, ordering);
a.recycle();
Expand Down Expand Up @@ -160,9 +189,9 @@ private static ObjectAnimator loadObjectAnimator(Context context, AttributeSet a
loadAnimator(context, attrs, anim);

TypedArray a =
context.obtainStyledAttributes(attrs, com.jakewharton.nineoldandroids.internal.FakeR.styleable.PropertyAnimator);
context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/PropertyAnimator);

String propertyName = a.getString(com.jakewharton.nineoldandroids.internal.FakeR.styleable.PropertyAnimator_propertyName);
String propertyName = a.getString(/*com.android.internal.R.styleable.*/PropertyAnimator_propertyName);

anim.setPropertyName(propertyName);

Expand All @@ -182,22 +211,22 @@ private static ValueAnimator loadAnimator(Context context, AttributeSet attrs, V
throws NotFoundException {

TypedArray a =
context.obtainStyledAttributes(attrs, com.jakewharton.nineoldandroids.internal.FakeR.styleable.Animator);
context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/Animator);

long duration = a.getInt(com.jakewharton.nineoldandroids.internal.FakeR.styleable.Animator_duration, 0);
long duration = a.getInt(/*com.android.internal.R.styleable.*/Animator_duration, 0);

long startDelay = a.getInt(com.jakewharton.nineoldandroids.internal.FakeR.styleable.Animator_startOffset, 0);
long startDelay = a.getInt(/*com.android.internal.R.styleable.*/Animator_startOffset, 0);

int valueType = a.getInt(com.jakewharton.nineoldandroids.internal.FakeR.styleable.Animator_valueType,
int valueType = a.getInt(/*com.android.internal.R.styleable.*/Animator_valueType,
VALUE_TYPE_FLOAT);

if (anim == null) {
anim = new ValueAnimator();
}
//TypeEvaluator evaluator = null;

int valueFromIndex = com.jakewharton.nineoldandroids.internal.FakeR.styleable.Animator_valueFrom;
int valueToIndex = com.jakewharton.nineoldandroids.internal.FakeR.styleable.Animator_valueTo;
int valueFromIndex = /*com.android.internal.R.styleable.*/Animator_valueFrom;
int valueToIndex = /*com.android.internal.R.styleable.*/Animator_valueTo;

boolean getFloats = (valueType == VALUE_TYPE_FLOAT);

Expand Down Expand Up @@ -287,21 +316,21 @@ private static ValueAnimator loadAnimator(Context context, AttributeSet attrs, V
anim.setDuration(duration);
anim.setStartDelay(startDelay);

if (a.hasValue(com.jakewharton.nineoldandroids.internal.FakeR.styleable.Animator_repeatCount)) {
if (a.hasValue(/*com.android.internal.R.styleable.*/Animator_repeatCount)) {
anim.setRepeatCount(
a.getInt(com.jakewharton.nineoldandroids.internal.FakeR.styleable.Animator_repeatCount, 0));
a.getInt(/*com.android.internal.R.styleable.*/Animator_repeatCount, 0));
}
if (a.hasValue(com.jakewharton.nineoldandroids.internal.FakeR.styleable.Animator_repeatMode)) {
if (a.hasValue(/*com.android.internal.R.styleable.*/Animator_repeatMode)) {
anim.setRepeatMode(
a.getInt(com.jakewharton.nineoldandroids.internal.FakeR.styleable.Animator_repeatMode,
a.getInt(/*com.android.internal.R.styleable.*/Animator_repeatMode,
ValueAnimator.RESTART));
}
//if (evaluator != null) {
// anim.setEvaluator(evaluator);
//}

final int resID =
a.getResourceId(com.jakewharton.nineoldandroids.internal.FakeR.styleable.Animator_interpolator, 0);
a.getResourceId(/*com.android.internal.R.styleable.*/Animator_interpolator, 0);
if (resID > 0) {
anim.setInterpolator(AnimationUtils.loadInterpolator(context, resID));
}
Expand Down
51 changes: 0 additions & 51 deletions library/src/com/jakewharton/nineoldandroids/internal/FakeR.java

This file was deleted.

6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<java.version>1.6</java.version>
<android.version>1.6_r2</android.version>
<android.platform>4</android.platform>
<android.version>4.0_r1</android.version>
<android.platform>14</android.platform>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>${android.version}</version>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<groupId>android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
Expand Down

0 comments on commit 34f275f

Please sign in to comment.