Skip to content

Commit bb5039c

Browse files
committed
- Added isCanceled() to determine if the the observation is cancelled or not.
- Documentation updated with Strategy Interval Times
1 parent bb54322 commit bb5039c

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Step 2. Add the dependency.
5454

5555
| Releases
5656
| ------------- |
57-
| 2.0.0 |
57+
| 2.1.0 |
5858

5959
### What's new in this version?
6060

@@ -75,10 +75,10 @@ Provide `Application` reference & `NetworkXObservingStrategy` to `NetworkX` .
7575
`NetworkXObservingStrategy` represent delay time in internet connection status checking
7676
Sates are:
7777

78-
* `NetworkXObservingStrategy.LOW`
79-
* `NetworkXObservingStrategy.MEDIUM`
80-
* `NetworkXObservingStrategy.HIGH`
81-
* `NetworkXObservingStrategy.REALTIME`
78+
* `NetworkXObservingStrategy.LOW` (15 * 1000) (Millis)
79+
* `NetworkXObservingStrategy.MEDIUM` (10 * 1000) (Millis)
80+
* `NetworkXObservingStrategy.HIGH` (3 * 1000) (Millis)
81+
* `NetworkXObservingStrategy.REALTIME` (1 * 1000) (Millis)
8282

8383
```kotlin
8484
override fun onCreate() {

app/NetworkX/src/main/java/com/rommansabbir/networkx/core/NetworkX.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ interface NetworkX {
3434
* @param strategy, [NetworkXObservingStrategy]
3535
*/
3636
fun updateStrategy(strategy: NetworkXObservingStrategy)
37+
38+
/**
39+
* Check if the observation is canceled or not
40+
*/
41+
fun isCanceled(): Boolean
3742
}

app/NetworkX/src/main/java/com/rommansabbir/networkx/core/NetworkXImpl.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ class NetworkXImpl(
8181
}
8282
}
8383

84+
override fun isCanceled(): Boolean {
85+
return ioScope == null && mainScope == null
86+
}
87+
8488
/**
8589
* Start observing network status by calling [isNetworkAvailable] method
8690
* which return the internet connection status.

app/src/main/java/com/rommansabbir/networkobserverexample/MainActivity.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ class MainActivity : AppCompatActivity() {
3030
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
3131
}
3232

33+
private fun isCanceled() {
34+
showMessage("Is Canceled: ${NetworkXCore.getNetworkX().isCanceled()}")
35+
}
36+
3337
override fun onResume() {
3438
super.onResume()
3539
NetworkXCore.getNetworkX().isInternetConnected()
40+
isCanceled()
3641

3742
NetworkXCore.getNetworkX().isInternetConnectedLiveData().observe(
3843
this

0 commit comments

Comments
 (0)