Fixes for other places where we expect CellLayoutChildren instead of CellLayout. (3392097)
Change-Id: I9df13c413ce62a2760ce6a8ebafed1e948088de2
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index de75fd3..448b766 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -267,6 +267,13 @@
addView(mChildren);
}
+ public CellLayoutChildren getChildrenLayout() {
+ if (getChildCount() > 0) {
+ return (CellLayoutChildren) getChildAt(0);
+ }
+ return null;
+ }
+
public void setIsDefaultDropTarget(boolean isDefaultDropTarget) {
if (mIsDefaultDropTarget != isDefaultDropTarget) {
mIsDefaultDropTarget = isDefaultDropTarget;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 8614865..a5799ae 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -3331,7 +3331,8 @@
int count = workspace.getChildCount();
for (int i = 0; i < count; i++) {
// Use removeAllViewsInLayout() to avoid an extra requestLayout() and invalidate().
- ((ViewGroup) workspace.getChildAt(i)).removeAllViewsInLayout();
+ final ViewGroup layout = ((CellLayout) workspace.getChildAt(i)).getChildrenLayout();
+ layout.removeAllViewsInLayout();
}
if (DEBUG_USER_INTERFACE) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 7021c6a..4ff9f40 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -60,6 +60,7 @@
import android.view.DragEvent;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.widget.TextView;
import android.widget.Toast;
@@ -376,7 +377,7 @@
* @return The open folder on the current screen, or null if there is none
*/
Folder getOpenFolder() {
- CellLayout currentPage = (CellLayout) getChildAt(mCurrentPage);
+ ViewGroup currentPage = ((CellLayout) getChildAt(mCurrentPage)).getChildrenLayout();
int count = currentPage.getChildCount();
for (int i = 0; i < count; i++) {
View child = currentPage.getChildAt(i);
@@ -394,7 +395,7 @@
ArrayList<Folder> folders = new ArrayList<Folder>(screenCount);
for (int screen = 0; screen < screenCount; screen++) {
- CellLayout currentPage = (CellLayout) getChildAt(screen);
+ ViewGroup currentPage = ((CellLayout) getChildAt(screen)).getChildrenLayout();
int count = currentPage.getChildCount();
for (int i = 0; i < count; i++) {
View child = currentPage.getChildAt(i);
@@ -2771,7 +2772,7 @@
public Folder getFolderForTag(Object tag) {
final int screenCount = getChildCount();
for (int screen = 0; screen < screenCount; screen++) {
- CellLayout currentScreen = ((CellLayout) getChildAt(screen));
+ ViewGroup currentScreen = ((CellLayout) getChildAt(screen)).getChildrenLayout();
int count = currentScreen.getChildCount();
for (int i = 0; i < count; i++) {
View child = currentScreen.getChildAt(i);
@@ -2790,7 +2791,7 @@
public View getViewForTag(Object tag) {
int screenCount = getChildCount();
for (int screen = 0; screen < screenCount; screen++) {
- CellLayout currentScreen = ((CellLayout) getChildAt(screen));
+ ViewGroup currentScreen = ((CellLayout) getChildAt(screen)).getChildrenLayout();
int count = currentScreen.getChildCount();
for (int i = 0; i < count; i++) {
View child = currentScreen.getChildAt(i);
@@ -2815,8 +2816,7 @@
}
for (int i = 0; i < screenCount; i++) {
- final CellLayoutChildren layout =
- (CellLayoutChildren) ((CellLayout) getChildAt(i)).getChildAt(0);
+ final ViewGroup layout = ((CellLayout) getChildAt(i)).getChildrenLayout();
// Avoid ANRs by treating each screen separately
post(new Runnable() {
@@ -2921,7 +2921,7 @@
void updateShortcuts(ArrayList<ApplicationInfo> apps) {
final int screenCount = getChildCount();
for (int i = 0; i < screenCount; i++) {
- final CellLayout layout = (CellLayout) getChildAt(i);
+ final ViewGroup layout = ((CellLayout) getChildAt(i)).getChildrenLayout();
int childCount = layout.getChildCount();
for (int j = 0; j < childCount; j++) {
final View view = layout.getChildAt(j);