Cleanup and refactoring in relation to drag and drop

-> folder creation, adding to folders, reordering, switching pages
-> ensuring parity of dragEnter and dragExit in cell layouts and workspace
   (neither were consistently getting an even number of each)
-> actually enforced above with exceptions -- probably want to
   take these out, but maybe we can leave them in as warnings
-> fixed bug with mapping points to hotseat
-> fixes other bugs with drag and drop

Change-Id: I564568f810f2784d122ec6135012b67c2e8e7551
This commit is contained in:
Adam Cohen
2012-04-04 12:47:08 -07:00
parent cffc0b9bee
commit c6cc61d458
5 changed files with 248 additions and 193 deletions
@@ -161,6 +161,7 @@ public class CellLayout extends ViewGroup {
private int[] mDirectionVector = new int[2];
int[] mPreviousReorderDirection = new int[2];
private static final int INVALID_DIRECTION = -100;
private DropTarget.DragEnforcer mDragEnforcer;
public CellLayout(Context context) {
this(context, null);
@@ -172,6 +173,7 @@ public class CellLayout extends ViewGroup {
public CellLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mDragEnforcer = new DropTarget.DragEnforcer(mContext);
// A ViewGroup usually does not draw, but CellLayout needs to draw a rectangle to show
// the user where a dragged item will land when dropped.
@@ -2508,6 +2510,7 @@ public class CellLayout extends ViewGroup {
* or it may have begun on another layout.
*/
void onDragEnter() {
mDragEnforcer.onDragEnter();
if (!mDragging) {
// Fade in the drag indicators
if (mCrosshairsAnimator != null) {
@@ -2521,6 +2524,7 @@ public class CellLayout extends ViewGroup {
* Called when drag has left this CellLayout or has been completed (successfully or not)
*/
void onDragExit() {
mDragEnforcer.onDragExit();
// This can actually be called when we aren't in a drag, e.g. when adding a new
// item to this layout via the customize drawer.
// Guard against that case.