Interpolator.Result.FREEZE_END) {
cache.state = ScrollabilityCache.OFF;
} else {
- cache.scrollBar.setAlpha(Math.round(values[0]));
+ cache.scrollBar.mutate().setAlpha(Math.round(values[0]));
}
// This will make the scroll bars inval themselves after
} else {
// We're just on -- but we may have been fading before so
// reset alpha
- cache.scrollBar.setAlpha(255);
+ cache.scrollBar.mutate().setAlpha(255);
}
private final Rect mTempBounds = new Rect();
private boolean mAlwaysDrawHorizontalTrack;
private boolean mAlwaysDrawVerticalTrack;
+ private boolean mMutated;
public ScrollBarDrawable() {
}
public void setVerticalThumbDrawable(Drawable thumb) {
if (thumb != null) {
+ if (mMutated) {
+ thumb.mutate();
+ }
thumb.setState(STATE_ENABLED);
mVerticalThumb = thumb;
}
public void setVerticalTrackDrawable(Drawable track) {
if (track != null) {
+ if (mMutated) {
+ track.mutate();
+ }
track.setState(STATE_ENABLED);
}
mVerticalTrack = track;
public void setHorizontalThumbDrawable(Drawable thumb) {
if (thumb != null) {
+ if (mMutated) {
+ thumb.mutate();
+ }
thumb.setState(STATE_ENABLED);
mHorizontalThumb = thumb;
}
public void setHorizontalTrackDrawable(Drawable track) {
if (track != null) {
+ if (mMutated) {
+ track.mutate();
+ }
track.setState(STATE_ENABLED);
}
mHorizontalTrack = track;
}
@Override
+ public ScrollBarDrawable mutate() {
+ if (!mMutated && super.mutate() == this) {
+ if (mVerticalTrack != null) {
+ mVerticalTrack.mutate();
+ }
+ if (mVerticalThumb != null) {
+ mVerticalThumb.mutate();
+ }
+ if (mHorizontalTrack != null) {
+ mHorizontalTrack.mutate();
+ }
+ if (mHorizontalThumb != null) {
+ mHorizontalThumb.mutate();
+ }
+ mMutated = true;
+ }
+ return this;
+ }
+
+ @Override
public void setAlpha(int alpha) {
if (mVerticalTrack != null) {
mVerticalTrack.setAlpha(alpha);