summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-06-12 12:41:15 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-12 12:41:15 -0700
commit307f0b4d4d6a49e87342a66bb9bb0adb4a36352a (patch)
tree9c9a612a1f176f5a1439658be773959d08a140b7
parentb9508aaf04760be597b6c87a7f7346207d6a2ea6 (diff)
parent12dd20d59bb8c2dbc957d171f091b78998f2015b (diff)
downloadandroid_packages_apps_Trebuchet-307f0b4d4d6a49e87342a66bb9bb0adb4a36352a.tar.gz
android_packages_apps_Trebuchet-307f0b4d4d6a49e87342a66bb9bb0adb4a36352a.tar.bz2
android_packages_apps_Trebuchet-307f0b4d4d6a49e87342a66bb9bb0adb4a36352a.zip
am 12dd20d5: Merge "Fixing issue where we were not always invalidating the page data when setting apps. (Bug 6549598)" into jb-dev
* commit '12dd20d59bb8c2dbc957d171f091b78998f2015b': Fixing issue where we were not always invalidating the page data when setting apps. (Bug 6549598)
-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 5f81d9c1d..a24bfdaf2 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
@@ -1740,16 +1721,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
@@ -1767,7 +1763,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) {
@@ -1797,7 +1793,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
@@ -1809,7 +1805,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);
}