diff options
| author | shepshapard <shepshapard@google.com> | 2019-02-08 16:54:55 -0800 |
|---|---|---|
| committer | shepshapard <shepshapard@google.com> | 2019-02-14 14:08:58 -0800 |
| commit | 3b07045a3f80c434d570e6dbfc9015b598b604cc (patch) | |
| tree | cfb7e61bd63ae5fd5cfb0483e64629e86b7dcc82 /core/java/android/widget/ProgressBar.java | |
| parent | b9218244e61995da9dd47e9bdf8f61dccc2d0eb2 (diff) | |
Removing reflection access ProgressBar#mDuration
For the following reasons:
1. Developers can set this via XML
2. Using this value is inferior to setting an
indeterminate drawable that implements Animatable.
Fixes: 124052713
Test: No new implementation, so no tests.
Change-Id: Ie1e23f75328cce5d8f4d317625d8f38c0a166352
Diffstat (limited to 'core/java/android/widget/ProgressBar.java')
| -rw-r--r-- | core/java/android/widget/ProgressBar.java | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index 6b48c6584ad2..9be1466137a3 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -199,7 +199,9 @@ public class ProgressBar extends View { private boolean mMaxInitialized; private int mBehavior; - @UnsupportedAppUsage + // Better to define a Drawable that implements Animatable if you want to modify animation + // characteristics programatically. + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 124052713) private int mDuration; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private boolean mIndeterminate; @@ -277,7 +279,6 @@ public class ProgressBar extends View { } } - mDuration = a.getInt(R.styleable.ProgressBar_indeterminateDuration, mDuration); mMinWidth = a.getDimensionPixelSize(R.styleable.ProgressBar_minWidth, mMinWidth); @@ -702,7 +703,17 @@ public class ProgressBar extends View { /** * Define the drawable used to draw the progress bar in indeterminate mode. * + * <p>For the Drawable to animate, it must implement {@link Animatable}, or override + * {@link Drawable#onLevelChange(int)}. A Drawable that implements Animatable will be animated + * via that interface and therefore provides the greatest amount of customization. A Drawable + * that only overrides onLevelChange(int) is animated directly by ProgressBar and only the + * animation {@link android.R.styleable#ProgressBar_indeterminateDuration duration}, + * {@link android.R.styleable#ProgressBar_indeterminateBehavior repeating behavior}, and + * {@link #setInterpolator(Interpolator) interpolator} can be modified, and only before the + * indeterminate animation begins. + * * @param d the new drawable + * @attr ref android.R.styleable#ProgressBar_indeterminateDrawable * @see #getIndeterminateDrawable() * @see #setIndeterminate(boolean) */ @@ -1762,10 +1773,21 @@ public class ProgressBar extends View { /** * Sets the acceleration curve for the indeterminate animation. - * The interpolator is loaded as a resource from the specified context. + * + * <p>The interpolator is loaded as a resource from the specified context. Defaults to a linear + * interpolation. + * + * <p>The interpolator only affects the indeterminate animation if the + * {@link #setIndeterminateDrawable(Drawable) supplied indeterminate drawable} does not + * implement {@link Animatable}. + * + * <p>This call must be made before the indeterminate animation starts for it to have an affect. * * @param context The application environment * @param resID The resource identifier of the interpolator to load + * @attr ref android.R.styleable#ProgressBar_interpolator + * @see #setInterpolator(Interpolator) + * @see #getInterpolator() */ public void setInterpolator(Context context, @InterpolatorRes int resID) { setInterpolator(AnimationUtils.loadInterpolator(context, resID)); @@ -1775,7 +1797,17 @@ public class ProgressBar extends View { * Sets the acceleration curve for the indeterminate animation. * Defaults to a linear interpolation. * + * <p>The interpolator only affects the indeterminate animation if the + * {@link #setIndeterminateDrawable(Drawable) supplied indeterminate drawable} does not + * implement {@link Animatable}. + * + * <p>This call must be made before the indeterminate animation starts for it to have + * an affect. + * * @param interpolator The interpolator which defines the acceleration curve + * @attr ref android.R.styleable#ProgressBar_interpolator + * @see #setInterpolator(Context, int) + * @see #getInterpolator() */ public void setInterpolator(Interpolator interpolator) { mInterpolator = interpolator; @@ -1785,6 +1817,9 @@ public class ProgressBar extends View { * Gets the acceleration curve type for the indeterminate animation. * * @return the {@link Interpolator} associated to this animation + * @attr ref android.R.styleable#ProgressBar_interpolator + * @see #setInterpolator(Context, int) + * @see #setInterpolator(Interpolator) */ @InspectableProperty public Interpolator getInterpolator() { |
