summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-04-03 14:08:41 -0700
committerWinson Chung <winsonc@google.com>2012-04-03 14:09:13 -0700
commitdb8a8944ede3be4ee63b43e24c407a3aaabee4de (patch)
tree5cc9c57d5bd422c164ced79c195aec042c714d6a
parent0ba38df8a4af98daa535a57ec6c6ecac69b10343 (diff)
downloadandroid_packages_apps_Trebuchet-db8a8944ede3be4ee63b43e24c407a3aaabee4de.tar.gz
android_packages_apps_Trebuchet-db8a8944ede3be4ee63b43e24c407a3aaabee4de.tar.bz2
android_packages_apps_Trebuchet-db8a8944ede3be4ee63b43e24c407a3aaabee4de.zip
Changing order of binding to prevent errant flashing while loading workspace.
Change-Id: I75eb39600d1cd28980fd0365affb2c6e5f7162c1
-rw-r--r--src/com/android/launcher2/Hotseat.java1
-rw-r--r--src/com/android/launcher2/LauncherModel.java39
-rw-r--r--src/com/android/launcher2/ShortcutInfo.java5
3 files changed, 38 insertions, 7 deletions
diff --git a/src/com/android/launcher2/Hotseat.java b/src/com/android/launcher2/Hotseat.java
index 9e525bd5a..fbb45b97e 100644
--- a/src/com/android/launcher2/Hotseat.java
+++ b/src/com/android/launcher2/Hotseat.java
@@ -104,7 +104,6 @@ public class Hotseat extends FrameLayout {
inflater.inflate(R.layout.application, mContent, false);
allAppsButton.setCompoundDrawablesWithIntrinsicBounds(null,
context.getResources().getDrawable(R.drawable.all_apps_button_icon), null, null);
- // allAppsButton.setText(context.getString(R.string.all_apps_button_label));
allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
allAppsButton.setOnTouchListener(new View.OnTouchListener() {
@Override
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 30eb86c5a..cc6e23e57 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -1228,7 +1228,39 @@ public class LauncherModel extends BroadcastReceiver {
return;
}
- int N;
+ // Get the list of workspace items to load and unbind the existing ShortcutInfos
+ // before we call startBinding() below.
+ final int currentScreen = oldCallbacks.getCurrentWorkspaceScreen();
+ final ArrayList<ItemInfo> tmpWorkspaceItems = unbindWorkspaceItemsOnMainThread();
+ // Order the items for loading as follows: current workspace, hotseat, everything else
+ Collections.sort(tmpWorkspaceItems, new Comparator<ItemInfo>() {
+ @Override
+ public int compare(ItemInfo lhs, ItemInfo rhs) {
+ int cellCountX = LauncherModel.getCellCountX();
+ int cellCountY = LauncherModel.getCellCountY();
+ int screenOffset = cellCountX * cellCountY;
+ int containerOffset = screenOffset * (Launcher.SCREEN_COUNT + 1); // +1 hotseat
+ long lr = (lhs.container * containerOffset + lhs.screen * screenOffset +
+ lhs.cellY * cellCountX + lhs.cellX);
+ long rr = (rhs.container * containerOffset + rhs.screen * screenOffset +
+ rhs.cellY * cellCountX + rhs.cellX);
+ return (int) (lr - rr);
+ }
+ });
+ // Precondition: the items are ordered by page, screen
+ final ArrayList<ItemInfo> workspaceItems = new ArrayList<ItemInfo>();
+ for (ItemInfo ii : tmpWorkspaceItems) {
+ // Prepend the current items, hotseat items, append everything else
+ if (ii.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&
+ ii.screen == currentScreen) {
+ workspaceItems.add(0, ii);
+ } else if (ii.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
+ workspaceItems.add(0, ii);
+ } else {
+ workspaceItems.add(ii);
+ }
+ }
+
// Tell the workspace that we're about to start firing items at it
mHandler.post(new Runnable() {
public void run() {
@@ -1239,10 +1271,8 @@ public class LauncherModel extends BroadcastReceiver {
}
});
- final ArrayList<ItemInfo> workspaceItems = unbindWorkspaceItemsOnMainThread();
-
// Add the items to the workspace.
- N = workspaceItems.size();
+ int N = workspaceItems.size();
for (int i=0; i<N; i+=ITEMS_CHUNK) {
final int start = i;
final int chunkSize = (i+ITEMS_CHUNK <= N) ? ITEMS_CHUNK : (N-i);
@@ -1278,7 +1308,6 @@ public class LauncherModel extends BroadcastReceiver {
// but since getCurrentScreen() just returns the int, we should be okay. This
// is just a hint for the order, and if it's wrong, we'll be okay.
// TODO: instead, we should have that push the current screen into here.
- final int currentScreen = oldCallbacks.getCurrentWorkspaceScreen();
N = sAppWidgets.size();
// once for the current screen
for (int i=0; i<N; i++) {
diff --git a/src/com/android/launcher2/ShortcutInfo.java b/src/com/android/launcher2/ShortcutInfo.java
index ff3028beb..76892dbde 100644
--- a/src/com/android/launcher2/ShortcutInfo.java
+++ b/src/com/android/launcher2/ShortcutInfo.java
@@ -149,7 +149,10 @@ class ShortcutInfo extends ItemInfo {
@Override
public String toString() {
- return "ShortcutInfo(title=" + title.toString() + ")";
+ return "ShortcutInfo(title=" + title.toString() + "intent=" + intent + "id=" + this.id
+ + " type=" + this.itemType + " container=" + this.container + " screen=" + screen
+ + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX + " spanY=" + spanY
+ + " isGesture=" + isGesture + " dropPos=" + dropPos + ")";
}
public static void dumpShortcutInfoList(String tag, String label,