ui: do not return to detail page when restoring state
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
46bf98d7f6
commit
5e844bed5e
@ -17,13 +17,16 @@ import kotlinx.coroutines.launch
|
|||||||
*/
|
*/
|
||||||
abstract class BaseActivity : ThemeChangeAwareActivity() {
|
abstract class BaseActivity : ThemeChangeAwareActivity() {
|
||||||
private val selectionChangeRegistry = SelectionChangeRegistry()
|
private val selectionChangeRegistry = SelectionChangeRegistry()
|
||||||
|
private var created = false
|
||||||
var selectedTunnel: ObservableTunnel? = null
|
var selectedTunnel: ObservableTunnel? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
val oldTunnel = field
|
val oldTunnel = field
|
||||||
if (oldTunnel == value) return
|
if (oldTunnel == value) return
|
||||||
field = value
|
field = value
|
||||||
onSelectedTunnelChanged(oldTunnel, value)
|
if (created) {
|
||||||
selectionChangeRegistry.notifyCallbacks(oldTunnel, 0, value)
|
onSelectedTunnelChanged(oldTunnel, value)
|
||||||
|
selectionChangeRegistry.notifyCallbacks(oldTunnel, 0, value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addOnSelectedTunnelChangedListener(listener: OnSelectedTunnelChangedListener) {
|
fun addOnSelectedTunnelChangedListener(listener: OnSelectedTunnelChangedListener) {
|
||||||
@ -39,10 +42,17 @@ abstract class BaseActivity : ThemeChangeAwareActivity() {
|
|||||||
intent != null -> intent.getStringExtra(KEY_SELECTED_TUNNEL)
|
intent != null -> intent.getStringExtra(KEY_SELECTED_TUNNEL)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
if (savedTunnelName != null)
|
if (savedTunnelName != null) {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
selectedTunnel = Application.getTunnelManager().getTunnels()[savedTunnelName]
|
val tunnel = Application.getTunnelManager().getTunnels()[savedTunnelName]
|
||||||
|
if (tunnel == null)
|
||||||
|
created = true
|
||||||
|
selectedTunnel = tunnel
|
||||||
|
created = true
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
created = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
|
Loading…
Reference in New Issue
Block a user