* commit '80b381c0736c1af43801b8ed26428abdf4d437b3': Mutate scroll bar drawables
This commit is contained in:
@@ -12872,7 +12872,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
|||||||
Interpolator.Result.FREEZE_END) {
|
Interpolator.Result.FREEZE_END) {
|
||||||
cache.state = ScrollabilityCache.OFF;
|
cache.state = ScrollabilityCache.OFF;
|
||||||
} else {
|
} 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
|
// This will make the scroll bars inval themselves after
|
||||||
@@ -12882,7 +12882,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
|||||||
} else {
|
} else {
|
||||||
// We're just on -- but we may have been fading before so
|
// We're just on -- but we may have been fading before so
|
||||||
// reset alpha
|
// reset alpha
|
||||||
cache.scrollBar.setAlpha(255);
|
cache.scrollBar.mutate().setAlpha(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public class ScrollBarDrawable extends Drawable {
|
|||||||
private final Rect mTempBounds = new Rect();
|
private final Rect mTempBounds = new Rect();
|
||||||
private boolean mAlwaysDrawHorizontalTrack;
|
private boolean mAlwaysDrawHorizontalTrack;
|
||||||
private boolean mAlwaysDrawVerticalTrack;
|
private boolean mAlwaysDrawVerticalTrack;
|
||||||
|
private boolean mMutated;
|
||||||
|
|
||||||
public ScrollBarDrawable() {
|
public ScrollBarDrawable() {
|
||||||
}
|
}
|
||||||
@@ -191,6 +192,9 @@ public class ScrollBarDrawable extends Drawable {
|
|||||||
|
|
||||||
public void setVerticalThumbDrawable(Drawable thumb) {
|
public void setVerticalThumbDrawable(Drawable thumb) {
|
||||||
if (thumb != null) {
|
if (thumb != null) {
|
||||||
|
if (mMutated) {
|
||||||
|
thumb.mutate();
|
||||||
|
}
|
||||||
thumb.setState(STATE_ENABLED);
|
thumb.setState(STATE_ENABLED);
|
||||||
mVerticalThumb = thumb;
|
mVerticalThumb = thumb;
|
||||||
}
|
}
|
||||||
@@ -198,6 +202,9 @@ public class ScrollBarDrawable extends Drawable {
|
|||||||
|
|
||||||
public void setVerticalTrackDrawable(Drawable track) {
|
public void setVerticalTrackDrawable(Drawable track) {
|
||||||
if (track != null) {
|
if (track != null) {
|
||||||
|
if (mMutated) {
|
||||||
|
track.mutate();
|
||||||
|
}
|
||||||
track.setState(STATE_ENABLED);
|
track.setState(STATE_ENABLED);
|
||||||
}
|
}
|
||||||
mVerticalTrack = track;
|
mVerticalTrack = track;
|
||||||
@@ -205,6 +212,9 @@ public class ScrollBarDrawable extends Drawable {
|
|||||||
|
|
||||||
public void setHorizontalThumbDrawable(Drawable thumb) {
|
public void setHorizontalThumbDrawable(Drawable thumb) {
|
||||||
if (thumb != null) {
|
if (thumb != null) {
|
||||||
|
if (mMutated) {
|
||||||
|
thumb.mutate();
|
||||||
|
}
|
||||||
thumb.setState(STATE_ENABLED);
|
thumb.setState(STATE_ENABLED);
|
||||||
mHorizontalThumb = thumb;
|
mHorizontalThumb = thumb;
|
||||||
}
|
}
|
||||||
@@ -212,6 +222,9 @@ public class ScrollBarDrawable extends Drawable {
|
|||||||
|
|
||||||
public void setHorizontalTrackDrawable(Drawable track) {
|
public void setHorizontalTrackDrawable(Drawable track) {
|
||||||
if (track != null) {
|
if (track != null) {
|
||||||
|
if (mMutated) {
|
||||||
|
track.mutate();
|
||||||
|
}
|
||||||
track.setState(STATE_ENABLED);
|
track.setState(STATE_ENABLED);
|
||||||
}
|
}
|
||||||
mHorizontalTrack = track;
|
mHorizontalTrack = track;
|
||||||
@@ -227,6 +240,26 @@ public class ScrollBarDrawable extends Drawable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
public void setAlpha(int alpha) {
|
public void setAlpha(int alpha) {
|
||||||
if (mVerticalTrack != null) {
|
if (mVerticalTrack != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user