diff options
author | Winson Chung <winsonc@google.com> | 2012-05-07 15:58:50 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-07 15:58:50 -0700 |
commit | 7fb9481d0983f6dd88f8e06b139be696dfc6ce61 (patch) | |
tree | 7fc0a4319b3afea6a9dcccc94b796e7254639c1d /src/com | |
parent | b2a275ecd2a5c02f2c4b51f5142e0d253746e534 (diff) | |
parent | 36a62fe917be0a2520c457f985075fb5d3d09d1c (diff) | |
download | packages_apps_trebuchet-7fb9481d0983f6dd88f8e06b139be696dfc6ce61.zip packages_apps_trebuchet-7fb9481d0983f6dd88f8e06b139be696dfc6ce61.tar.gz packages_apps_trebuchet-7fb9481d0983f6dd88f8e06b139be696dfc6ce61.tar.bz2 |
Merge "Further preventing drags while loading is in progress. (Bug 6276881)" into jb-dev
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher2/Folder.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherModel.java | 18 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedViewWithDraggableItems.java | 2 |
4 files changed, 32 insertions, 8 deletions
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java index 0389264..f63e9bc 100644 --- a/src/com/android/launcher2/Folder.java +++ b/src/com/android/launcher2/Folder.java @@ -200,6 +200,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } public boolean onLongClick(View v) { + // Return if global dragging is not enabled + if (!mLauncher.isDraggingEnabled()) return true; + Object tag = v.getTag(); if (tag instanceof ShortcutInfo) { ShortcutInfo item = (ShortcutInfo) tag; diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 0614312..d0f4b86 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -496,6 +496,12 @@ public final class Launcher extends Activity return mDragLayer; } + boolean isDraggingEnabled() { + // We prevent dragging when we are loading the workspace as it is possible to pick up a view + // that is subsequently removed from the workspace in startBinding(). + return !mModel.isLoadingWorkspace(); + } + static int getScreen() { synchronized (sLock) { return sScreen; @@ -2082,14 +2088,9 @@ public final class Launcher extends Activity } public boolean onLongClick(View v) { - - if (mState != State.WORKSPACE) { - return false; - } - - if (isWorkspaceLocked()) { - return false; - } + if (!isDraggingEnabled()) return false; + if (isWorkspaceLocked()) return false; + if (mState != State.WORKSPACE) return false; if (!(v instanceof CellLayout)) { v = (View) v.getParent().getParent(); diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index 97e52fe..7e4901e 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -745,6 +745,15 @@ public class LauncherModel extends BroadcastReceiver { return mAllAppsLoaded; } + boolean isLoadingWorkspace() { + synchronized (mLock) { + if (mLoaderTask != null) { + return mLoaderTask.isLoadingWorkspace(); + } + } + return false; + } + /** * Runnable for the thread that loads the contents of the launcher: * - workspace icons @@ -755,6 +764,7 @@ public class LauncherModel extends BroadcastReceiver { private Context mContext; private Thread mWaitThread; private boolean mIsLaunching; + private boolean mIsLoadingAndBindingWorkspace; private boolean mStopped; private boolean mLoadAndBindStepFinished; private HashMap<Object, CharSequence> mLabelCache; @@ -769,7 +779,13 @@ public class LauncherModel extends BroadcastReceiver { return mIsLaunching; } + boolean isLoadingWorkspace() { + return mIsLoadingAndBindingWorkspace; + } + private void loadAndBindWorkspace() { + mIsLoadingAndBindingWorkspace = true; + // Load the workspace if (DEBUG_LOADERS) { Log.d(TAG, "loadAndBindWorkspace mWorkspaceLoaded=" + mWorkspaceLoaded); @@ -1381,6 +1397,8 @@ public class LauncherModel extends BroadcastReceiver { Log.d(TAG, "bound workspace in " + (SystemClock.uptimeMillis()-t) + "ms"); } + + mIsLoadingAndBindingWorkspace = false; } }); } diff --git a/src/com/android/launcher2/PagedViewWithDraggableItems.java b/src/com/android/launcher2/PagedViewWithDraggableItems.java index a047970..22fd82b 100644 --- a/src/com/android/launcher2/PagedViewWithDraggableItems.java +++ b/src/com/android/launcher2/PagedViewWithDraggableItems.java @@ -107,6 +107,8 @@ public abstract class PagedViewWithDraggableItems extends PagedView // When we have exited all apps or are in transition, disregard long clicks if (!mLauncher.isAllAppsCustomizeOpen() || mLauncher.getWorkspace().isSwitchingState()) return false; + // Return if global dragging is not enabled + if (!mLauncher.isDraggingEnabled()) return false; return beginDragging(v); } |