summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/gallery3d/app/TimeBar.java46
1 files changed, 21 insertions, 25 deletions
diff --git a/src/com/android/gallery3d/app/TimeBar.java b/src/com/android/gallery3d/app/TimeBar.java
index 1f3630622..f52879732 100644
--- a/src/com/android/gallery3d/app/TimeBar.java
+++ b/src/com/android/gallery3d/app/TimeBar.java
@@ -237,32 +237,28 @@ public class TimeBar extends View {
int y = (int) event.getY();
switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- if (inScrubber(x, y)) {
- scrubbing = true;
- scrubberCorrection = x - scrubberLeft;
- listener.onScrubbingStart();
- return true;
- }
- break;
- case MotionEvent.ACTION_MOVE:
- if (scrubbing) {
- scrubberLeft = x - scrubberCorrection;
- clampScrubber();
- currentTime = getScrubberTime();
- listener.onScrubbingMove(currentTime);
- invalidate();
- return true;
- }
- break;
+ case MotionEvent.ACTION_DOWN: {
+ scrubberCorrection = inScrubber(x, y)
+ ? x - scrubberLeft
+ : scrubber.getWidth() / 2;
+ scrubbing = true;
+ listener.onScrubbingStart();
+ }
+ // fall-through
+ case MotionEvent.ACTION_MOVE: {
+ scrubberLeft = x - scrubberCorrection;
+ clampScrubber();
+ currentTime = getScrubberTime();
+ listener.onScrubbingMove(currentTime);
+ invalidate();
+ return true;
+ }
case MotionEvent.ACTION_CANCEL:
- case MotionEvent.ACTION_UP:
- if (scrubbing) {
- listener.onScrubbingEnd(getScrubberTime());
- scrubbing = false;
- return true;
- }
- break;
+ case MotionEvent.ACTION_UP: {
+ listener.onScrubbingEnd(getScrubberTime());
+ scrubbing = false;
+ return true;
+ }
}
}
return false;