mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-25 14:57:24 +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)
|
_viewEvents.postValue(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun NavDirections.navigate() {
|
fun NavDirections.navigate(pop: Boolean = false) {
|
||||||
_viewEvents.postValue(NavigationEvent(this))
|
_viewEvents.postValue(NavigationEvent(this, pop))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,10 +62,12 @@ class MagiskInstallFileEvent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
class NavigationEvent(
|
class NavigationEvent(
|
||||||
private val directions: NavDirections
|
private val directions: NavDirections,
|
||||||
|
private val pop: Boolean
|
||||||
) : ViewEvent(), ActivityExecutor {
|
) : ViewEvent(), ActivityExecutor {
|
||||||
override fun invoke(activity: BaseUIActivity<*, *>) {
|
override fun invoke(activity: BaseUIActivity<*, *>) {
|
||||||
(activity as? BaseUIActivity<*, *>)?.apply {
|
(activity as? BaseUIActivity<*, *>)?.apply {
|
||||||
|
if (pop) navigation?.popBackStack()
|
||||||
directions.navigate()
|
directions.navigate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,9 @@ class InstallViewModel(
|
|||||||
|
|
||||||
fun install() {
|
fun install() {
|
||||||
when (method) {
|
when (method) {
|
||||||
R.id.method_patch -> FlashFragment.patch(data!!).navigate()
|
R.id.method_patch -> FlashFragment.patch(data!!).navigate(true)
|
||||||
R.id.method_direct -> FlashFragment.flash(false).navigate()
|
R.id.method_direct -> FlashFragment.flash(false).navigate(true)
|
||||||
R.id.method_inactive_slot -> FlashFragment.flash(true).navigate()
|
R.id.method_inactive_slot -> FlashFragment.flash(true).navigate(true)
|
||||||
else -> error("Unknown value")
|
else -> error("Unknown value")
|
||||||
}
|
}
|
||||||
state = State.LOADING
|
state = State.LOADING
|
||||||
|
@ -150,7 +150,6 @@
|
|||||||
app:enterAnim="@anim/fragment_enter"
|
app:enterAnim="@anim/fragment_enter"
|
||||||
app:exitAnim="@anim/fragment_exit"
|
app:exitAnim="@anim/fragment_exit"
|
||||||
app:popEnterAnim="@anim/fragment_enter_pop"
|
app:popEnterAnim="@anim/fragment_enter_pop"
|
||||||
app:popExitAnim="@anim/fragment_exit_pop"
|
app:popExitAnim="@anim/fragment_exit_pop" />
|
||||||
app:popUpTo="@id/homeFragment" />
|
|
||||||
|
|
||||||
</navigation>
|
</navigation>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user