am f1d23f9c: am fe087d38: Merge "Fix invalid bounds detection in ExploreByTouchHelper" into lmp-mr1-dev
* commit 'f1d23f9cc1992b936c98e2882eb5a3d766129fe7': Fix invalid bounds detection in ExploreByTouchHelper
This commit is contained in:
@@ -54,6 +54,10 @@ public abstract class ExploreByTouchHelper extends View.AccessibilityDelegate {
|
|||||||
/** Default class name used for virtual views. */
|
/** Default class name used for virtual views. */
|
||||||
private static final String DEFAULT_CLASS_NAME = View.class.getName();
|
private static final String DEFAULT_CLASS_NAME = View.class.getName();
|
||||||
|
|
||||||
|
/** Default bounds used to determine if the client didn't set any. */
|
||||||
|
private static final Rect INVALID_PARENT_BOUNDS = new Rect(
|
||||||
|
Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||||
|
|
||||||
// Temporary, reusable data structures.
|
// Temporary, reusable data structures.
|
||||||
private final Rect mTempScreenRect = new Rect();
|
private final Rect mTempScreenRect = new Rect();
|
||||||
private final Rect mTempParentRect = new Rect();
|
private final Rect mTempParentRect = new Rect();
|
||||||
@@ -372,6 +376,7 @@ public abstract class ExploreByTouchHelper extends View.AccessibilityDelegate {
|
|||||||
// Ensure the client has good defaults.
|
// Ensure the client has good defaults.
|
||||||
node.setEnabled(true);
|
node.setEnabled(true);
|
||||||
node.setClassName(DEFAULT_CLASS_NAME);
|
node.setClassName(DEFAULT_CLASS_NAME);
|
||||||
|
node.setBoundsInParent(INVALID_PARENT_BOUNDS);
|
||||||
|
|
||||||
// Allow the client to populate the node.
|
// Allow the client to populate the node.
|
||||||
onPopulateNodeForVirtualView(virtualViewId, node);
|
onPopulateNodeForVirtualView(virtualViewId, node);
|
||||||
@@ -383,7 +388,7 @@ public abstract class ExploreByTouchHelper extends View.AccessibilityDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
node.getBoundsInParent(mTempParentRect);
|
node.getBoundsInParent(mTempParentRect);
|
||||||
if (mTempParentRect.isEmpty()) {
|
if (mTempParentRect.equals(INVALID_PARENT_BOUNDS)) {
|
||||||
throw new RuntimeException("Callbacks must set parent bounds in "
|
throw new RuntimeException("Callbacks must set parent bounds in "
|
||||||
+ "populateNodeForVirtualViewId()");
|
+ "populateNodeForVirtualViewId()");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user