Prevent creating duplicate configuration dialog

This commit is contained in:
Mygod
2020-06-16 06:34:52 +08:00
parent d00d7983d1
commit 84eb0d33f1

View File

@@ -35,10 +35,7 @@ import be.mygod.vpnhotspot.util.formatAddresses
import be.mygod.vpnhotspot.util.showAllowingStateLoss import be.mygod.vpnhotspot.util.showAllowingStateLoss
import be.mygod.vpnhotspot.widget.SmartSnackbar import be.mygod.vpnhotspot.widget.SmartSnackbar
import kotlinx.android.parcel.Parcelize import kotlinx.android.parcel.Parcelize
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.*
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import timber.log.Timber import timber.log.Timber
import java.net.NetworkInterface import java.net.NetworkInterface
import java.net.SocketException import java.net.SocketException
@@ -142,12 +139,17 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
} }
} }
fun configure() = parent.viewLifecycleOwner.lifecycleScope.launchWhenCreated { private var configureJob: Job? = null
getConfiguration()?.let { (config, readOnly) -> fun configure() {
WifiApDialogFragment().apply { if (configureJob != null) return
arg(WifiApDialogFragment.Arg(config, readOnly, true)) configureJob = parent.viewLifecycleOwner.lifecycleScope.launchWhenCreated {
key(this@RepeaterManager.javaClass.name) getConfiguration()?.let { (config, readOnly) ->
}.showAllowingStateLoss(parent.parentFragmentManager) WifiApDialogFragment().apply {
arg(WifiApDialogFragment.Arg(config, readOnly, true))
key(this@RepeaterManager.javaClass.name)
}.showAllowingStateLoss(parent.parentFragmentManager)
}
configureJob = null
} }
} }