From caf1614ad252d5636c2cd54af2677ab90449d065 Mon Sep 17 00:00:00 2001 From: skydoves Date: Thu, 10 Sep 2020 21:38:11 +0900 Subject: [PATCH] Release a new version 1.0.7 --- README.md | 51 ++++++++++++++++++++++++++++++++------------- dependencies.gradle | 4 ++-- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index bb12a15..32f1d0c 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Add a dependency code to your **module**'s `build.gradle` file. ```gradle dependencies { - implementation "com.github.skydoves:only:1.0.6" + implementation "com.github.skydoves:only:1.0.7" } ``` @@ -51,6 +51,10 @@ only("introPopup", times = 3) { onDo { showIntroPopup() } } ``` +Here is the Java codes. +```java +Only.onDo("introPopup", 1, () -> showIntroPopup()); +``` ### onDone Below codes will run the `doSomethingAfterDone()` and `toast("done")` after run the `onDo` block codes three times. @@ -78,6 +82,13 @@ only("introPopup", times = 3) { } } ``` +Here is the Java codes. +```java +Only.onDo("introPopup", 1, + () -> doSomethingOnlyOnce(), // onDo + () -> doSOmethingAfterDone() // onDone +); +``` ### onLastDo, onBeforeDone We can do pre and post-processing using `onLastDo`, `onBeforeDone` options. @@ -217,8 +228,23 @@ if (times < 3) { showIntroPopup(); } ``` -### Builder -we can run `Only` in java project using `Only.Builder` and `Runnable`. +### Java Supports +we can run `Only` in our java project. +```java +Only.onDo("introPopup", 1, + new Runnable() { + @Override + public void run() { + doSomethingOnlyOnce(); + } +}, new Runnable() { + @Override + public void run() { + doSOmethingAfterDone(); + } +}); +``` +Or we can run using `Only.Builder` like below. ```java new Only.Builder("introPopup", 1) .onDo(new Runnable() { @@ -239,21 +265,18 @@ We can make it more simple using Java8 lambda expression.
Add below codes on your `build.gradle` file. ```gradle android { - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } ``` Then you can run the Only like below. ```java -new Only.Builder("introPopup", 1) - .onDo(() -> { - doSomethingOnlyOnce(); - }) - .onDone(() -> { - doSOmethingAfterDone(); - }).run(); // run the Only +Only.onDo("introPopup", 1, + () -> doSomethingOnlyOnce(), // onDo + () -> doSOmethingAfterDone() // onDone +); ``` ### Custom util class We can create custom util class like what Kotlin's `onlyOnce`. diff --git a/dependencies.gradle b/dependencies.gradle index 7bb9154..e554ba8 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,8 +1,8 @@ ext.versions = [ minSdk : 15, compileSdk : 30, - versionCode : 7, - versionName : '1.0.6', + versionCode : 8, + versionName : '1.0.7', gradleBuildTool : '3.6.3', spotlessGradle : '5.4.0',