summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2015-04-16 21:52:13 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-16 21:52:13 +0000
commitdf41097194b0ea490513c2a4e85bd9adc54637e8 (patch)
treeadbcd1f087f193800264eb7c6b47e54111e667b4 /src
parent3774923944c4da8decc58df1aaa9b839ed542179 (diff)
parentb76cd628e657fd050ccf3f4dc31b2e8bc36356e5 (diff)
downloadandroid_packages_apps_Trebuchet-df41097194b0ea490513c2a4e85bd9adc54637e8.tar.gz
android_packages_apps_Trebuchet-df41097194b0ea490513c2a4e85bd9adc54637e8.tar.bz2
android_packages_apps_Trebuchet-df41097194b0ea490513c2a4e85bd9adc54637e8.zip
Merge "Focus handling null pointer exception during monkey tests." into ub-launcher3-burnaby
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/FocusHelper.java10
-rw-r--r--src/com/android/launcher3/PagedView.java5
2 files changed, 12 insertions, 3 deletions
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index 8791c896a..32ed98c17 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -222,7 +222,7 @@ public class FocusHelper {
Hotseat hotseat = (Hotseat) hotseatLayout.getParent();
Workspace workspace = (Workspace) v.getRootView().findViewById(R.id.workspace);
- int pageIndex = workspace.getCurrentPage();
+ int pageIndex = workspace.getNextPage();
int pageCount = workspace.getChildCount();
int countX = -1;
int countY = -1;
@@ -231,6 +231,12 @@ public class FocusHelper {
.getChildAt(iconIndex).getLayoutParams()).cellX;
final CellLayout iconLayout = (CellLayout) workspace.getChildAt(pageIndex);
+ if (iconLayout == null) {
+ // This check is to guard against cases where key strokes rushes in when workspace
+ // child creation/deletion is still in flux. (e.g., during drop or fling
+ // animation.)
+ return consume;
+ }
final ViewGroup iconParent = iconLayout.getShortcutsAndWidgets();
ViewGroup parent = null;
@@ -364,6 +370,7 @@ public class FocusHelper {
}
int row = FocusLogic.findRow(matrix, iconIndex);
parent = getCellLayoutChildrenForIndex(workspace, newPageIndex);
+ workspace.snapToPage(newPageIndex);
if (parent != null) {
iconLayout = (CellLayout) parent.getParent();
matrix = FocusLogic.createSparseMatrix(iconLayout,
@@ -394,6 +401,7 @@ public class FocusHelper {
if (newIconIndex == FocusLogic.PREVIOUS_PAGE_LEFT_COLUMN) {
newPageIndex = pageIndex - 1;
}
+ workspace.snapToPage(newPageIndex);
row = FocusLogic.findRow(matrix, iconIndex);
parent = getCellLayoutChildrenForIndex(workspace, newPageIndex);
if (parent != null) {
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 6e9f27a0a..88295c084 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -476,13 +476,14 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
/**
* Returns the index of the currently displayed page.
- *
- * @return The index of the currently displayed page.
*/
int getCurrentPage() {
return mCurrentPage;
}
+ /**
+ * Returns the index of page to be shown immediately afterwards.
+ */
int getNextPage() {
return (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
}