Merge "Fix 3482911: NPE in CustomizePagedView.resetCheckedItem"
This commit is contained in:
commit
6c7a985c55
|
@ -337,14 +337,15 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
|
|||
|
||||
/**
|
||||
* Similar to resetCheckedGrandchildren, but allows us to specify that it's not animated.
|
||||
* NOTE: This assumes that only a single item can be checked.
|
||||
*/
|
||||
private void resetCheckedItem(boolean animated) {
|
||||
Checkable checkable = getCheckedGrandchildren().get(0);
|
||||
if (checkable instanceof PagedViewWidget) {
|
||||
((PagedViewWidget) checkable).setChecked(false, animated);
|
||||
} else {
|
||||
((PagedViewIcon) checkable).setChecked(false, animated);
|
||||
final Checkable checkable = getSingleCheckedGrandchild();
|
||||
if (checkable != null) {
|
||||
if (checkable instanceof PagedViewWidget) {
|
||||
((PagedViewWidget) checkable).setChecked(false, animated);
|
||||
} else {
|
||||
((PagedViewIcon) checkable).setChecked(false, animated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,8 +354,7 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
|
|||
|
||||
// Create a view, identical to the drag view, that is only used for animating the
|
||||
// item onto the home screen (or back to its original position, if the drop failed).
|
||||
final int[] pos = new int[2];
|
||||
mDragController.getDragView().getLocationOnScreen(pos);
|
||||
final int[] pos = mDragController.getDragView().getPosition(null);
|
||||
final View animView = dragLayer.createDragView(mDragBitmap, pos[0], pos[1]);
|
||||
animView.setVisibility(View.VISIBLE);
|
||||
|
||||
|
|
|
@ -245,5 +245,13 @@ public class DragView extends View {
|
|||
void remove() {
|
||||
mWindowManager.removeView(this);
|
||||
}
|
||||
|
||||
int[] getPosition(int[] result) {
|
||||
WindowManager.LayoutParams lp = mLayoutParams;
|
||||
if (result == null) result = new int[2];
|
||||
result[0] = lp.x;
|
||||
result[1] = lp.y;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1420,7 +1420,7 @@ public abstract class PagedView extends ViewGroup {
|
|||
* Otherwise, returns null.
|
||||
*/
|
||||
protected Checkable getSingleCheckedGrandchild() {
|
||||
if (mChoiceMode == CHOICE_MODE_SINGLE) {
|
||||
if (mChoiceMode != CHOICE_MODE_MULTIPLE) {
|
||||
final int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; ++i) {
|
||||
Page layout = (Page) getChildAt(i);
|
||||
|
@ -1436,14 +1436,6 @@ public abstract class PagedView extends ViewGroup {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Object getChosenItem() {
|
||||
View checkedView = (View) getSingleCheckedGrandchild();
|
||||
if (checkedView != null) {
|
||||
return checkedView.getTag();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void resetCheckedGrandchildren() {
|
||||
// loop through children, and set all of their children to _not_ be checked
|
||||
final ArrayList<Checkable> checked = getCheckedGrandchildren();
|
||||
|
|
Loading…
Reference in New Issue