Fix hotspot movement on focus change
BUG: 15726988 Change-Id: I97f88e5f7e404ecfcd5c254fddd18c8f6616064e
This commit is contained in:
@@ -52,6 +52,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
||||
*/
|
||||
private static final boolean DEFAULT_DITHER = true;
|
||||
private DrawableContainerState mDrawableContainerState;
|
||||
private Rect mHotspotBounds;
|
||||
private Drawable mCurrDrawable;
|
||||
private int mAlpha = 0xFF;
|
||||
|
||||
@@ -273,11 +274,27 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
||||
|
||||
@Override
|
||||
public void setHotspotBounds(int left, int top, int right, int bottom) {
|
||||
if (mHotspotBounds == null) {
|
||||
mHotspotBounds = new Rect(left, top, bottom, right);
|
||||
} else {
|
||||
mHotspotBounds.set(left, top, bottom, right);
|
||||
}
|
||||
|
||||
if (mCurrDrawable != null) {
|
||||
mCurrDrawable.setHotspotBounds(left, top, right, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public void getHotspotBounds(Rect outRect) {
|
||||
if (mHotspotBounds != null) {
|
||||
outRect.set(mHotspotBounds);
|
||||
} else {
|
||||
super.getHotspotBounds(outRect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onStateChange(int[] state) {
|
||||
if (mLastDrawable != null) {
|
||||
@@ -430,6 +447,12 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
|
||||
d.setBounds(getBounds());
|
||||
d.setLayoutDirection(getLayoutDirection());
|
||||
d.setAutoMirrored(mDrawableContainerState.mAutoMirrored);
|
||||
|
||||
final Rect hotspotBounds = mHotspotBounds;
|
||||
if (hotspotBounds != null) {
|
||||
d.setHotspotBounds(hotspotBounds.left, hotspotBounds.top,
|
||||
hotspotBounds.right, hotspotBounds.bottom);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mCurrDrawable = null;
|
||||
|
||||
Reference in New Issue
Block a user