Fix var capture
This commit is contained in:
parent
139f586be6
commit
e90b87b037
1 changed files with 5 additions and 4 deletions
|
|
@ -33,11 +33,12 @@ class Application : Application() {
|
|||
|
||||
private fun registerNetworkCallback() {
|
||||
val connectivityManager = getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
// If there's already a default network at registration time, registerDefaultNetworkCallback
|
||||
// will synchronously deliver an initial onAvailable for it. That's not a real transition, so
|
||||
// skip the first onAvailable in that case to avoid a spurious reconnect on every cold start.
|
||||
var skipInitialAvailable = connectivityManager.activeNetwork != null
|
||||
connectivityManager.registerDefaultNetworkCallback(object : ConnectivityManager.NetworkCallback() {
|
||||
// If there's already a default network at registration time, registerDefaultNetworkCallback
|
||||
// will deliver an initial onAvailable for it. That's not a real transition, so skip the
|
||||
// first onAvailable in that case to avoid a spurious reconnect on every cold start.
|
||||
private var skipInitialAvailable = connectivityManager.activeNetwork != null
|
||||
|
||||
override fun onAvailable(network: Network) {
|
||||
if (skipInitialAvailable) {
|
||||
skipInitialAvailable = false
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue