mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 04:25:27 +00:00
Fixed backpress not working
This commit is contained in:
parent
628b37c4fa
commit
50134a2f9b
@ -44,6 +44,9 @@ abstract class MagiskActivity<ViewModel : MagiskViewModel, Binding : ViewDataBin
|
|||||||
FragNavController(supportFragmentManager, navHostId)
|
FragNavController(supportFragmentManager, navHostId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val isRootFragment
|
||||||
|
get() = navigationController?.let { it.currentStackIndex != defaultPosition } ?: false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val isDarkTheme = Config.get<Boolean>(Config.Key.DARK_THEME)
|
val isDarkTheme = Config.get<Boolean>(Config.Key.DARK_THEME)
|
||||||
val theme = if (isDarkTheme) {
|
val theme = if (isDarkTheme) {
|
||||||
@ -148,7 +151,7 @@ abstract class MagiskActivity<ViewModel : MagiskViewModel, Binding : ViewDataBin
|
|||||||
navigationController?.popFragment() ?: throw UnsupportedOperationException()
|
navigationController?.popFragment() ?: throw UnsupportedOperationException()
|
||||||
} catch (e: UnsupportedOperationException) {
|
} catch (e: UnsupportedOperationException) {
|
||||||
when {
|
when {
|
||||||
navigationController?.currentStackIndex != defaultPosition -> {
|
isRootFragment -> {
|
||||||
val options = FragNavTransactionOptions.newBuilder()
|
val options = FragNavTransactionOptions.newBuilder()
|
||||||
.transition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
|
.transition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
|
||||||
.build()
|
.build()
|
||||||
|
Loading…
Reference in New Issue
Block a user