@Override
public boolean onTouchEvent(MotionEvent ev) {
case MotionEvent.ACTION_MOVE:
mNavigator.setDrawToVisible(true);
final int scrollX = mScrollX;
final int scrollY = mScrollY;
final float touchX = mTouchOffsetX;
final float touchY = mTouchOffsetY;
final int offsetX = mBitmapOffsetX;
final int offsetY = mBitmapOffsetY;
int left = (int) (scrollX + mLastMotionX - touchX - offsetX);
int top = (int) (scrollY + mLastMotionY - touchY - offsetY);
final Bitmap dragBitmap = mDragBitmap;
final int width = dragBitmap.getWidth();
final int height = dragBitmap.getHeight();
final Rect rect = mRect;
rect.set(left - 1, top - 1, left + width + 1, top + height + 1);
mLastMotionX = x;
mLastMotionY = y;
left = (int) (scrollX + x - touchX - offsetX);
top = (int) (scrollY + y - touchY - offsetY);
rect.union(left - 1, top - 1, left + width + 1, top + height + 1);
final int[] coordinates = mDropCoordinates;
DropTarget dropTarget = findDropTarget((int) x, (int) y, coordinates);
if (dropTarget != null) {
if (mLastDropTarget == dropTarget) {
dropTarget.onDragOver(mDragSource, coordinates[0], coordinates[1],
(int) mTouchOffsetX, (int) mTouchOffsetY, mDragInfo);
} else {
if (mLastDropTarget != null) {
mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
(int) mTouchOffsetX, (int) mTouchOffsetY, mDragInfo);
}
dropTarget.onDragEnter(mDragSource, coordinates[0], coordinates[1],
(int) mTouchOffsetX, (int) mTouchOffsetY, mDragInfo);
}
} else {
if (mLastDropTarget != null) {
mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
(int) mTouchOffsetX, (int) mTouchOffsetY, mDragInfo);
}
}
findCellPoint(dropTarget, coordinates, x, y);
invalidate();
mLastDropTarget = dropTarget;
boolean inDragRegion = false;
if (mDragRegion != null) {
final RectF region = mDragRegion;
final boolean inRegion = region.contains(ev.getRawX(), ev.getRawY());
if (!mEnteredRegion && inRegion) {
mDragPaint = mTrashPaint;
mEnteredRegion = true;
inDragRegion = true;
} else if (mEnteredRegion && !inRegion) {
mDragPaint = mTranslucence;
mEnteredRegion = false;
}
}
int offset = getDragWingsOffset();
if (!inDragRegion && x < SCROLL_ZONE && y >= offset && y <= offset + calculate.getDragWingsHeight()) {
if (mScrollState == SCROLL_OUTSIDE_ZONE) {
mScrollState = SCROLL_WAITING_IN_ZONE;
mScrollRunnable.setDirection(SCROLL_LEFT);
postDelayed(mScrollRunnable, SCROLL_DELAY);
}
} else if (!inDragRegion && x > getWidth() - SCROLL_ZONE && y >= offset && y <= offset + calculate.getDragWingsHeight()) {
if (mScrollState == SCROLL_OUTSIDE_ZONE) {
mScrollState = SCROLL_WAITING_IN_ZONE;
mScrollRunnable.setDirection(SCROLL_RIGHT);
postDelayed(mScrollRunnable, SCROLL_DELAY);
}
} else {
if (mScrollState == SCROLL_WAITING_IN_ZONE) {
mScrollState = SCROLL_OUTSIDE_ZONE;
mScrollRunnable.setDirection(SCROLL_RIGHT);
removeCallbacks(mScrollRunnable);
}
}
break;
}
public boolean onTouchEvent(MotionEvent ev) {
case MotionEvent.ACTION_MOVE:
mNavigator.setDrawToVisible(true);
final int scrollX = mScrollX;
final int scrollY = mScrollY;
final float touchX = mTouchOffsetX;
final float touchY = mTouchOffsetY;
final int offsetX = mBitmapOffsetX;
final int offsetY = mBitmapOffsetY;
int left = (int) (scrollX + mLastMotionX - touchX - offsetX);
int top = (int) (scrollY + mLastMotionY - touchY - offsetY);
final Bitmap dragBitmap = mDragBitmap;
final int width = dragBitmap.getWidth();
final int height = dragBitmap.getHeight();
final Rect rect = mRect;
rect.set(left - 1, top - 1, left + width + 1, top + height + 1);
mLastMotionX = x;
mLastMotionY = y;
left = (int) (scrollX + x - touchX - offsetX);
top = (int) (scrollY + y - touchY - offsetY);
rect.union(left - 1, top - 1, left + width + 1, top + height + 1);
final int[] coordinates = mDropCoordinates;
DropTarget dropTarget = findDropTarget((int) x, (int) y, coordinates);
if (dropTarget != null) {
if (mLastDropTarget == dropTarget) {
dropTarget.onDragOver(mDragSource, coordinates[0], coordinates[1],
(int) mTouchOffsetX, (int) mTouchOffsetY, mDragInfo);
} else {
if (mLastDropTarget != null) {
mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
(int) mTouchOffsetX, (int) mTouchOffsetY, mDragInfo);
}
dropTarget.onDragEnter(mDragSource, coordinates[0], coordinates[1],
(int) mTouchOffsetX, (int) mTouchOffsetY, mDragInfo);
}
} else {
if (mLastDropTarget != null) {
mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
(int) mTouchOffsetX, (int) mTouchOffsetY, mDragInfo);
}
}
findCellPoint(dropTarget, coordinates, x, y);
invalidate();
mLastDropTarget = dropTarget;
boolean inDragRegion = false;
if (mDragRegion != null) {
final RectF region = mDragRegion;
final boolean inRegion = region.contains(ev.getRawX(), ev.getRawY());
if (!mEnteredRegion && inRegion) {
mDragPaint = mTrashPaint;
mEnteredRegion = true;
inDragRegion = true;
} else if (mEnteredRegion && !inRegion) {
mDragPaint = mTranslucence;
mEnteredRegion = false;
}
}
int offset = getDragWingsOffset();
if (!inDragRegion && x < SCROLL_ZONE && y >= offset && y <= offset + calculate.getDragWingsHeight()) {
if (mScrollState == SCROLL_OUTSIDE_ZONE) {
mScrollState = SCROLL_WAITING_IN_ZONE;
mScrollRunnable.setDirection(SCROLL_LEFT);
postDelayed(mScrollRunnable, SCROLL_DELAY);
}
} else if (!inDragRegion && x > getWidth() - SCROLL_ZONE && y >= offset && y <= offset + calculate.getDragWingsHeight()) {
if (mScrollState == SCROLL_OUTSIDE_ZONE) {
mScrollState = SCROLL_WAITING_IN_ZONE;
mScrollRunnable.setDirection(SCROLL_RIGHT);
postDelayed(mScrollRunnable, SCROLL_DELAY);
}
} else {
if (mScrollState == SCROLL_WAITING_IN_ZONE) {
mScrollState = SCROLL_OUTSIDE_ZONE;
mScrollRunnable.setDirection(SCROLL_RIGHT);
removeCallbacks(mScrollRunnable);
}
}
break;
}