Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
b0fba6ce
Commit
b0fba6ce
authored
Jan 20, 2022
by
石松洲
Committed by
John Wu
Jan 20, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize navigation back stack
Fix topjohnwu#4333 Co-authored-by:
LoveSy
<
shana@zju.edu.cn
>
parent
1f5992f2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
8 deletions
+9
-8
BaseViewModel.kt
app/src/main/java/com/topjohnwu/magisk/arch/BaseViewModel.kt
+2
-2
ViewEvents.kt
app/src/main/java/com/topjohnwu/magisk/events/ViewEvents.kt
+3
-1
InstallViewModel.kt
.../java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt
+3
-3
main.xml
app/src/main/res/navigation/main.xml
+1
-2
No files found.
app/src/main/java/com/topjohnwu/magisk/arch/BaseViewModel.kt
View file @
b0fba6ce
...
@@ -98,8 +98,8 @@ abstract class BaseViewModel(
...
@@ -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
))
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/events/ViewEvents.kt
View file @
b0fba6ce
...
@@ -62,10 +62,12 @@ class MagiskInstallFileEvent(
...
@@ -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
()
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt
View file @
b0fba6ce
...
@@ -84,9 +84,9 @@ class InstallViewModel(
...
@@ -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
...
...
app/src/main/res/navigation/main.xml
View file @
b0fba6ce
...
@@ -150,7 +150,6 @@
...
@@ -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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment