From 10fefb18c4f227f6a08fc24966800e49ce743be8 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 1 Nov 2010 11:57:06 -0700 Subject: Fixing issues in Launcher - Now ending choice mode if a selected application is removed - Only updating apps in the customization drawer if the applications change - Adding null check when determining scrolling in PagedView Change-Id: I0b23d1383649626dc012bd70a5e8087885b77c17 --- src/com/android/launcher2/AllAppsPagedView.java | 20 +++++++++++++++++--- src/com/android/launcher2/CustomizePagedView.java | 16 +++++++++------- src/com/android/launcher2/PagedView.java | 4 +++- 3 files changed, 29 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java index 4dcdb818d..149f9fb8a 100644 --- a/src/com/android/launcher2/AllAppsPagedView.java +++ b/src/com/android/launcher2/AllAppsPagedView.java @@ -18,14 +18,13 @@ package com.android.launcher2; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import android.content.ComponentName; import android.content.Context; import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.ActionMode; -import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -294,7 +293,22 @@ public class AllAppsPagedView extends PagedView } private void removeAppsWithoutInvalidate(ArrayList list) { - // loop through all the apps and remove apps that have the same component + // End the choice mode if any of the items in the list that are being removed are + // currently selected + ArrayList checkedList = getCheckedGrandchildren(); + HashSet checkedAppInfos = new HashSet(); + for (Checkable checked : checkedList) { + PagedViewIcon icon = (PagedViewIcon) checked; + checkedAppInfos.add((ApplicationInfo) icon.getTag()); + } + for (ApplicationInfo info : list) { + if (checkedAppInfos.contains(info)) { + endChoiceMode(); + break; + } + } + + // Loop through all the apps and remove apps that have the same component final int length = list.size(); for (int i = 0; i < length; ++i) { final ApplicationInfo info = list.get(i); diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java index 5cfc38fb1..a475a50d2 100644 --- a/src/com/android/launcher2/CustomizePagedView.java +++ b/src/com/android/launcher2/CustomizePagedView.java @@ -144,7 +144,7 @@ public class CustomizePagedView extends PagedView Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR); // Update the widgets/shortcuts to reflect changes in the set of available apps - update(); + invalidatePageDataAndIconCache(); } /** @@ -170,7 +170,7 @@ public class CustomizePagedView extends PagedView addAppsWithoutInvalidate(list); // Update the widgets/shortcuts to reflect changes in the set of available apps - update(); + invalidatePageDataAndIconCache(); } /** @@ -197,7 +197,7 @@ public class CustomizePagedView extends PagedView removeAppsWithoutInvalidate(list); // Update the widgets/shortcuts to reflect changes in the set of available apps - update(); + invalidatePageDataAndIconCache(); } /** @@ -212,7 +212,7 @@ public class CustomizePagedView extends PagedView addAppsWithoutInvalidate(list); // Update the widgets/shortcuts to reflect changes in the set of available apps - update(); + invalidatePageDataAndIconCache(); } /** @@ -231,8 +231,6 @@ public class CustomizePagedView extends PagedView } public void update() { - Context context = getContext(); - // get the list of widgets mWidgetList = AppWidgetManager.getInstance(mLauncher).getInstalledProviders(); Collections.sort(mWidgetList, new Comparator() { @@ -260,7 +258,11 @@ public class CustomizePagedView extends PagedView mWallpaperList = mPackageManager.queryIntentActivities(wallpapersIntent, 0); Collections.sort(mWallpaperList, resolveInfoComparator); - // reset the icon cache + invalidatePageDataAndIconCache(); + } + + private void invalidatePageDataAndIconCache() { + // Reset the icon cache mPageViewIconCache.clear(); // Refresh all the tabs diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 9739b156f..c1256969b 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -755,7 +755,9 @@ public abstract class PagedView extends ViewGroup { // by a distant descendant, so use the mAllowLongPress flag to block // everything final View currentPage = getPageAt(mCurrentPage); - currentPage.cancelLongPress(); + if (currentPage != null) { + currentPage.cancelLongPress(); + } } } } -- cgit v1.2.3