@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (mDragging && mDragBitmap != null) {
if (mAnimationState == ANIMATION_STATE_STARTING) {
mAnimationStartTime = SystemClock.uptimeMillis();
mAnimationState = ANIMATION_STATE_RUNNING;
}
if (mAnimationState == ANIMATION_STATE_RUNNING) {
float normalized = (float) (SystemClock.uptimeMillis() - mAnimationStartTime) /
mAnimationDuration;
if (normalized >= 1.0f) {
mAnimationState = ANIMATION_STATE_DONE;
}
normalized = Math.min(normalized, 1.0f);
final float value = mAnimationFrom + (mAnimationTo - mAnimationFrom) * normalized;
switch (mAnimationType) {
case ANIMATION_TYPE_SCALE:
final Bitmap dragBitmap = mDragBitmap;
mDragPaint = mTranslucence;
canvas.save();
canvas.translate(mScrollX + mLastMotionX - mTouchOffsetX - mBitmapOffsetX,
mScrollY + mLastMotionY - mTouchOffsetY - mBitmapOffsetY);
canvas.translate((dragBitmap.getWidth() * (1.0f - value)) / 2,
(dragBitmap.getHeight() * (1.0f - value)) / 2);
canvas.scale(value, value);
canvas.drawBitmap(dragBitmap, 0.0f, 0.0f, mDragPaint);
canvas.restore();
break;
}
} else {
//AAA
//calculate.setGroupHeight(groupNavi.getHeight());
drawCanUseSpace(canvas);
drawWingsImg(canvas);
canvas.drawBitmap(mDragBitmap,
mScrollX + mLastMotionX - mTouchOffsetX - mBitmapOffsetX,
mScrollY + mLastMotionY - mTouchOffsetY - mBitmapOffsetY, mDragPaint);
}
//AAAA
} else {
if (needWingsAnimation) {
drawWingsImg(canvas);
}
}
}
private void endDrag() {
if (mDragging) {
//AAA
setDraging(false);
//groupNavi.updateFocusGroup(workspace.getCurrentGroup());
if (workspace.isScrollerFinished()) {
doWingsAnimation();
} else {
if (haveGroupChange) {
haveGroupChange = false;
doWingsAnimation();
} else {
doNotWingsAnimation();
}
}
//
mDragging = false;
if (mDragBitmap != null) {
mDragBitmap.recycle();
}
if (mOriginator != null) {
// mOriginator.setVisibility(VISIBLE);
}
if (mListener != null) {
mListener.onDragEnd();
}
}
}