mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 12:05:30 +00:00
Optimize navigation back stack
Fix topjohnwu#4333 Co-authored-by: LoveSy <shana@zju.edu.cn>
This commit is contained in:
parent
1f5992f2c2
commit
b0fba6ce5b
@ -98,8 +98,8 @@ abstract class BaseViewModel(
|
||||
_viewEvents.postValue(this)
|
||||
}
|
||||
|
||||
fun NavDirections.navigate() {
|
||||
_viewEvents.postValue(NavigationEvent(this))
|
||||
fun NavDirections.navigate(pop: Boolean = false) {
|
||||
_viewEvents.postValue(NavigationEvent(this, pop))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -62,10 +62,12 @@ class MagiskInstallFileEvent(
|
||||
}
|
||||
|
||||
class NavigationEvent(
|
||||
private val directions: NavDirections
|
||||
private val directions: NavDirections,
|
||||
private val pop: Boolean
|
||||
) : ViewEvent(), ActivityExecutor {
|
||||
override fun invoke(activity: BaseUIActivity<*, *>) {
|
||||
(activity as? BaseUIActivity<*, *>)?.apply {
|
||||
if (pop) navigation?.popBackStack()
|
||||
directions.navigate()
|
||||
}
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ class InstallViewModel(
|
||||
|
||||
fun install() {
|
||||
when (method) {
|
||||
R.id.method_patch -> FlashFragment.patch(data!!).navigate()
|
||||
R.id.method_direct -> FlashFragment.flash(false).navigate()
|
||||
R.id.method_inactive_slot -> FlashFragment.flash(true).navigate()
|
||||
R.id.method_patch -> FlashFragment.patch(data!!).navigate(true)
|
||||
R.id.method_direct -> FlashFragment.flash(false).navigate(true)
|
||||
R.id.method_inactive_slot -> FlashFragment.flash(true).navigate(true)
|
||||
else -> error("Unknown value")
|
||||
}
|
||||
state = State.LOADING
|
||||
|
@ -150,7 +150,6 @@
|
||||
app:enterAnim="@anim/fragment_enter"
|
||||
app:exitAnim="@anim/fragment_exit"
|
||||
app:popEnterAnim="@anim/fragment_enter_pop"
|
||||
app:popExitAnim="@anim/fragment_exit_pop"
|
||||
app:popUpTo="@id/homeFragment" />
|
||||
app:popExitAnim="@anim/fragment_exit_pop" />
|
||||
|
||||
</navigation>
|
||||
|
Loading…
Reference in New Issue
Block a user