diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 42af49f..8c5b627 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,8 +1,10 @@ + diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..e202dc4 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 5e73d4b..a787d93 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,29 +5,41 @@ - + diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index b026cbe..3c0c584 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ It is a lib for using singleClickListener and PushDown Anim Together ``` ### needed dependencies: ``` - implementation 'com.github.tareq3:PushDown_ExtSingleClick:1.0' + implementation 'com.github.tareq3:PushDown_ExtSingleClick:2.0.0' ``` diff --git a/app/build.gradle b/app/build.gradle index 354717b..0d4c869 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,14 +7,14 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 27 + compileSdkVersion 33 defaultConfig { applicationId "com.mti.pushdown_extsingleclick" minSdkVersion 16 - targetSdkVersion 27 + targetSdkVersion 33 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { release { @@ -22,14 +22,15 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + namespace 'com.mti.pushdown_extsingleclick' } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support.constraint:constraint-layout:1.1.2' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' implementation project(':pushdown_ext_onclick_single') } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6e99b42..5f61f14 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -5,8 +5,7 @@ ~ Last modified 8/7/18 10:29 PM --> - + - + diff --git a/app/src/main/java/com/mti/pushdown_extsingleclick/MainActivity.java b/app/src/main/java/com/mti/pushdown_extsingleclick/MainActivity.java index 0ebbb61..3a60936 100644 --- a/app/src/main/java/com/mti/pushdown_extsingleclick/MainActivity.java +++ b/app/src/main/java/com/mti/pushdown_extsingleclick/MainActivity.java @@ -6,11 +6,13 @@ package com.mti.pushdown_extsingleclick; -import android.support.v7.app.AppCompatActivity; +import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Toast; +import androidx.appcompat.app.AppCompatActivity; + import com.mti.pushdown_ext_onclick_single.PushDownAnim; import com.mti.pushdown_ext_onclick_single.SingleClick; @@ -23,38 +25,20 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); + // Without animation - - - - - - - - - - - //Todo: If you want only singleClick Listener without anim - - - SingleClick.get(findViewById(R.id.mButton)).setOnSingleClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - - Toast.makeText(MainActivity.this, "Clicked "+ i, Toast.LENGTH_SHORT).show(); - i++; - } + /* + SingleClick.get(findViewById(R.id.mButton)).setOnSingleClickListener(v -> { + Toast.makeText(MainActivity.this, "Clicked "+ i, Toast.LENGTH_SHORT).show(); + i++; }); + */ - //Todo: With Anim Single Click Listener - PushDownAnim.setPushDownAnimTo(findViewById(R.id.mButton)).setOnSingleClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - - Toast.makeText(MainActivity.this, "Clicked "+ i, Toast.LENGTH_SHORT).show(); - i++; - } + // With animation + PushDownAnim.setPushDownAnimTo(findViewById(R.id.mButton)).setOnSingleClickListener(v -> { + Toast.makeText(MainActivity.this, "Clicked "+ i, Toast.LENGTH_SHORT).show(); + i++; }); } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 1a49e14..c90ac24 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,16 +1,9 @@ - - - + android:layout_height="match_parent"> - \ No newline at end of file + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 1af2420..625ca18 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.0-beta04' + classpath('com.android.tools.build:gradle:4.2.2') // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle.properties b/gradle.properties index 0fe8e4a..316aa98 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,6 +12,8 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9a4163a..1f3fdbc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/pushdown_ext_onclick_single/build.gradle b/pushdown_ext_onclick_single/build.gradle index 16320d3..dd328da 100644 --- a/pushdown_ext_onclick_single/build.gradle +++ b/pushdown_ext_onclick_single/build.gradle @@ -7,17 +7,13 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 27 - - + compileSdkVersion 33 defaultConfig { minSdkVersion 16 - targetSdkVersion 27 - versionCode 1 - versionName "1.0" + targetSdkVersion 33 - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } @@ -27,16 +23,17 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + namespace 'com.mti.pushdown_ext_onclick_single' } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:27.1.1' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + implementation 'androidx.appcompat:appcompat:1.6.1' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } diff --git a/pushdown_ext_onclick_single/src/main/AndroidManifest.xml b/pushdown_ext_onclick_single/src/main/AndroidManifest.xml index caa05a3..85fa0d2 100644 --- a/pushdown_ext_onclick_single/src/main/AndroidManifest.xml +++ b/pushdown_ext_onclick_single/src/main/AndroidManifest.xml @@ -4,5 +4,4 @@ ~ Last modified 8/7/18 10:35 PM --> - + diff --git a/pushdown_ext_onclick_single/src/main/java/com/mti/pushdown_ext_onclick_single/PushDownAnim.java b/pushdown_ext_onclick_single/src/main/java/com/mti/pushdown_ext_onclick_single/PushDownAnim.java index 2c520f2..91f6acc 100644 --- a/pushdown_ext_onclick_single/src/main/java/com/mti/pushdown_ext_onclick_single/PushDownAnim.java +++ b/pushdown_ext_onclick_single/src/main/java/com/mti/pushdown_ext_onclick_single/PushDownAnim.java @@ -14,7 +14,6 @@ import android.animation.ValueAnimator; import android.graphics.Rect; import android.os.SystemClock; -import android.support.annotation.IntDef; import android.util.TypedValue; import android.view.MotionEvent; import android.view.View; @@ -25,6 +24,8 @@ import static java.lang.annotation.RetentionPolicy.SOURCE; +import androidx.annotation.IntDef; + /*** * Created by Tareq on 07,August,2018. */ diff --git a/pushdown_ext_onclick_single/src/main/java/com/mti/pushdown_ext_onclick_single/SingleClick.java b/pushdown_ext_onclick_single/src/main/java/com/mti/pushdown_ext_onclick_single/SingleClick.java index efd61ab..4f7c549 100644 --- a/pushdown_ext_onclick_single/src/main/java/com/mti/pushdown_ext_onclick_single/SingleClick.java +++ b/pushdown_ext_onclick_single/src/main/java/com/mti/pushdown_ext_onclick_single/SingleClick.java @@ -32,40 +32,22 @@ public class SingleClick { private WeakReference weakView; public SingleClick(View view) { - this.weakView = new WeakReference<>(view) ; - this.weakView.get().setClickable( true ); + this.weakView = new WeakReference<>(view); + this.weakView.get().setClickable(true); } - - - - - //first we need to access the view - public static SingleClick get(View view){ - SingleClick singleClick =new SingleClick(view); + public static SingleClick get(View view) { + SingleClick singleClick = new SingleClick(view); return singleClick; } - - - - - - - - - - - - private long mLastClickTime = 0; //just for resoving fast double click crash issue for DateTime Dialog - public SingleClick setOnSingleClickListener(final View.OnClickListener onClickListener){ - if( weakView.get() != null ){ - + public SingleClick setOnSingleClickListener(final View.OnClickListener onClickListener) { + if (weakView.get() != null) { weakView.get().setOnClickListener(new View.OnClickListener() { @@ -73,8 +55,8 @@ public SingleClick setOnSingleClickListener(final View.OnClickListener onClickLi public void onClick(View v) { // mis-clicking prevention, using threshold of 1000 ms - if (SystemClock.elapsedRealtime() - mLastClickTime < 1000){ - return ; + if (SystemClock.elapsedRealtime() - mLastClickTime < 1000) { + return; } mLastClickTime = SystemClock.elapsedRealtime();