TimeRulers
TimeRulers copied to clipboard
滑动的时候会重绘,造成闪一下
移动的时候会闪回初始状态再跳转
case MotionEvent.ACTION_MOVE: if (mode == DRAG && mDrag) { int dx = (int) (event.getRawX() - lastX); if (dx == 0) { return false; } int top = getTop(); Log.d("*****onTouchEvent", " dx" + dx + " left" + getLeft() + " right" + getLeft() + getWidth()); int left = getLeft() + dx; int right = left + getWidth();
if (left >= 0) {
left = 0;
right = getWidth();
}
if (right < screenWidth) {
right = screenWidth;
left = right - getWidth();
}
layout(left, top, right, top + getHeight());
invalidate();
lastX = event.getRawX();
lastY = event.getRawY();
int deltaX = (0 - left);
int timeBarLength = getWidth() - screenWidth;
currentTimeInMillisecond = mostLeftTimeInMillisecond + deltaX * WHOLE_TIMEBAR_TOTAL_SECONDS * 1000 / timeBarLength;
if (mOnBarMoveListener != null) {
mOnBarMoveListener.onBarMove(getScreenLeftTimeInMillisecond(), getScreenRightTimeInMillisecond(), currentTimeInMillisecond);
}
}