Created
January 28, 2015 10:26
-
-
Save zinuzoid/daf67a62bd1ae3b33531 to your computer and use it in GitHub Desktop.
ProtectedSeekBar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ProtectedSeekBar | |
* 01/27/15 | |
* | |
* @author Jetsada Machom <[email protected]> | |
*/ | |
public class ProtectedSeekBar extends SeekBar { | |
private Drawable mThumb; | |
public ProtectedSeekBar(Context context, AttributeSet attrs, int defStyleAttr) { | |
super(context, attrs, defStyleAttr); | |
} | |
public ProtectedSeekBar(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public ProtectedSeekBar(Context context) { | |
super(context); | |
} | |
@Override | |
public void setThumb(Drawable thumb) { | |
super.setThumb(thumb); | |
mThumb = thumb; | |
} | |
@Override | |
public boolean onTouchEvent(MotionEvent event) { | |
if(event.getAction() == MotionEvent.ACTION_DOWN) { | |
if( event.getX() < mThumb.getBounds().left || | |
event.getX() > mThumb.getBounds().right || | |
event.getY() > mThumb.getBounds().bottom || | |
event.getY() < mThumb.getBounds().top) { | |
return false; | |
} | |
} | |
return super.onTouchEvent(event); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment