summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-07-28 11:00:20 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-07-28 11:00:20 -0700
commitfec9786f2e7171f6616b8258a8dee8be2d5f1fd4 (patch)
tree0833ab626391583578eacea5c2b429ccea4ae468 /src
parentac68b8151f081ad9989cf302e48ff215cd249848 (diff)
parent3b0b46af5dd09ae00cd0ff7fcce6cff17447acad (diff)
downloadandroid_packages_apps_Trebuchet-fec9786f2e7171f6616b8258a8dee8be2d5f1fd4.tar.gz
android_packages_apps_Trebuchet-fec9786f2e7171f6616b8258a8dee8be2d5f1fd4.tar.bz2
android_packages_apps_Trebuchet-fec9786f2e7171f6616b8258a8dee8be2d5f1fd4.zip
Merge "Adding workaround for crashes (5087036, 4556344) now that widget previews are loaded asynchronously."
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/FocusHelper.java28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/com/android/launcher2/FocusHelper.java b/src/com/android/launcher2/FocusHelper.java
index 3783d566c..f97492bd6 100644
--- a/src/com/android/launcher2/FocusHelper.java
+++ b/src/com/android/launcher2/FocusHelper.java
@@ -139,6 +139,9 @@ public class FocusHelper {
final int action = e.getAction();
final boolean handleKeyEvent = (action != KeyEvent.ACTION_UP);
PagedViewGridLayout newParent = null;
+ // Now that we load items in the bg asynchronously, we can't just focus
+ // child siblings willy-nilly
+ View child = null;
boolean wasHandled = false;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
@@ -150,7 +153,8 @@ public class FocusHelper {
if (pageIndex > 0) {
newParent = (PagedViewGridLayout)
container.getChildAt(pageIndex - 1);
- newParent.getChildAt(newParent.getChildCount() - 1).requestFocus();
+ child = newParent.getChildAt(newParent.getChildCount() - 1);
+ if (child != null) child.requestFocus();
}
}
}
@@ -165,7 +169,8 @@ public class FocusHelper {
if (pageIndex < (pageCount - 1)) {
newParent = (PagedViewGridLayout)
container.getChildAt(pageIndex + 1);
- newParent.getChildAt(0).requestFocus();
+ child = newParent.getChildAt(0);
+ if (child != null) child.requestFocus();
}
}
}
@@ -176,7 +181,8 @@ public class FocusHelper {
// Select the closest icon in the previous row, otherwise select the tab bar
if (y > 0) {
int newWidgetIndex = ((y - 1) * cellCountX) + x;
- parent.getChildAt(newWidgetIndex).requestFocus();
+ child = parent.getChildAt(newWidgetIndex);
+ if (child != null) child.requestFocus();
} else {
tabs.requestFocus();
}
@@ -188,7 +194,8 @@ public class FocusHelper {
// Select the closest icon in the previous row, otherwise do nothing
if (y < (cellCountY - 1)) {
int newWidgetIndex = Math.min(widgetCount - 1, ((y + 1) * cellCountX) + x);
- parent.getChildAt(newWidgetIndex).requestFocus();
+ child = parent.getChildAt(newWidgetIndex);
+ if (child != null) child.requestFocus();
}
}
wasHandled = true;
@@ -208,10 +215,11 @@ public class FocusHelper {
// if there is no previous page
if (pageIndex > 0) {
newParent = (PagedViewGridLayout) container.getChildAt(pageIndex - 1);
- newParent.getChildAt(0).requestFocus();
+ child = newParent.getChildAt(0);
} else {
- parent.getChildAt(0).requestFocus();
+ child = parent.getChildAt(0);
}
+ if (child != null) child.requestFocus();
}
wasHandled = true;
break;
@@ -221,17 +229,19 @@ public class FocusHelper {
// if there is no next page
if (pageIndex < (pageCount - 1)) {
newParent = (PagedViewGridLayout) container.getChildAt(pageIndex + 1);
- newParent.getChildAt(0).requestFocus();
+ child = newParent.getChildAt(0);
} else {
- parent.getChildAt(widgetCount - 1).requestFocus();
+ child = parent.getChildAt(widgetCount - 1);
}
+ if (child != null) child.requestFocus();
}
wasHandled = true;
break;
case KeyEvent.KEYCODE_MOVE_HOME:
if (handleKeyEvent) {
// Select the first item on this page
- parent.getChildAt(0).requestFocus();
+ child = parent.getChildAt(0);
+ if (child != null) child.requestFocus();
}
wasHandled = true;
break;