summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2013-08-27 11:58:12 -0700
committerWinson Chung <winsonc@google.com>2013-08-27 15:54:46 -0700
commit9e6a0a20d40675ef98c7fdb8892cf34b90152f7a (patch)
tree5c3a9fe04f8de3e466043c6a2fe56379c5e63fc2 /src
parent53fc06d5d6d4b57e824490300bf62dbed54d9ac7 (diff)
downloadandroid_packages_apps_Trebuchet-9e6a0a20d40675ef98c7fdb8892cf34b90152f7a.tar.gz
android_packages_apps_Trebuchet-9e6a0a20d40675ef98c7fdb8892cf34b90152f7a.tar.bz2
android_packages_apps_Trebuchet-9e6a0a20d40675ef98c7fdb8892cf34b90152f7a.zip
Clearing workspace screen data structures along with pages.
Change-Id: Ib6c4522cd0c0c06dd6fd327be3621a6de0778f9c
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java2
-rw-r--r--src/com/android/launcher3/LauncherModel.java41
-rw-r--r--src/com/android/launcher3/Workspace.java14
3 files changed, 52 insertions, 5 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 943deda71..dd9e793fb 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3501,7 +3501,7 @@ public class Launcher extends Activity
// Clear the workspace because it's going to be rebound
mWorkspace.clearDropTargets();
- mWorkspace.removeAllViews();
+ mWorkspace.removeAllWorkspaceScreens();
mWidgetsToAdvance.clear();
if (mHotseat != null) {
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 8676b0915..c1754b437 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -283,7 +283,7 @@ public class LauncherModel extends BroadcastReceiver {
final Callbacks callbacks) {
Log.w(TAG, "10249126 - addAndBindAddedApps()");
if (added.isEmpty()) {
- throw new RuntimeException("EMPTY ADDED ARRAY?");
+ return;
}
// Process the newly added applications and add them to the database first
Runnable r = new Runnable() {
@@ -979,6 +979,7 @@ public class LauncherModel extends BroadcastReceiver {
* a list of screen ids in the order that they should appear.
*/
void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) {
+ Log.w(TAG, "10249126 - updateWorkspaceScreenOrder()");
final ArrayList<Long> screensCopy = new ArrayList<Long>(screens);
final ContentResolver cr = context.getContentResolver();
final Uri uri = LauncherSettings.WorkspaceScreens.CONTENT_URI;
@@ -988,10 +989,17 @@ public class LauncherModel extends BroadcastReceiver {
while (iter.hasNext()) {
long id = iter.next();
if (id < 0) {
+ Log.w(TAG, "10249126 - updateWorkspaceScreenOrder - remove: " + id + ")");
iter.remove();
}
}
+ // Dump the screens copy
+ Log.w(TAG, "10249126 - updateWorkspaceScreenOrder - screensCopy");
+ for (Long l : screensCopy) {
+ Log.w(TAG, "10249126\t- " + l);
+ }
+
Runnable r = new Runnable() {
@Override
public void run() {
@@ -1004,10 +1012,18 @@ public class LauncherModel extends BroadcastReceiver {
long screenId = screensCopy.get(i);
v.put(LauncherSettings.WorkspaceScreens._ID, screenId);
v.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i);
- Log.w(TAG, "10249126 - updateWorkspaceScreenOrder(" + screenId + ", " + i + ")");
+ Log.w(TAG, "10249126 - updateWorkspaceScreenOrder - add: " +
+ screenId + ", " + i + ")");
values[i] = v;
}
cr.bulkInsert(uri, values);
+
+ // Dump the sBgWorkspaceScreens
+ Log.w(TAG, "10249126 - updateWorkspaceScreenOrder - sBgWorkspaceScreens");
+ for (Long l : sBgWorkspaceScreens) {
+ Log.w(TAG, "10249126\t- " + l);
+ }
+
sBgWorkspaceScreens.clear();
sBgWorkspaceScreens.addAll(screensCopy);
}
@@ -1915,6 +1931,13 @@ public class LauncherModel extends BroadcastReceiver {
}
}
Collections.sort(sBgWorkspaceScreens);
+
+ // Dump the sBgWorkspaceScreens
+ Log.w(TAG, "10249126 - updateWorkspaceScreenOrder - sBgWorkspaceScreens");
+ for (Long l : sBgWorkspaceScreens) {
+ Log.w(TAG, "10249126\t- " + l);
+ }
+
mApp.getLauncherProvider().updateMaxScreenId(maxScreenId);
updateWorkspaceScreenOrder(context, sBgWorkspaceScreens);
@@ -1948,6 +1971,13 @@ public class LauncherModel extends BroadcastReceiver {
// If there are any empty screens remove them, and update.
if (unusedScreens.size() != 0) {
sBgWorkspaceScreens.removeAll(unusedScreens);
+
+ // Dump the sBgWorkspaceScreens
+ Log.w(TAG, "10249126 - updateWorkspaceScreenOrder - sBgWorkspaceScreens");
+ for (Long l : sBgWorkspaceScreens) {
+ Log.w(TAG, "10249126\t- " + l);
+ }
+
updateWorkspaceScreenOrder(context, sBgWorkspaceScreens);
}
}
@@ -2101,6 +2131,13 @@ public class LauncherModel extends BroadcastReceiver {
private void bindWorkspaceScreens(final Callbacks oldCallbacks,
final ArrayList<Long> orderedScreens) {
Log.w(TAG, "10249126 - bindWorkspaceScreens()");
+
+ // Dump the orderedScreens
+ Log.w(TAG, "10249126 - orderedScreens");
+ for (Long l : sBgWorkspaceScreens) {
+ Log.w(TAG, "10249126\t- " + l);
+ }
+
final Runnable r = new Runnable() {
@Override
public void run() {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 311438922..e3fad4e00 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -106,6 +106,7 @@ public class Workspace extends SmoothPagedView
private final WallpaperManager mWallpaperManager;
private IBinder mWindowToken;
+ private int mOriginalDefaultPage;
private int mDefaultPage;
// The screen id used for the empty screen always present to the right.
@@ -298,7 +299,7 @@ public class Workspace extends SmoothPagedView
mOverviewModeShrinkFactor =
res.getInteger(R.integer.config_workspaceOverviewShrinkPercentage) / 100.0f;
mCameraDistance = res.getInteger(R.integer.config_cameraDistance);
- mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
+ mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
a.recycle();
setOnHierarchyChangeListener(this);
@@ -453,10 +454,19 @@ public class Workspace extends SmoothPagedView
return mTouchState != TOUCH_STATE_REST;
}
+ public void removeAllWorkspaceScreens() {
+ Log.w(TAG, "10249126 - removeAllWorkspaceScreens()");
+ // Remove the pages and clear the screen models
+ removeAllViews();
+ mScreenOrder.clear();
+ mWorkspaceScreens.clear();
+ }
+
public long insertNewWorkspaceScreenBeforeEmptyScreen(long screenId) {
// Find the index to insert this view into. If the empty screen exists, then
// insert it before that.
int insertIndex = mScreenOrder.indexOf(EXTRA_EMPTY_SCREEN_ID);
+ Log.w(TAG, "10249126 - insertNewWorkspaceScreenBeforeEmptyScreen(" + insertIndex + ")");
if (insertIndex < 0) {
insertIndex = mScreenOrder.size();
}
@@ -494,7 +504,7 @@ public class Workspace extends SmoothPagedView
addFullScreenPage(customScreen);
// Ensure that the current page and default page are maintained.
- mDefaultPage++;
+ mDefaultPage = mOriginalDefaultPage + 1;
setCurrentPage(getCurrentPage() + 1);
}