From fb5283e61a26c03fce72579fad1c57d4130096ca Mon Sep 17 00:00:00 2001 From: Mygod Date: Mon, 1 Jun 2020 16:16:57 -0400 Subject: [PATCH] updateConfiguration without being cancelled --- .../java/be/mygod/vpnhotspot/manage/TetheringFragment.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringFragment.kt index 2b16de15..16585a06 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringFragment.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringFragment.kt @@ -33,6 +33,9 @@ import be.mygod.vpnhotspot.util.broadcastReceiver import be.mygod.vpnhotspot.util.isNotGone import be.mygod.vpnhotspot.widget.SmartSnackbar import kotlinx.coroutines.CompletableDeferred +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch import timber.log.Timber import java.lang.reflect.InvocationTargetException import java.net.NetworkInterface @@ -218,8 +221,10 @@ class TetheringFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClick val configuration by lazy { AlertDialogFragment.getRet(data!!).configuration } when (requestCode) { REPEATER_WPS -> adapter.repeaterManager.onWpsResult(resultCode, data) - CONFIGURE_REPEATER -> if (resultCode == DialogInterface.BUTTON_POSITIVE) lifecycleScope.launchWhenCreated { - adapter.repeaterManager.updateConfiguration(configuration) + CONFIGURE_REPEATER -> if (resultCode == DialogInterface.BUTTON_POSITIVE) { + GlobalScope.launch(Dispatchers.Main.immediate) { + adapter.repeaterManager.updateConfiguration(configuration) + } } CONFIGURE_AP -> if (resultCode == DialogInterface.BUTTON_POSITIVE) try { WifiApManager.configuration = configuration