summaryrefslogtreecommitdiff
path: root/core/java/android/widget/Scroller.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/widget/Scroller.java')
-rw-r--r--core/java/android/widget/Scroller.java26
1 files changed, 14 insertions, 12 deletions
diff --git a/core/java/android/widget/Scroller.java b/core/java/android/widget/Scroller.java
index 4cb0839036f2..23f72b6be989 100644
--- a/core/java/android/widget/Scroller.java
+++ b/core/java/android/widget/Scroller.java
@@ -50,8 +50,6 @@ public class Scroller {
private float mDurationReciprocal;
private float mDeltaX;
private float mDeltaY;
- private float mViscousFluidScale;
- private float mViscousFluidNormalize;
private boolean mFinished;
private Interpolator mInterpolator;
@@ -65,6 +63,17 @@ public class Scroller {
private final float mDeceleration;
+ private static float sViscousFluidScale;
+ private static float sViscousFluidNormalize;
+
+ static {
+ // This controls the viscous fluid effect (how much of it)
+ sViscousFluidScale = 8.0f;
+ // must be set to 1.0 (used in viscousFluid())
+ sViscousFluidNormalize = 1.0f;
+ sViscousFluidNormalize = 1.0f / viscousFluid(1.0f);
+ }
+
/**
* Create a Scroller with the default duration and interpolator.
*/
@@ -277,11 +286,6 @@ public class Scroller {
mDeltaX = dx;
mDeltaY = dy;
mDurationReciprocal = 1.0f / (float) mDuration;
- // This controls the viscous fluid effect (how much of it)
- mViscousFluidScale = 8.0f;
- // must be set to 1.0 (used in viscousFluid())
- mViscousFluidNormalize = 1.0f;
- mViscousFluidNormalize = 1.0f / viscousFluid(1.0f);
}
/**
@@ -339,11 +343,9 @@ public class Scroller {
mFinalY = Math.max(mFinalY, mMinY);
}
-
-
- private float viscousFluid(float x)
+ static float viscousFluid(float x)
{
- x *= mViscousFluidScale;
+ x *= sViscousFluidScale;
if (x < 1.0f) {
x -= (1.0f - (float)Math.exp(-x));
} else {
@@ -351,7 +353,7 @@ public class Scroller {
x = 1.0f - (float)Math.exp(1.0f - x);
x = start + x * (1.0f - start);
}
- x *= mViscousFluidNormalize;
+ x *= sViscousFluidNormalize;
return x;
}