Skip to content

Commit caf1614

Browse files
committed
Release a new version 1.0.7
1 parent 9c30b93 commit caf1614

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

README.md

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
Add a dependency code to your **module**'s `build.gradle` file.
2727
```gradle
2828
dependencies {
29-
implementation "com.github.skydoves:only:1.0.6"
29+
implementation "com.github.skydoves:only:1.0.7"
3030
}
3131
```
3232

@@ -51,6 +51,10 @@ only("introPopup", times = 3) {
5151
onDo { showIntroPopup() }
5252
}
5353
```
54+
Here is the Java codes.
55+
```java
56+
Only.onDo("introPopup", 1, () -> showIntroPopup());
57+
```
5458

5559
### onDone
5660
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) {
7882
}
7983
}
8084
```
85+
Here is the Java codes.
86+
```java
87+
Only.onDo("introPopup", 1,
88+
() -> doSomethingOnlyOnce(), // onDo
89+
() -> doSOmethingAfterDone() // onDone
90+
);
91+
```
8192

8293
### onLastDo, onBeforeDone
8394
We can do pre and post-processing using `onLastDo`, `onBeforeDone` options.
@@ -217,8 +228,23 @@ if (times < 3) {
217228
showIntroPopup();
218229
}
219230
```
220-
### Builder
221-
we can run `Only` in java project using `Only.Builder` and `Runnable`.
231+
### Java Supports
232+
we can run `Only` in our java project.
233+
```java
234+
Only.onDo("introPopup", 1,
235+
new Runnable() {
236+
@Override
237+
public void run() {
238+
doSomethingOnlyOnce();
239+
}
240+
}, new Runnable() {
241+
@Override
242+
public void run() {
243+
doSOmethingAfterDone();
244+
}
245+
});
246+
```
247+
Or we can run using `Only.Builder` like below.
222248
```java
223249
new Only.Builder("introPopup", 1)
224250
.onDo(new Runnable() {
@@ -239,21 +265,18 @@ We can make it more simple using Java8 lambda expression.<br>
239265
Add below codes on your `build.gradle` file.
240266
```gradle
241267
android {
242-
compileOptions {
243-
sourceCompatibility JavaVersion.VERSION_1_8
244-
targetCompatibility JavaVersion.VERSION_1_8
245-
}
268+
compileOptions {
269+
sourceCompatibility JavaVersion.VERSION_1_8
270+
targetCompatibility JavaVersion.VERSION_1_8
271+
}
246272
}
247273
```
248274
Then you can run the Only like below.
249275
```java
250-
new Only.Builder("introPopup", 1)
251-
.onDo(() -> {
252-
doSomethingOnlyOnce();
253-
})
254-
.onDone(() -> {
255-
doSOmethingAfterDone();
256-
}).run(); // run the Only
276+
Only.onDo("introPopup", 1,
277+
() -> doSomethingOnlyOnce(), // onDo
278+
() -> doSOmethingAfterDone() // onDone
279+
);
257280
```
258281
### Custom util class
259282
We can create custom util class like what Kotlin's `onlyOnce`.

dependencies.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ext.versions = [
22
minSdk : 15,
33
compileSdk : 30,
4-
versionCode : 7,
5-
versionName : '1.0.6',
4+
versionCode : 8,
5+
versionName : '1.0.7',
66

77
gradleBuildTool : '3.6.3',
88
spotlessGradle : '5.4.0',

0 commit comments

Comments
 (0)