File tree Expand file tree Collapse file tree
src/main/java/com/dx/dxloadingbutton/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11apply plugin : ' com.android.application'
22
33android {
4- compileSdkVersion 25
5- buildToolsVersion " 25 .0.3 "
4+ compileSdkVersion 26
5+ buildToolsVersion " 26 .0.2 "
66 defaultConfig {
77 applicationId " com.dx.dxloadingbutton"
88 minSdkVersion 21
9- targetSdkVersion 25
9+ targetSdkVersion 26
1010 versionCode 1
1111 versionName " 1.0"
1212 testInstrumentationRunner " android.support.test.runner.AndroidJUnitRunner"
@@ -24,7 +24,7 @@ dependencies {
2424 androidTestCompile(' com.android.support.test.espresso:espresso-core:2.2.2' , {
2525 exclude group : ' com.android.support' , module : ' support-annotations'
2626 })
27- compile ' com.android.support:appcompat-v7:25.4 .0'
27+ compile ' com.android.support:appcompat-v7:26.1 .0'
2828 testCompile ' junit:junit:4.12'
2929 compile project(' :library' )
3030}
Original file line number Diff line number Diff line change @@ -2,12 +2,12 @@ apply plugin: 'com.android.library'
22apply plugin : ' com.github.dcendents.android-maven'
33
44android {
5- compileSdkVersion 25
6- buildToolsVersion " 25 .0.3 "
5+ compileSdkVersion 26
6+ buildToolsVersion " 26 .0.2 "
77
88 defaultConfig {
99 minSdkVersion 16
10- targetSdkVersion 25
10+ targetSdkVersion 26
1111 versionCode 1
1212 versionName " 1.0"
1313
@@ -27,6 +27,6 @@ dependencies {
2727 androidTestCompile(' com.android.support.test.espresso:espresso-core:2.2.2' , {
2828 exclude group : ' com.android.support' , module : ' support-annotations'
2929 })
30- compile ' com.android.support:appcompat-v7:25.4 .0'
30+ compile ' com.android.support:appcompat-v7:26.1 .0'
3131 testCompile ' junit:junit:4.12'
3232}
Original file line number Diff line number Diff line change @@ -210,20 +210,29 @@ public boolean performClick() {
210210 @ SuppressLint ("ClickableViewAccessibility" )
211211 @ Override
212212 public boolean onTouchEvent (MotionEvent event ) {
213- if (!isEnabled ()){
213+ if (!isEnabled ()) {
214214 return true ;
215215 }
216- switch (event .getAction ()){
216+ switch (event .getAction ()) {
217217 case MotionEvent .ACTION_DOWN :
218218 mTouchX = event .getX ();
219219 mTouchY = event .getY ();
220220 playRippleAnimation (true );
221221 break ;
222222 case MotionEvent .ACTION_UP :
223- playRippleAnimation (false );
223+ if ((event .getX () > mButtonRectF .left && event .getX () < mButtonRectF .right ) &&
224+ (event .getY () > mButtonRectF .top && event .getY () < mButtonRectF .bottom )) {
225+ // only register as click if finger is up inside view
226+ playRippleAnimation (false );
227+ } else {
228+ // if finger is moved outside view and lifted up, reset
229+ mTouchX = 0 ;
230+ mTouchY = 0 ;
231+ mRippleRadius = 0 ;
232+ invalidate ();
233+ }
224234 break ;
225235 }
226-
227236 return true ;
228237 }
229238
You can’t perform that action at this time.
0 commit comments