Skip to content

Commit

Permalink
Release a new version 1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Sep 10, 2020
1 parent 9c30b93 commit caf1614
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 16 deletions.
51 changes: 37 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
```

Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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() {
Expand All @@ -239,21 +265,18 @@ We can make it more simple using Java8 lambda expression.<br>
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`.
Expand Down
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit caf1614

Please sign in to comment.