summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-06-08 16:01:58 -0700
committerWinson Chung <winsonc@google.com>2012-06-08 16:02:30 -0700
commit9802ac9024b7bef300c6c9eb46aa63eb04697b28 (patch)
tree0314adabe800feaa8b38a8269411d55a67cc6b55 /src/com/android
parent478244409e15594ceaa7426a6a23cc805db0b1fc (diff)
downloadandroid_packages_apps_Trebuchet-9802ac9024b7bef300c6c9eb46aa63eb04697b28.tar.gz
android_packages_apps_Trebuchet-9802ac9024b7bef300c6c9eb46aa63eb04697b28.tar.bz2
android_packages_apps_Trebuchet-9802ac9024b7bef300c6c9eb46aa63eb04697b28.zip
Fixing issue where we were not always invalidating the page data when setting apps. (Bug 6549598)
Change-Id: I2fff41e87465608a21ffb7c91e988b33f8d54ee3
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java56
1 files changed, 26 insertions, 30 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 61329adaf..894dd0795 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -434,16 +434,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
- /**
- * This differs from isDataReady as this is the test done if isDataReady is not set.
- */
- private boolean testDataReady() {
- // We only do this test once, and we default to the Applications page, so we only really
- // have to wait for there to be apps.
- // TODO: What if one of them is validly empty
- return !mApps.isEmpty() && !mWidgets.isEmpty();
- }
-
/** Restores the page for an item at the specified index */
void restorePageForIndex(int index) {
if (index < 0) return;
@@ -515,7 +505,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
void showAllAppsCling() {
- if (!mHasShownAllAppsCling && isDataReady() && testDataReady()) {
+ if (!mHasShownAllAppsCling && isDataReady()) {
mHasShownAllAppsCling = true;
// Calculate the position for the cling punch through
int[] offset = new int[2];
@@ -534,7 +524,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
if (!isDataReady()) {
- if (testDataReady()) {
+ if (!mApps.isEmpty() && !mWidgets.isEmpty()) {
setDataIsReady();
setMeasuredDimension(width, height);
onDataReady(width, height);
@@ -561,7 +551,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void updatePackages() {
// Get the list of widgets and shortcuts
- boolean wasEmpty = mWidgets.isEmpty();
mWidgets.clear();
List<AppWidgetProviderInfo> widgets =
AppWidgetManager.getInstance(mLauncher).getInstalledProviders();
@@ -589,17 +578,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mWidgets.addAll(shortcuts);
Collections.sort(mWidgets,
new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
- Log.d(TAG, "6549598 updatePackages mWidgets.size(): " + mWidgets.size() + " wasEmpty: " + wasEmpty);
+ Log.d(TAG, "6549598 updatePackages mWidgets.size(): " + mWidgets.size());
updatePageCounts();
-
- if (wasEmpty) {
- // The next layout pass will trigger data-ready if both widgets and apps are set, so request
- // a layout to do this test and invalidate the page data when ready.
- if (testDataReady()) requestLayout();
- } else {
- cancelAllTasks();
- invalidatePageData();
- }
+ invalidateOnDataChange();
}
@Override
@@ -1763,16 +1744,31 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public boolean isAnimating() {
return false;
}
+
+ /**
+ * We should call thise method whenever the core data changes (mApps, mWidgets) so that we can
+ * appropriately determine when to invalidate the PagedView page data. In cases where the data
+ * has yet to be set, we can requestLayout() and wait for onDataReady() to be called in the
+ * next onMeasure() pass, which will trigger an invalidatePageData() itself.
+ */
+ private void invalidateOnDataChange() {
+ if (!isDataReady()) {
+ // The next layout pass will trigger data-ready if both widgets and apps are set, so
+ // request a layout to trigger the page data when ready.
+ requestLayout();
+ } else {
+ cancelAllTasks();
+ invalidatePageData();
+ }
+ }
+
@Override
public void setApps(ArrayList<ApplicationInfo> list) {
mApps = list;
Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
Log.d(TAG, "6549598 setApps mApps.size(): " + mApps.size());
updatePageCounts();
-
- // The next layout pass will trigger data-ready if both widgets and apps are set, so
- // request a layout to do this test and invalidate the page data when ready.
- if (testDataReady()) requestLayout();
+ invalidateOnDataChange();
}
private void addAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
// We add it in place, in alphabetical order
@@ -1790,7 +1786,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
addAppsWithoutInvalidate(list);
Log.d(TAG, "6549598 addApps mApps.size(): " + mApps.size() + " list.size(): " + list.size());
updatePageCounts();
- invalidatePageData();
+ invalidateOnDataChange();
Log.d(TAG, "6549598 addApps mNumAppsPages: " + mNumAppsPages);
}
private int findAppByComponent(List<ApplicationInfo> list, ApplicationInfo item) {
@@ -1820,7 +1816,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
removeAppsWithoutInvalidate(list);
Log.d(TAG, "6549598 removeApps mApps.size(): " + mApps.size() + " list.size(): " + list.size());
updatePageCounts();
- invalidatePageData();
+ invalidateOnDataChange();
Log.d(TAG, "6549598 removeApps mNumAppsPages: " + mNumAppsPages);
}
@Override
@@ -1832,7 +1828,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
addAppsWithoutInvalidate(list);
Log.d(TAG, "6549598 updateApps mApps.size(): " + mApps.size() + " list.size(): " + list.size());
updatePageCounts();
- invalidatePageData();
+ invalidateOnDataChange();
Log.d(TAG, "6549598 updateApps mNumAppsPages: " + mNumAppsPages);
}