Skip to content

Commit 1c46d67

Browse files
committed
1. morphToCircle() is now public so the btn can now be morphed to circle programmatically without the user swiping the button.
2. Added new method: performOnSwipe() to perform a successful swipe programmatically.
1 parent 96b313a commit 1c46d67

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

proswipebutton/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ext {
1313
siteUrl = 'https://github.com/shadowfaxtech/proSwipeButton'
1414
gitUrl = 'https://github.com/shadowfaxtech/proSwipeButton.git'
1515

16-
libraryVersion = '1.0.2'
16+
libraryVersion = '1.1'
1717

1818
developerId = 'developerId'
1919
developerName = 'Ishaan Garg'
@@ -30,8 +30,8 @@ android {
3030
defaultConfig {
3131
minSdkVersion 15
3232
targetSdkVersion 26
33-
versionCode 3
34-
versionName "1.0.2"
33+
versionCode 4
34+
versionName "1.1"
3535
vectorDrawables.useSupportLibrary = true
3636

3737
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

proswipebutton/src/main/java/in/shadowfax/proswipebutton/ProSwipeButton.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)