Skip to content

Commit

Permalink
Added method to reset the status.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinalwb committed May 15, 2020
1 parent 5f289e5 commit 3d41203
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 21 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// implementation project(path: ':slidetoconfirmlib')
implementation 'com.github.chinalwb:slidetoconfirm:1.0.1'
implementation project(path: ':slidetoconfirmlib')
// implementation 'com.github.chinalwb:slidetoconfirm:1.0.1'

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

SlideToConfirm slideToConfirm = findViewById(R.id.slide_to_confirm);
final SlideToConfirm slideToConfirm = findViewById(R.id.slide_to_confirm);
slideToConfirm.setSlideListener(new ISlideListener() {
@Override
public void onSlideStart() {
Expand All @@ -35,6 +35,12 @@ public void onSlideCancel() {
@Override
public void onSlideDone() {
Log.w("XX", "on Done!!");
slideToConfirm.postDelayed(new Runnable() {
@Override
public void run() {
slideToConfirm.reset();
}
}, 1000 * 3);
}
});
}
Expand Down
Binary file added app/src/main/res/drawable-hdpi/slider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
android:layout_gravity="center_vertical"
android:layout_margin="20dp"

app:border_radius="30dp"
app:border_width="2dp"
app:border_radius="10dp"
app:border_width="1dp"
app:slider_background_color="@color/pact_purple"
app:slider_color="@color/colorAccent"
app:slider_lottie="lottie_x.json"
app:slider_image="@drawable/slider"
app:slider_width="100dp"
app:slider_reset_duration="1000"
app:slider_width="60dp"
app:slider_reset_duration="300"
app:slider_vibration_duration="50"
app:slider_threshold="1dp"
app:engage_text="Your action text"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-all.zip
57 changes: 57 additions & 0 deletions slidetoconfirmlib/build-aar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// ./gradlew clean build generateRelease
apply plugin: 'maven'

def groupId = project.PUBLISH_GROUP_ID
def artifactId = project.PUBLISH_ARTIFACT_ID
def version = project.PUBLISH_VERSION

def localReleaseDest = "${buildDir}/release/${version}"

task androidJavadocs(type: Javadoc) {
failOnError = false
source = android.sourceSets.main.java.srcDirs
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath += files(ext.androidJar)
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}

uploadArchives {
repositories.mavenDeployer {
pom.groupId = groupId
pom.artifactId = artifactId
pom.version = version
// Add other pom properties here if you want (developer details / licenses)
repository(url: "file://${localReleaseDest}")
}
}

task zipRelease(type: Zip) {
from localReleaseDest
destinationDir buildDir
archiveName "release-${version}.zip"
}

task generateRelease {
doLast {
println "Release ${version} can be found at ${localReleaseDest}/"
println "Release ${version} zipped can be found ${buildDir}/release-${version}.zip"
}
}

generateRelease.dependsOn(uploadArchives)
generateRelease.dependsOn(zipRelease)


artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
23 changes: 12 additions & 11 deletions slidetoconfirmlib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
apply plugin: 'com.android.library'


//ext {
// PUBLISH_GROUP_ID = 'com.github.chinalwb'
// PUBLISH_ARTIFACT_ID = 'slidetoconfirm'
// PUBLISH_VERSION = '1.0.1'
//}
//
//tasks.withType(Javadoc) {
// options.addStringOption('Xdoclint:none', '-quiet')
// options.addStringOption('encoding', 'UTF-8')
// options.addStringOption('charSet', 'UTF-8')
//}
ext {
PUBLISH_GROUP_ID = 'com.github.chinalwb'
PUBLISH_ARTIFACT_ID = 'slidetoconfirm'
PUBLISH_VERSION = '1.0.2'
}

tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}

android {
compileSdkVersion 29
Expand Down Expand Up @@ -48,4 +48,5 @@ dependencies {
implementation 'com.airbnb.android:lottie:3.4.0'
}

apply from: './build-aar.gradle'
// apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,15 @@ public boolean onTouchEvent(MotionEvent ev) {
return true;
}

resetStatus();
resetSlider();
}

performClick();

return true;
}

private void resetStatus() {
private void resetSlider() {
mDownX = 0;
mDeltaX = 0;
mStartDrag = false;
Expand Down Expand Up @@ -408,6 +408,21 @@ private void setUnlockedStatus() {
notifySliderDone();
}

public void reset() {
mDownX = 0;
mDeltaX = 0;
mUnlocked = false;
mStartDrag = false;

RelativeLayout.LayoutParams swipedLayoutParams = (RelativeLayout.LayoutParams) mSwipedView.getLayoutParams();
swipedLayoutParams.width = mSliderWidth;
mSwipedView.setLayoutParams(swipedLayoutParams);

mEngagedTextView.setVisibility(View.VISIBLE);
mSlider.setVisibility(View.VISIBLE);
mCTA.setVisibility(View.GONE);
}


private void handleVibration() {
if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.VIBRATE) !=
Expand Down

0 comments on commit 3d41203

Please sign in to comment.