File tree Expand file tree Collapse file tree 4 files changed +19
-5
lines changed
NetworkX/src/main/java/com/rommansabbir/networkx/core
src/main/java/com/rommansabbir/networkobserverexample Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Original file line number Diff line number Diff 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
7676Sates 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 () {
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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.
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments