summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/CellLayout.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-03-24 17:38:42 -0700
committerWinson Chung <winsonc@google.com>2015-03-24 18:02:01 -0700
commit3d9490ab9520ffe3798539ed1626463a7eb6c9e1 (patch)
treed6274e708b843370c168205c87018851655aa45f /src/com/android/launcher3/CellLayout.java
parentd0930655e5670bb40ec70523c1c76ff86fab2538 (diff)
downloadandroid_packages_apps_Trebuchet-3d9490ab9520ffe3798539ed1626463a7eb6c9e1.tar.gz
android_packages_apps_Trebuchet-3d9490ab9520ffe3798539ed1626463a7eb6c9e1.tar.bz2
android_packages_apps_Trebuchet-3d9490ab9520ffe3798539ed1626463a7eb6c9e1.zip
Removing more code with API 21 dependencies.
Change-Id: I16c914334ce0694b84626269ae4bb5e83082c739
Diffstat (limited to 'src/com/android/launcher3/CellLayout.java')
-rw-r--r--src/com/android/launcher3/CellLayout.java35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index eb2aa547d..63afa3091 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -417,10 +417,13 @@ public class CellLayout extends ViewGroup {
protected int intersectsValidDropTarget(int id) {
LauncherAccessibilityDelegate delegate =
LauncherAppState.getInstance().getAccessibilityDelegate();
- LauncherAccessibilityDelegate.DragInfo dragInfo = delegate.getDragInfo();
+ if (delegate == null) {
+ return -1;
+ }
int y = id % mCountY;
int x = id / mCountY;
+ LauncherAccessibilityDelegate.DragInfo dragInfo = delegate.getDragInfo();
if (dragInfo.dragType == DragType.WIDGET) {
// For a widget, every cell must be vacant. In addition, we will return any valid
@@ -489,10 +492,15 @@ public class CellLayout extends ViewGroup {
@Override
protected boolean onPerformActionForVirtualView(int viewId, int action, Bundle args) {
+ LauncherAccessibilityDelegate delegate =
+ LauncherAppState.getInstance().getAccessibilityDelegate();
+ if (delegate == null) {
+ return false;
+ }
+
if (action == AccessibilityNodeInfoCompat.ACTION_CLICK) {
String confirmation = getConfirmationForIconDrop(viewId);
- LauncherAppState.getInstance().getAccessibilityDelegate()
- .handleAccessibleDrop(CellLayout.this, getItemBounds(viewId), confirmation);
+ delegate.handleAccessibleDrop(CellLayout.this, getItemBounds(viewId), confirmation);
return true;
}
return false;
@@ -500,11 +508,16 @@ public class CellLayout extends ViewGroup {
@Override
public void onClick(View arg0) {
+ LauncherAccessibilityDelegate delegate =
+ LauncherAppState.getInstance().getAccessibilityDelegate();
+ if (delegate == null) {
+ return;
+ }
+
int viewId = getViewIdAt(mDownX, mDownY);
String confirmation = getConfirmationForIconDrop(viewId);
- LauncherAppState.getInstance().getAccessibilityDelegate()
- .handleAccessibleDrop(CellLayout.this, getItemBounds(viewId), confirmation);
+ delegate.handleAccessibleDrop(CellLayout.this, getItemBounds(viewId), confirmation);
}
@Override
@@ -533,10 +546,13 @@ public class CellLayout extends ViewGroup {
private String getLocationDescriptionForIconDrop(int id) {
LauncherAccessibilityDelegate delegate =
LauncherAppState.getInstance().getAccessibilityDelegate();
- LauncherAccessibilityDelegate.DragInfo dragInfo = delegate.getDragInfo();
+ if (delegate == null) {
+ return "";
+ }
int y = id % mCountY;
int x = id / mCountY;
+ LauncherAccessibilityDelegate.DragInfo dragInfo = delegate.getDragInfo();
Resources res = getContext().getResources();
View child = getChildAt(x, y);
@@ -555,11 +571,14 @@ public class CellLayout extends ViewGroup {
private String getConfirmationForIconDrop(int id) {
LauncherAccessibilityDelegate delegate =
- LauncherAppState.getInstance().getAccessibilityDelegate();
- LauncherAccessibilityDelegate.DragInfo dragInfo = delegate.getDragInfo();
+ LauncherAppState.getInstance().getAccessibilityDelegate();
+ if (delegate == null) {
+ return "";
+ }
int y = id % mCountY;
int x = id / mCountY;
+ LauncherAccessibilityDelegate.DragInfo dragInfo = delegate.getDragInfo();
Resources res = getContext().getResources();
View child = getChildAt(x, y);