Skip to content

Commit 4766def

Browse files
Andreas AgvardJohan Redestig
authored andcommitted
Fixed Android animation framework, for using interpolators that do not start at 0.0f
There is a bug that affects interpolators that do not return 0.0f when given 0.0f as input. All default interpolators in Android do return 0.0f, which is why it hasn't been noticed. Some custom interpolators can for example run backwards, returning 1.0f when given input 0.0f.
1 parent 8ab11f8 commit 4766def

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

core/java/android/view/animation/Animation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ public void initializeInvalidateRegion(int left, int top, int right, int bottom)
880880
region.inset(-1.0f, -1.0f);
881881
if (mFillBefore) {
882882
final Transformation previousTransformation = mPreviousTransformation;
883-
applyTransformation(0.0f, previousTransformation);
883+
applyTransformation(mInterpolator.getInterpolation(0.0f), previousTransformation);
884884
}
885885
}
886886

core/java/android/view/animation/AnimationSet.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ public void initializeInvalidateRegion(int left, int top, int right, int bottom)
282282
final Animation a = animations.get(i);
283283

284284
temp.clear();
285-
a.applyTransformation(0.0f, temp);
285+
final Interpolator interpolator = a.mInterpolator;
286+
a.applyTransformation(interpolator != null ? interpolator.getInterpolation(0.0f)
287+
: 0.0f, temp);
286288
previousTransformation.compose(temp);
287289
}
288290
}

0 commit comments

Comments
 (0)