@@ -172,10 +172,7 @@ public boolean onTouch(View v, MotionEvent event) {
172172 //Release logic here
173173 if (arrowHintContainer .getX () + arrowHintContainer .getWidth () > getWidth () * swipeDistance ) {
174174 // swipe completed, fly the hint away!
175- animateFadeHide (context , arrowHintContainer );
176- if (swipeListener != null )
177- swipeListener .onSwipeConfirm ();
178- morphToCircle ();
175+ performSuccessfulSwipe ();
179176 } else if (arrowHintContainer .getX () <= 0 ) {
180177 // upon click without swipe
181178 startFwdAnim ();
@@ -191,6 +188,12 @@ public boolean onTouch(View v, MotionEvent event) {
191188 });
192189 }
193190
191+ private void performSuccessfulSwipe () {
192+ if (swipeListener != null )
193+ swipeListener .onSwipeConfirm ();
194+ morphToCircle ();
195+ }
196+
194197 @ Override
195198 protected void onSizeChanged (int w , int h , int oldw , int oldh ) {
196199 super .onSizeChanged (w , h , oldw , oldh );
@@ -245,7 +248,17 @@ private void startHintInitAnim() {
245248 arrowHintContainer .startAnimation (anim );
246249 }
247250
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 );
249262 setOnTouchListener (null );
250263 ObjectAnimator cornerAnimation =
251264 ObjectAnimator .ofFloat (gradientDrawable , "cornerRadius" , BTN_INIT_RADIUS , BTN_MORPHED_RADIUS );
0 commit comments