*/
private void manageFocusHotspot(boolean focused, View v) {
final Rect r = new Rect();
- if (!focused && v != null && mAttachInfo != null) {
- v.getBoundsOnScreen(r);
+ if (v != null && mAttachInfo != null) {
+ v.getHotspotBounds(r);
final int[] location = mAttachInfo.mTmpLocation;
getLocationOnScreen(location);
r.offset(-location[0], -location[1]);
}
/**
+ * Populates <code>outRect</code> with the hotspot bounds. By default,
+ * the hotspot bounds are identical to the screen bounds.
+ *
+ * @param outRect rect to populate with hotspot bounds
+ * @hide Only for internal use by views and widgets.
+ */
+ public void getHotspotBounds(Rect outRect) {
+ final Drawable background = getBackground();
+ if (background != null) {
+ background.getHotspotBounds(outRect);
+ } else {
+ getBoundsOnScreen(outRect);
+ }
+ }
+
+ /**
* Request that a rectangle of this view be visible on the screen,
* scrolling if necessary just enough.
*
*/
public void setHotspotBounds(int left, int top, int right, int bottom) {}
+ /** @hide For internal use only. Individual results may vary. */
+ public void getHotspotBounds(Rect outRect) {
+ outRect.set(getBounds());
+ }
+
/**
* Whether this drawable requests projection.
*
*/
private static final boolean DEFAULT_DITHER = true;
private DrawableContainerState mDrawableContainerState;
+ private Rect mHotspotBounds;
private Drawable mCurrDrawable;
private int mAlpha = 0xFF;
@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) {
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;
mInsetState.mDrawable.setHotspotBounds(left, top, right, bottom);
}
+ /** @hide */
+ @Override
+ public void getHotspotBounds(Rect outRect) {
+ mInsetState.mDrawable.getHotspotBounds(outRect);
+ }
+
@Override
public boolean setVisible(boolean visible, boolean restart) {
mInsetState.mDrawable.setVisible(visible, restart);
private int[] mPaddingB;
private final Rect mTmpRect = new Rect();
+ private Rect mHotspotBounds;
private boolean mMutated;
/**
for (int i = 0; i < N; i++) {
array[i].mDrawable.setHotspotBounds(left, top, right, bottom);
}
+
+ if (mHotspotBounds == null) {
+ mHotspotBounds = new Rect(left, top, right, bottom);
+ } else {
+ mHotspotBounds.set(left, top, right, bottom);
+ }
+ }
+
+ /** @hide */
+ @Override
+ public void getHotspotBounds(Rect outRect) {
+ if (mHotspotBounds != null) {
+ outRect.set(mHotspotBounds);
+ } else {
+ super.getHotspotBounds(outRect);
+ }
}
@Override
onHotspotBoundsChanged();
}
+ /** @hide */
+ @Override
+ public void getHotspotBounds(Rect outRect) {
+ outRect.set(mHotspotBounds);
+ }
+
/**
* Notifies all the animating ripples that the hotspot bounds have changed.
*/