fix NPE in NetworkChangeReceiver
This commit is contained in:
parent
ee13848928
commit
733370a126
|
@ -29,7 +29,7 @@ class NetworkChangeReceiver : DaggerBroadcastReceiver() {
|
||||||
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
val networks: Array<Network> = cm.allNetworks
|
val networks: Array<Network> = cm.allNetworks
|
||||||
networks.forEach {
|
networks.forEach {
|
||||||
val capabilities = cm.getNetworkCapabilities(it)
|
val capabilities = cm.getNetworkCapabilities(it) ?: return@forEach
|
||||||
event.wifiConnected = event.wifiConnected || (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
|
event.wifiConnected = event.wifiConnected || (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
|
||||||
|| capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET))
|
|| capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET))
|
||||||
event.mobileConnected = event.mobileConnected || capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
|
event.mobileConnected = event.mobileConnected || capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
|
||||||
|
|
Loading…
Reference in a new issue