Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Avoid unnecessary division in TextView.Marquee.tick.
Browse files Browse the repository at this point in the history
Test: Marquee.tick works
Change-Id: Idb2c1cadb6b49009f8bec45ad44a34f5636c0e79
  • Loading branch information
Tim Murray committed Dec 19, 2017
1 parent 53b2d74 commit fa83834
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/java/android/widget/TextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -11879,7 +11879,7 @@ private static final class Marquee {
private final Choreographer mChoreographer;

private byte mStatus = MARQUEE_STOPPED;
private final float mPixelsPerSecond;
private final float mPixelsPerMs;
private float mMaxScroll;
private float mMaxFadeScroll;
private float mGhostStart;
Expand All @@ -11892,7 +11892,7 @@ private static final class Marquee {

Marquee(TextView v) {
final float density = v.getContext().getResources().getDisplayMetrics().density;
mPixelsPerSecond = MARQUEE_DP_PER_SECOND * density;
mPixelsPerMs = MARQUEE_DP_PER_SECOND * density / 1000f;
mView = new WeakReference<TextView>(v);
mChoreographer = Choreographer.getInstance();
}
Expand Down Expand Up @@ -11937,7 +11937,7 @@ void tick() {
long currentMs = mChoreographer.getFrameTime();
long deltaMs = currentMs - mLastAnimationMs;
mLastAnimationMs = currentMs;
float deltaPx = deltaMs / 1000f * mPixelsPerSecond;
float deltaPx = deltaMs * mPixelsPerMs;
mScroll += deltaPx;
if (mScroll > mMaxScroll) {
mScroll = mMaxScroll;
Expand Down

0 comments on commit fa83834

Please sign in to comment.