@@ -172,10 +172,7 @@ public boolean onTouch(View v, MotionEvent event) {
172
172
//Release logic here
173
173
if (arrowHintContainer .getX () + arrowHintContainer .getWidth () > getWidth () * swipeDistance ) {
174
174
// swipe completed, fly the hint away!
175
- animateFadeHide (context , arrowHintContainer );
176
- if (swipeListener != null )
177
- swipeListener .onSwipeConfirm ();
178
- morphToCircle ();
175
+ performSuccessfulSwipe ();
179
176
} else if (arrowHintContainer .getX () <= 0 ) {
180
177
// upon click without swipe
181
178
startFwdAnim ();
@@ -191,6 +188,12 @@ public boolean onTouch(View v, MotionEvent event) {
191
188
});
192
189
}
193
190
191
+ private void performSuccessfulSwipe () {
192
+ if (swipeListener != null )
193
+ swipeListener .onSwipeConfirm ();
194
+ morphToCircle ();
195
+ }
196
+
194
197
@ Override
195
198
protected void onSizeChanged (int w , int h , int oldw , int oldh ) {
196
199
super .onSizeChanged (w , h , oldw , oldh );
@@ -245,7 +248,17 @@ private void startHintInitAnim() {
245
248
arrowHintContainer .startAnimation (anim );
246
249
}
247
250
248
- private void morphToCircle () {
251
+ /**
252
+ * Just like performOnClick() in a standard button,
253
+ * this will call the attached OnSwipeListener
254
+ * and morph the btn to a circle
255
+ */
256
+ public void performOnSwipe () {
257
+ performSuccessfulSwipe ();
258
+ }
259
+
260
+ public void morphToCircle () {
261
+ animateFadeHide (context , arrowHintContainer );
249
262
setOnTouchListener (null );
250
263
ObjectAnimator cornerAnimation =
251
264
ObjectAnimator .ofFloat (gradientDrawable , "cornerRadius" , BTN_INIT_RADIUS , BTN_MORPHED_RADIUS );
0 commit comments