Created
February 2, 2017 22:32
-
-
Save sigmadeltasoftware/1e9aaff92ec116281dfab025bc3ee5cb to your computer and use it in GitHub Desktop.
DoubleTapSeekBar with SimpleOnGestureListener
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
package com.sigmadelta.verticaldoubletapseekbar; | |
import android.content.Context; | |
import android.support.v4.view.GestureDetectorCompat; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.GestureDetector; | |
import android.view.MotionEvent; | |
import android.widget.SeekBar; | |
public class DoubleTapSeekBar extends SeekBar { | |
private GestureDetectorCompat _detector; | |
public DoubleTapSeekBar(Context context) { | |
super(context); | |
_detector = new GestureDetectorCompat(context, new DoubleTapGestureListener()); | |
} | |
public DoubleTapSeekBar(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
_detector = new GestureDetectorCompat(context, new DoubleTapGestureListener()); | |
} | |
public DoubleTapSeekBar(Context context, AttributeSet attrs, int defStyleAttr) { | |
super(context, attrs, defStyleAttr); | |
_detector = new GestureDetectorCompat(context, new DoubleTapGestureListener()); | |
} | |
public DoubleTapSeekBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | |
super(context, attrs, defStyleAttr, defStyleRes); | |
_detector = new GestureDetectorCompat(context, new DoubleTapGestureListener()); | |
} | |
@Override | |
public boolean onTouchEvent(MotionEvent e) { | |
_detector.onTouchEvent(e); | |
return super.onTouchEvent(e); | |
} | |
private class DoubleTapGestureListener extends | |
GestureDetector.SimpleOnGestureListener { | |
@Override | |
public boolean onDoubleTap(MotionEvent event) { | |
Log.d("DoubleTapSeekBar", "Reset to 0dB!"); | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment