Merge "Revert "Animates AbsSeekBar progress movement from key presses."" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0a310c99ee
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package android.widget;
|
package android.widget;
|
||||||
|
|
||||||
import android.animation.ObjectAnimator;
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
@@ -65,9 +64,6 @@ public abstract class AbsSeekBar extends ProgressBar {
|
|||||||
* progress.
|
* progress.
|
||||||
*/
|
*/
|
||||||
private int mKeyProgressIncrement = 1;
|
private int mKeyProgressIncrement = 1;
|
||||||
private ObjectAnimator mPositionAnimator;
|
|
||||||
private static final int PROGRESS_ANIMATION_DURATION = 250;
|
|
||||||
|
|
||||||
|
|
||||||
private static final int NO_ALPHA = 0xFF;
|
private static final int NO_ALPHA = 0xFF;
|
||||||
private float mDisabledAlpha;
|
private float mDisabledAlpha;
|
||||||
@@ -388,14 +384,15 @@ public abstract class AbsSeekBar extends ProgressBar {
|
|||||||
void onProgressRefresh(float scale, boolean fromUser) {
|
void onProgressRefresh(float scale, boolean fromUser) {
|
||||||
super.onProgressRefresh(scale, fromUser);
|
super.onProgressRefresh(scale, fromUser);
|
||||||
|
|
||||||
if (!isAnimationRunning()) {
|
final Drawable thumb = mThumb;
|
||||||
setThumbPos(scale);
|
if (thumb != null) {
|
||||||
}
|
setThumbPos(getWidth(), thumb, scale, Integer.MIN_VALUE);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// Since we draw translated, the drawable's bounds that it signals
|
||||||
void onAnimatePosition(float scale, boolean fromUser) {
|
// for invalidation won't be the actual bounds we want invalidated,
|
||||||
setThumbPos(scale);
|
// so just invalidate this whole view.
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -440,18 +437,6 @@ public abstract class AbsSeekBar extends ProgressBar {
|
|||||||
return max > 0 ? getProgress() / (float) max : 0;
|
return max > 0 ? getProgress() / (float) max : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setThumbPos(float scale) {
|
|
||||||
final Drawable thumb = mThumb;
|
|
||||||
if (thumb != null) {
|
|
||||||
setThumbPos(getWidth(), thumb, scale, Integer.MIN_VALUE);
|
|
||||||
// Since we draw translated, the drawable's bounds that it signals
|
|
||||||
// for invalidation won't be the actual bounds we want invalidated,
|
|
||||||
// so just invalidate this whole view.
|
|
||||||
invalidate();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the thumb drawable bounds.
|
* Updates the thumb drawable bounds.
|
||||||
*
|
*
|
||||||
@@ -714,13 +699,13 @@ public abstract class AbsSeekBar extends ProgressBar {
|
|||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case KeyEvent.KEYCODE_DPAD_LEFT:
|
case KeyEvent.KEYCODE_DPAD_LEFT:
|
||||||
if (progress <= 0) break;
|
if (progress <= 0) break;
|
||||||
animateSetProgress(progress - mKeyProgressIncrement);
|
setProgress(progress - mKeyProgressIncrement, true);
|
||||||
onKeyChange();
|
onKeyChange();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
||||||
if (progress >= getMax()) break;
|
if (progress >= getMax()) break;
|
||||||
animateSetProgress(progress + mKeyProgressIncrement);
|
setProgress(progress + mKeyProgressIncrement, true);
|
||||||
onKeyChange();
|
onKeyChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -729,38 +714,6 @@ public abstract class AbsSeekBar extends ProgressBar {
|
|||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isAnimationRunning() {
|
|
||||||
return mPositionAnimator != null && mPositionAnimator.isRunning();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setProgress(int progress, boolean fromUser) {
|
|
||||||
if (isAnimationRunning()) {
|
|
||||||
mPositionAnimator.cancel();
|
|
||||||
}
|
|
||||||
super.setProgress(progress, fromUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
void animateSetProgress(int progress) {
|
|
||||||
float curProgress = isAnimationRunning() ? getAnimationPosition() : getProgress();
|
|
||||||
|
|
||||||
if (progress < 0) {
|
|
||||||
progress = 0;
|
|
||||||
} else if (progress > getMax()) {
|
|
||||||
progress = getMax();
|
|
||||||
}
|
|
||||||
setProgressValueOnly(progress);
|
|
||||||
|
|
||||||
mPositionAnimator = ObjectAnimator.ofFloat(this, "animationPosition", curProgress,
|
|
||||||
progress);
|
|
||||||
mPositionAnimator.setDuration(PROGRESS_ANIMATION_DURATION);
|
|
||||||
mPositionAnimator.setAutoCancel(true);
|
|
||||||
mPositionAnimator.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
|
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
|
||||||
super.onInitializeAccessibilityEvent(event);
|
super.onInitializeAccessibilityEvent(event);
|
||||||
|
|||||||
@@ -227,8 +227,6 @@ public class ProgressBar extends View {
|
|||||||
private long mUiThreadId;
|
private long mUiThreadId;
|
||||||
private boolean mShouldStartAnimationDrawable;
|
private boolean mShouldStartAnimationDrawable;
|
||||||
|
|
||||||
private float mAnimationPosition;
|
|
||||||
|
|
||||||
private boolean mInDrawing;
|
private boolean mInDrawing;
|
||||||
private boolean mAttached;
|
private boolean mAttached;
|
||||||
private boolean mRefreshIsPosted;
|
private boolean mRefreshIsPosted;
|
||||||
@@ -246,7 +244,7 @@ public class ProgressBar extends View {
|
|||||||
public ProgressBar(Context context) {
|
public ProgressBar(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProgressBar(Context context, AttributeSet attrs) {
|
public ProgressBar(Context context, AttributeSet attrs) {
|
||||||
this(context, attrs, com.android.internal.R.attr.progressBarStyle);
|
this(context, attrs, com.android.internal.R.attr.progressBarStyle);
|
||||||
}
|
}
|
||||||
@@ -263,9 +261,9 @@ public class ProgressBar extends View {
|
|||||||
|
|
||||||
final TypedArray a = context.obtainStyledAttributes(
|
final TypedArray a = context.obtainStyledAttributes(
|
||||||
attrs, R.styleable.ProgressBar, defStyleAttr, defStyleRes);
|
attrs, R.styleable.ProgressBar, defStyleAttr, defStyleRes);
|
||||||
|
|
||||||
mNoInvalidate = true;
|
mNoInvalidate = true;
|
||||||
|
|
||||||
final Drawable progressDrawable = a.getDrawable(R.styleable.ProgressBar_progressDrawable);
|
final Drawable progressDrawable = a.getDrawable(R.styleable.ProgressBar_progressDrawable);
|
||||||
if (progressDrawable != null) {
|
if (progressDrawable != null) {
|
||||||
// Calling this method can set mMaxHeight, make sure the corresponding
|
// Calling this method can set mMaxHeight, make sure the corresponding
|
||||||
@@ -284,11 +282,11 @@ public class ProgressBar extends View {
|
|||||||
mBehavior = a.getInt(R.styleable.ProgressBar_indeterminateBehavior, mBehavior);
|
mBehavior = a.getInt(R.styleable.ProgressBar_indeterminateBehavior, mBehavior);
|
||||||
|
|
||||||
final int resID = a.getResourceId(
|
final int resID = a.getResourceId(
|
||||||
com.android.internal.R.styleable.ProgressBar_interpolator,
|
com.android.internal.R.styleable.ProgressBar_interpolator,
|
||||||
android.R.anim.linear_interpolator); // default to linear interpolator
|
android.R.anim.linear_interpolator); // default to linear interpolator
|
||||||
if (resID > 0) {
|
if (resID > 0) {
|
||||||
setInterpolator(context, resID);
|
setInterpolator(context, resID);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMax(a.getInt(R.styleable.ProgressBar_max, mMax));
|
setMax(a.getInt(R.styleable.ProgressBar_max, mMax));
|
||||||
|
|
||||||
@@ -401,12 +399,12 @@ public class ProgressBar extends View {
|
|||||||
* traverse layer and state list drawables.
|
* traverse layer and state list drawables.
|
||||||
*/
|
*/
|
||||||
private Drawable tileify(Drawable drawable, boolean clip) {
|
private Drawable tileify(Drawable drawable, boolean clip) {
|
||||||
|
|
||||||
if (drawable instanceof LayerDrawable) {
|
if (drawable instanceof LayerDrawable) {
|
||||||
LayerDrawable background = (LayerDrawable) drawable;
|
LayerDrawable background = (LayerDrawable) drawable;
|
||||||
final int N = background.getNumberOfLayers();
|
final int N = background.getNumberOfLayers();
|
||||||
Drawable[] outDrawables = new Drawable[N];
|
Drawable[] outDrawables = new Drawable[N];
|
||||||
|
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
int id = background.getId(i);
|
int id = background.getId(i);
|
||||||
outDrawables[i] = tileify(background.getDrawable(i),
|
outDrawables[i] = tileify(background.getDrawable(i),
|
||||||
@@ -414,13 +412,13 @@ public class ProgressBar extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LayerDrawable newBg = new LayerDrawable(outDrawables);
|
LayerDrawable newBg = new LayerDrawable(outDrawables);
|
||||||
|
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
newBg.setId(i, background.getId(i));
|
newBg.setId(i, background.getId(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return newBg;
|
return newBg;
|
||||||
|
|
||||||
} else if (drawable instanceof StateListDrawable) {
|
} else if (drawable instanceof StateListDrawable) {
|
||||||
StateListDrawable in = (StateListDrawable) drawable;
|
StateListDrawable in = (StateListDrawable) drawable;
|
||||||
StateListDrawable out = new StateListDrawable();
|
StateListDrawable out = new StateListDrawable();
|
||||||
@@ -429,7 +427,7 @@ public class ProgressBar extends View {
|
|||||||
out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip));
|
out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip));
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
} else if (drawable instanceof BitmapDrawable) {
|
} else if (drawable instanceof BitmapDrawable) {
|
||||||
final BitmapDrawable bitmap = (BitmapDrawable) drawable;
|
final BitmapDrawable bitmap = (BitmapDrawable) drawable;
|
||||||
final Bitmap tileBitmap = bitmap.getBitmap();
|
final Bitmap tileBitmap = bitmap.getBitmap();
|
||||||
@@ -450,7 +448,7 @@ public class ProgressBar extends View {
|
|||||||
return clip ? new ClipDrawable(
|
return clip ? new ClipDrawable(
|
||||||
shapeDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL) : shapeDrawable;
|
shapeDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL) : shapeDrawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,7 +456,7 @@ public class ProgressBar extends View {
|
|||||||
final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
|
final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
|
||||||
return new RoundRectShape(roundedCorners, null, null);
|
return new RoundRectShape(roundedCorners, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a AnimationDrawable for use as a barberpole animation.
|
* Convert a AnimationDrawable for use as a barberpole animation.
|
||||||
* Each frame of the animation is wrapped in a ClipDrawable and
|
* Each frame of the animation is wrapped in a ClipDrawable and
|
||||||
@@ -470,7 +468,7 @@ public class ProgressBar extends View {
|
|||||||
final int N = background.getNumberOfFrames();
|
final int N = background.getNumberOfFrames();
|
||||||
AnimationDrawable newBg = new AnimationDrawable();
|
AnimationDrawable newBg = new AnimationDrawable();
|
||||||
newBg.setOneShot(background.isOneShot());
|
newBg.setOneShot(background.isOneShot());
|
||||||
|
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
Drawable frame = tileify(background.getFrame(i), true);
|
Drawable frame = tileify(background.getFrame(i), true);
|
||||||
frame.setLevel(10000);
|
frame.setLevel(10000);
|
||||||
@@ -481,7 +479,7 @@ public class ProgressBar extends View {
|
|||||||
}
|
}
|
||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Initialize the progress bar's default values:
|
* Initialize the progress bar's default values:
|
||||||
@@ -522,7 +520,7 @@ public class ProgressBar extends View {
|
|||||||
* <p>Change the indeterminate mode for this progress bar. In indeterminate
|
* <p>Change the indeterminate mode for this progress bar. In indeterminate
|
||||||
* mode, the progress is ignored and the progress bar shows an infinite
|
* mode, the progress is ignored and the progress bar shows an infinite
|
||||||
* animation instead.</p>
|
* animation instead.</p>
|
||||||
*
|
*
|
||||||
* If this progress bar's style only supports indeterminate mode (such as the circular
|
* If this progress bar's style only supports indeterminate mode (such as the circular
|
||||||
* progress bars), then this will be ignored.
|
* progress bars), then this will be ignored.
|
||||||
*
|
*
|
||||||
@@ -701,7 +699,7 @@ public class ProgressBar extends View {
|
|||||||
|
|
||||||
setIndeterminateDrawable(d);
|
setIndeterminateDrawable(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Get the drawable used to draw the progress bar in
|
* <p>Get the drawable used to draw the progress bar in
|
||||||
* progress mode.</p>
|
* progress mode.</p>
|
||||||
@@ -1137,7 +1135,7 @@ public class ProgressBar extends View {
|
|||||||
|
|
||||||
setProgressDrawable(d);
|
setProgressDrawable(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The drawable currently used to draw the progress bar
|
* @return The drawable currently used to draw the progress bar
|
||||||
*/
|
*/
|
||||||
@@ -1188,7 +1186,7 @@ public class ProgressBar extends View {
|
|||||||
final int count = mRefreshData.size();
|
final int count = mRefreshData.size();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
final RefreshData rd = mRefreshData.get(i);
|
final RefreshData rd = mRefreshData.get(i);
|
||||||
doRefreshProgress(rd.id, rd.progress, rd.fromUser, true, rd.animate);
|
doRefreshProgress(rd.id, rd.progress, rd.fromUser, true);
|
||||||
rd.recycle();
|
rd.recycle();
|
||||||
}
|
}
|
||||||
mRefreshData.clear();
|
mRefreshData.clear();
|
||||||
@@ -1203,12 +1201,10 @@ public class ProgressBar extends View {
|
|||||||
new SynchronizedPool<RefreshData>(POOL_MAX);
|
new SynchronizedPool<RefreshData>(POOL_MAX);
|
||||||
|
|
||||||
public int id;
|
public int id;
|
||||||
public float progress;
|
public int progress;
|
||||||
public boolean fromUser;
|
public boolean fromUser;
|
||||||
public boolean animate;
|
|
||||||
|
|
||||||
public static RefreshData obtain(int id, float progress, boolean fromUser,
|
public static RefreshData obtain(int id, int progress, boolean fromUser) {
|
||||||
boolean animate) {
|
|
||||||
RefreshData rd = sPool.acquire();
|
RefreshData rd = sPool.acquire();
|
||||||
if (rd == null) {
|
if (rd == null) {
|
||||||
rd = new RefreshData();
|
rd = new RefreshData();
|
||||||
@@ -1216,10 +1212,9 @@ public class ProgressBar extends View {
|
|||||||
rd.id = id;
|
rd.id = id;
|
||||||
rd.progress = progress;
|
rd.progress = progress;
|
||||||
rd.fromUser = fromUser;
|
rd.fromUser = fromUser;
|
||||||
rd.animate = animate;
|
|
||||||
return rd;
|
return rd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recycle() {
|
public void recycle() {
|
||||||
sPool.release(this);
|
sPool.release(this);
|
||||||
}
|
}
|
||||||
@@ -1243,19 +1238,9 @@ public class ProgressBar extends View {
|
|||||||
layer.setTintMode(tintMode);
|
layer.setTintMode(tintMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getScale(float progress) {
|
private synchronized void doRefreshProgress(int id, int progress, boolean fromUser,
|
||||||
return mMax > 0 ? progress / (float) mMax : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void doRefreshProgress(int id, float progress, boolean fromUser,
|
|
||||||
boolean callBackToApp) {
|
boolean callBackToApp) {
|
||||||
doRefreshProgress(id, progress, fromUser, callBackToApp, false);
|
float scale = mMax > 0 ? (float) progress / (float) mMax : 0;
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void doRefreshProgress(int id, float progress, boolean fromUser,
|
|
||||||
boolean callBackToApp, boolean animate) {
|
|
||||||
float scale = getScale(progress);
|
|
||||||
|
|
||||||
final Drawable d = mCurrentDrawable;
|
final Drawable d = mCurrentDrawable;
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
Drawable progressDrawable = null;
|
Drawable progressDrawable = null;
|
||||||
@@ -1272,65 +1257,27 @@ public class ProgressBar extends View {
|
|||||||
} else {
|
} else {
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == R.id.progress) {
|
if (callBackToApp && id == R.id.progress) {
|
||||||
if (animate) {
|
onProgressRefresh(scale, fromUser);
|
||||||
onAnimatePosition(scale, fromUser);
|
|
||||||
} else if (callBackToApp) {
|
|
||||||
onProgressRefresh(scale, fromUser);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a ProgressBar is animating its position.
|
|
||||||
*
|
|
||||||
* @param scale Current position/progress between 0 and 1.
|
|
||||||
* @param fromUser True if the progress change was initiated by the user.
|
|
||||||
*/
|
|
||||||
void onAnimatePosition(float scale, boolean fromUser) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the progress value without going through the entire refresh process.
|
|
||||||
*
|
|
||||||
* @see #setProgress(int, boolean)
|
|
||||||
* @param progress The new progress, between 0 and {@link #getMax()}
|
|
||||||
*/
|
|
||||||
void setProgressValueOnly(int progress) {
|
|
||||||
mProgress = progress;
|
|
||||||
onProgressRefresh(getScale(progress), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setAnimationPosition(float position) {
|
|
||||||
mAnimationPosition = position;
|
|
||||||
refreshProgress(R.id.progress, position, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
float getAnimationPosition() {
|
|
||||||
return mAnimationPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
void onProgressRefresh(float scale, boolean fromUser) {
|
void onProgressRefresh(float scale, boolean fromUser) {
|
||||||
if (AccessibilityManager.getInstance(mContext).isEnabled()) {
|
if (AccessibilityManager.getInstance(mContext).isEnabled()) {
|
||||||
scheduleAccessibilityEventSender();
|
scheduleAccessibilityEventSender();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void refreshProgress(int id, float progress, boolean fromUser) {
|
private synchronized void refreshProgress(int id, int progress, boolean fromUser) {
|
||||||
refreshProgress(id, progress, fromUser, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void refreshProgress(int id, float progress, boolean fromUser,
|
|
||||||
boolean animate) {
|
|
||||||
if (mUiThreadId == Thread.currentThread().getId()) {
|
if (mUiThreadId == Thread.currentThread().getId()) {
|
||||||
doRefreshProgress(id, progress, fromUser, true, animate);
|
doRefreshProgress(id, progress, fromUser, true);
|
||||||
} else {
|
} else {
|
||||||
if (mRefreshProgressRunnable == null) {
|
if (mRefreshProgressRunnable == null) {
|
||||||
mRefreshProgressRunnable = new RefreshProgressRunnable();
|
mRefreshProgressRunnable = new RefreshProgressRunnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
final RefreshData rd = RefreshData.obtain(id, progress, fromUser, animate);
|
final RefreshData rd = RefreshData.obtain(id, progress, fromUser);
|
||||||
mRefreshData.add(rd);
|
mRefreshData.add(rd);
|
||||||
if (mAttached && !mRefreshIsPosted) {
|
if (mAttached && !mRefreshIsPosted) {
|
||||||
post(mRefreshProgressRunnable);
|
post(mRefreshProgressRunnable);
|
||||||
@@ -1338,7 +1285,7 @@ public class ProgressBar extends View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Set the current progress to the specified value. Does not do anything
|
* <p>Set the current progress to the specified value. Does not do anything
|
||||||
* if the progress bar is in indeterminate mode.</p>
|
* if the progress bar is in indeterminate mode.</p>
|
||||||
@@ -1348,13 +1295,13 @@ public class ProgressBar extends View {
|
|||||||
* @see #setIndeterminate(boolean)
|
* @see #setIndeterminate(boolean)
|
||||||
* @see #isIndeterminate()
|
* @see #isIndeterminate()
|
||||||
* @see #getProgress()
|
* @see #getProgress()
|
||||||
* @see #incrementProgressBy(int)
|
* @see #incrementProgressBy(int)
|
||||||
*/
|
*/
|
||||||
@android.view.RemotableViewMethod
|
@android.view.RemotableViewMethod
|
||||||
public synchronized void setProgress(int progress) {
|
public synchronized void setProgress(int progress) {
|
||||||
setProgress(progress, false);
|
setProgress(progress, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@android.view.RemotableViewMethod
|
@android.view.RemotableViewMethod
|
||||||
synchronized void setProgress(int progress, boolean fromUser) {
|
synchronized void setProgress(int progress, boolean fromUser) {
|
||||||
if (mIndeterminate) {
|
if (mIndeterminate) {
|
||||||
@@ -1380,7 +1327,7 @@ public class ProgressBar extends View {
|
|||||||
* Set the current secondary progress to the specified value. Does not do
|
* Set the current secondary progress to the specified value. Does not do
|
||||||
* anything if the progress bar is in indeterminate mode.
|
* anything if the progress bar is in indeterminate mode.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param secondaryProgress the new secondary progress, between 0 and {@link #getMax()}
|
* @param secondaryProgress the new secondary progress, between 0 and {@link #getMax()}
|
||||||
* @see #setIndeterminate(boolean)
|
* @see #setIndeterminate(boolean)
|
||||||
* @see #isIndeterminate()
|
* @see #isIndeterminate()
|
||||||
@@ -1461,8 +1408,8 @@ public class ProgressBar extends View {
|
|||||||
* @param max the upper range of this progress bar
|
* @param max the upper range of this progress bar
|
||||||
*
|
*
|
||||||
* @see #getMax()
|
* @see #getMax()
|
||||||
* @see #setProgress(int)
|
* @see #setProgress(int)
|
||||||
* @see #setSecondaryProgress(int)
|
* @see #setSecondaryProgress(int)
|
||||||
*/
|
*/
|
||||||
@android.view.RemotableViewMethod
|
@android.view.RemotableViewMethod
|
||||||
public synchronized void setMax(int max) {
|
public synchronized void setMax(int max) {
|
||||||
@@ -1479,13 +1426,13 @@ public class ProgressBar extends View {
|
|||||||
refreshProgress(R.id.progress, mProgress, false);
|
refreshProgress(R.id.progress, mProgress, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Increase the progress bar's progress by the specified amount.</p>
|
* <p>Increase the progress bar's progress by the specified amount.</p>
|
||||||
*
|
*
|
||||||
* @param diff the amount by which the progress must be increased
|
* @param diff the amount by which the progress must be increased
|
||||||
*
|
*
|
||||||
* @see #setProgress(int)
|
* @see #setProgress(int)
|
||||||
*/
|
*/
|
||||||
public synchronized final void incrementProgressBy(int diff) {
|
public synchronized final void incrementProgressBy(int diff) {
|
||||||
setProgress(mProgress + diff);
|
setProgress(mProgress + diff);
|
||||||
@@ -1496,7 +1443,7 @@ public class ProgressBar extends View {
|
|||||||
*
|
*
|
||||||
* @param diff the amount by which the secondary progress must be increased
|
* @param diff the amount by which the secondary progress must be increased
|
||||||
*
|
*
|
||||||
* @see #setSecondaryProgress(int)
|
* @see #setSecondaryProgress(int)
|
||||||
*/
|
*/
|
||||||
public synchronized final void incrementSecondaryProgressBy(int diff) {
|
public synchronized final void incrementSecondaryProgressBy(int diff) {
|
||||||
setSecondaryProgress(mSecondaryProgress + diff);
|
setSecondaryProgress(mSecondaryProgress + diff);
|
||||||
@@ -1519,13 +1466,13 @@ public class ProgressBar extends View {
|
|||||||
if (mInterpolator == null) {
|
if (mInterpolator == null) {
|
||||||
mInterpolator = new LinearInterpolator();
|
mInterpolator = new LinearInterpolator();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTransformation == null) {
|
if (mTransformation == null) {
|
||||||
mTransformation = new Transformation();
|
mTransformation = new Transformation();
|
||||||
} else {
|
} else {
|
||||||
mTransformation.clear();
|
mTransformation.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAnimation == null) {
|
if (mAnimation == null) {
|
||||||
mAnimation = new AlphaAnimation(0.0f, 1.0f);
|
mAnimation = new AlphaAnimation(0.0f, 1.0f);
|
||||||
} else {
|
} else {
|
||||||
@@ -1676,7 +1623,7 @@ public class ProgressBar extends View {
|
|||||||
}
|
}
|
||||||
mIndeterminateDrawable.setBounds(left, top, right, bottom);
|
mIndeterminateDrawable.setBounds(left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mProgressDrawable != null) {
|
if (mProgressDrawable != null) {
|
||||||
mProgressDrawable.setBounds(0, 0, right, bottom);
|
mProgressDrawable.setBounds(0, 0, right, bottom);
|
||||||
}
|
}
|
||||||
@@ -1746,20 +1693,20 @@ public class ProgressBar extends View {
|
|||||||
setMeasuredDimension(resolveSizeAndState(dw, widthMeasureSpec, 0),
|
setMeasuredDimension(resolveSizeAndState(dw, widthMeasureSpec, 0),
|
||||||
resolveSizeAndState(dh, heightMeasureSpec, 0));
|
resolveSizeAndState(dh, heightMeasureSpec, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawableStateChanged() {
|
protected void drawableStateChanged() {
|
||||||
super.drawableStateChanged();
|
super.drawableStateChanged();
|
||||||
updateDrawableState();
|
updateDrawableState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDrawableState() {
|
private void updateDrawableState() {
|
||||||
int[] state = getDrawableState();
|
int[] state = getDrawableState();
|
||||||
|
|
||||||
if (mProgressDrawable != null && mProgressDrawable.isStateful()) {
|
if (mProgressDrawable != null && mProgressDrawable.isStateful()) {
|
||||||
mProgressDrawable.setState(state);
|
mProgressDrawable.setState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIndeterminateDrawable != null && mIndeterminateDrawable.isStateful()) {
|
if (mIndeterminateDrawable != null && mIndeterminateDrawable.isStateful()) {
|
||||||
mIndeterminateDrawable.setState(state);
|
mIndeterminateDrawable.setState(state);
|
||||||
}
|
}
|
||||||
@@ -1781,14 +1728,14 @@ public class ProgressBar extends View {
|
|||||||
static class SavedState extends BaseSavedState {
|
static class SavedState extends BaseSavedState {
|
||||||
int progress;
|
int progress;
|
||||||
int secondaryProgress;
|
int secondaryProgress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor called from {@link ProgressBar#onSaveInstanceState()}
|
* Constructor called from {@link ProgressBar#onSaveInstanceState()}
|
||||||
*/
|
*/
|
||||||
SavedState(Parcelable superState) {
|
SavedState(Parcelable superState) {
|
||||||
super(superState);
|
super(superState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor called from {@link #CREATOR}
|
* Constructor called from {@link #CREATOR}
|
||||||
*/
|
*/
|
||||||
@@ -1822,10 +1769,10 @@ public class ProgressBar extends View {
|
|||||||
// Force our ancestor class to save its state
|
// Force our ancestor class to save its state
|
||||||
Parcelable superState = super.onSaveInstanceState();
|
Parcelable superState = super.onSaveInstanceState();
|
||||||
SavedState ss = new SavedState(superState);
|
SavedState ss = new SavedState(superState);
|
||||||
|
|
||||||
ss.progress = mProgress;
|
ss.progress = mProgress;
|
||||||
ss.secondaryProgress = mSecondaryProgress;
|
ss.secondaryProgress = mSecondaryProgress;
|
||||||
|
|
||||||
return ss;
|
return ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1833,7 +1780,7 @@ public class ProgressBar extends View {
|
|||||||
public void onRestoreInstanceState(Parcelable state) {
|
public void onRestoreInstanceState(Parcelable state) {
|
||||||
SavedState ss = (SavedState) state;
|
SavedState ss = (SavedState) state;
|
||||||
super.onRestoreInstanceState(ss.getSuperState());
|
super.onRestoreInstanceState(ss.getSuperState());
|
||||||
|
|
||||||
setProgress(ss.progress);
|
setProgress(ss.progress);
|
||||||
setSecondaryProgress(ss.secondaryProgress);
|
setSecondaryProgress(ss.secondaryProgress);
|
||||||
}
|
}
|
||||||
@@ -1849,7 +1796,7 @@ public class ProgressBar extends View {
|
|||||||
final int count = mRefreshData.size();
|
final int count = mRefreshData.size();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
final RefreshData rd = mRefreshData.get(i);
|
final RefreshData rd = mRefreshData.get(i);
|
||||||
doRefreshProgress(rd.id, rd.progress, rd.fromUser, rd.animate);
|
doRefreshProgress(rd.id, rd.progress, rd.fromUser, true);
|
||||||
rd.recycle();
|
rd.recycle();
|
||||||
}
|
}
|
||||||
mRefreshData.clear();
|
mRefreshData.clear();
|
||||||
|
|||||||
@@ -314,10 +314,6 @@ public class RatingBar extends AbsSeekBar {
|
|||||||
dispatchRatingChange(true);
|
dispatchRatingChange(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
void animateSetProgress(int progress) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void dispatchRatingChange(boolean fromUser) {
|
void dispatchRatingChange(boolean fromUser) {
|
||||||
if (mOnRatingBarChangeListener != null) {
|
if (mOnRatingBarChangeListener != null) {
|
||||||
mOnRatingBarChangeListener.onRatingChanged(this, getRating(),
|
mOnRatingBarChangeListener.onRatingChanged(this, getRating(),
|
||||||
|
|||||||
Reference in New Issue
Block a user