@@ -19,21 +19,26 @@ public class PhasedSeekBar extends View {
19
19
protected static final int [] STATE_PRESSED = new int [] { android .R .attr .state_pressed };
20
20
21
21
protected int [] mState = STATE_SELECTED ;
22
+
22
23
protected boolean mModeIsHorizontal = true ;
23
24
protected boolean mFirstDraw = true ;
24
25
protected boolean mUpdateFromPosition = false ;
25
26
protected boolean mDrawOnOff = true ;
26
27
protected boolean mFixPoint = true ;
28
+
27
29
protected Drawable mBackgroundDrawable ;
28
30
protected RectF mBackgroundPaddingRect ;
31
+
29
32
protected int mCurrentX , mCurrentY ;
30
33
protected int mPivotX , mPivotY ;
31
34
protected int mItemHalfWidth , mItemHalfHeight ;
32
35
protected int mItemAnchorHalfWidth , mItemAnchorHalfHeight ;
33
36
protected int [][] mAnchors ;
34
37
protected int mCurrentItem ;
38
+
35
39
protected PhasedAdapter mAdapter ;
36
40
protected PhasedListener mListener ;
41
+ protected PhasedInteractionListener mInteractionListener ;
37
42
38
43
public PhasedSeekBar (Context context ) {
39
44
super (context );
@@ -169,9 +174,13 @@ public boolean onTouchEvent(MotionEvent event) {
169
174
mCurrentY = !mModeIsHorizontal ? getNormalizedY (event ) : mPivotY ;
170
175
int action = event .getAction ();
171
176
mUpdateFromPosition = mFixPoint && action == MotionEvent .ACTION_UP ;
172
- mState = action == MotionEvent .ACTION_UP || action == MotionEvent .ACTION_CANCEL
173
- ? STATE_SELECTED : STATE_PRESSED ;
177
+ mState = action == MotionEvent .ACTION_UP || action == MotionEvent .ACTION_CANCEL ? STATE_SELECTED : STATE_PRESSED ;
174
178
invalidate ();
179
+
180
+ if (mInteractionListener != null ) {
181
+ mInteractionListener .onInteracted (mCurrentX , mCurrentY , mCurrentItem , event );
182
+ }
183
+
175
184
switch (action ) {
176
185
case MotionEvent .ACTION_DOWN :
177
186
case MotionEvent .ACTION_UP :
@@ -204,6 +213,10 @@ public void setListener(PhasedListener listener) {
204
213
mListener = listener ;
205
214
}
206
215
216
+ public void setInteractionListener (PhasedInteractionListener interactionListener ) {
217
+ mInteractionListener = interactionListener ;
218
+ }
219
+
207
220
public void setPosition (int position ) {
208
221
position = position < 0 ? 0 : position ;
209
222
position = position >= mAdapter .getCount () ? mAdapter .getCount () - 1 : position ;
0 commit comments