
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.SeekBar;

@SuppressLint("ClickableViewAccessibility")
public class AccurateSeekBar extends SeekBar {

	private float lastXPosition;
	
	public AccurateSeekBar(Context context) {
		super(context);
	}

	public AccurateSeekBar(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public AccurateSeekBar(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
	        case MotionEvent.ACTION_MOVE:
	    		if (Math.abs(event.getY()) < (this.getHeight() * 2)) {
	        		this.setProgress((int)(this.getMax() * (float)(event.getX() / ((float)this.getWidth() - 1))));
	    		} else {
	        		float trackingHorizontalDistance = event.getX() - this.lastXPosition;
	        		float valuePerPixel = (float)this.getMax() / (float)this.getWidth();
	        		float valueDivisor = Math.abs(event.getY()) / (float)this.getHeight();
	    			float offset = (trackingHorizontalDistance * valuePerPixel) / valueDivisor;
	    			this.setProgress(this.getProgress() + (int)offset);
	    		}
	            break;
        }
        this.lastXPosition = event.getX();
        return true;
	}
	
}

@@ -257,16 +257,63 @@
 kBar %7B%0A%0A
+%09private final float THRESHOLD_MULTIPLIER = 2;%0A
 %09private
@@ -674,95 +674,38 @@
 ) %7B%0A
-        switch (event.getAction()) %7B%0A%09        case MotionEvent.ACTION_MOVE:%0A%09    %09%09if (
+%09%09boolean shouldTrackNormal = 
 Math
@@ -726,16 +726,23 @@
 Y()) %3C (
+(float)
 this.get
@@ -756,133 +756,137 @@
 ) * 
-2)) %7B%0A%09        %09%09this.setProgress((int)(this.getMax() * (float)(event.getX() / ((float)this.getWidth() - 1))));%0A%09    %09%09%7D else
+THRESHOLD_MULTIPLIER);%0A        switch (event.getAction()) %7B%0A%09        case MotionEvent.ACTION_MOVE:%0A%09    %09%09if (!shouldTrackNormal)
  %7B%0A%09
@@ -1367,16 +1367,64 @@
   return
+ shouldTrackNormal ? super.onTouchEvent(event) :
  true;%0A%09

refactor for clarity