and9

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

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值