Merge "Override View.drawableStateChanged to detect state_pressed"

main
Tadashi G. Takaoka 2013-05-01 05:04:44 +00:00 committed by Android (Google) Code Review
commit 17a353831a
1 changed files with 23 additions and 8 deletions

View File

@ -51,11 +51,32 @@ public final class SetupStartIndicatorView extends LinearLayout {
mIndicatorView = indicatorView;
}
// TODO: Once we stop supporting ICS, uncomment {@link #setPressed(boolean)} method and
// remove this method.
@Override
public void setPressed(final boolean pressed) {
super.setPressed(pressed);
protected void drawableStateChanged() {
super.drawableStateChanged();
for (final int state : getDrawableState()) {
if (state == android.R.attr.state_pressed) {
updateIndicatorView(true /* pressed */);
return;
}
}
updateIndicatorView(false /* pressed */);
}
// TODO: Once we stop supporting ICS, uncomment this method and remove
// {@link #drawableStateChanged()} method.
// @Override
// public void setPressed(final boolean pressed) {
// super.setPressed(pressed);
// updateIndicatorView(pressed);
// }
private void updateIndicatorView(final boolean pressed) {
if (mIndicatorView != null) {
mIndicatorView.setPressed(pressed);
mIndicatorView.invalidate();
}
}
}
@ -72,12 +93,6 @@ public final class SetupStartIndicatorView extends LinearLayout {
mIndicatorPaint.setStyle(Paint.Style.FILL);
}
@Override
public void setPressed(final boolean pressed) {
super.setPressed(pressed);
invalidate();
}
@Override
protected void onDraw(final Canvas canvas) {
super.onDraw(canvas);