Observe network connnectivity
Observe internet connectivity will ping google.com
This commit is contained in:
parent
42ce6fd334
commit
5ba5f5f94e
@ -6,6 +6,7 @@ import com.skoumal.teanity.extensions.doOnSubscribeUi
|
|||||||
import com.skoumal.teanity.extensions.subscribeK
|
import com.skoumal.teanity.extensions.subscribeK
|
||||||
import com.skoumal.teanity.util.KObservableField
|
import com.skoumal.teanity.util.KObservableField
|
||||||
import com.skoumal.teanity.viewmodel.LoadingViewModel
|
import com.skoumal.teanity.viewmodel.LoadingViewModel
|
||||||
|
import com.topjohnwu.magisk.extensions.get
|
||||||
import com.topjohnwu.magisk.model.events.BackPressEvent
|
import com.topjohnwu.magisk.model.events.BackPressEvent
|
||||||
import com.topjohnwu.magisk.model.events.PermissionEvent
|
import com.topjohnwu.magisk.model.events.PermissionEvent
|
||||||
import com.topjohnwu.magisk.model.events.ViewActionEvent
|
import com.topjohnwu.magisk.model.events.ViewActionEvent
|
||||||
@ -18,8 +19,8 @@ abstract class MagiskViewModel : LoadingViewModel() {
|
|||||||
val isConnected = KObservableField(true)
|
val isConnected = KObservableField(true)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
ReactiveNetwork.observeInternetConnectivity()
|
ReactiveNetwork.observeNetworkConnectivity(get())
|
||||||
.subscribeK { isConnected.value = it }
|
.subscribeK { isConnected.value = it.available() }
|
||||||
.add()
|
.add()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user