Further preventing drags while loading is in progress. (Bug 6276881)

Change-Id: I3fc9ad4cd3d71a8eba4e3bcc0a1b6346c59fbee5
This commit is contained in:
Winson Chung 2012-05-06 18:04:42 -07:00
parent 04cb48f465
commit 36a62fe917
4 changed files with 32 additions and 8 deletions

View File

@ -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;

View File

@ -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;
@ -2077,14 +2083,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();

View File

@ -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;
}
});
}

View File

@ -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);
}