mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 10:37:39 +00:00
Fixed error in navigation implementation
This commit is contained in:
parent
974cb1167f
commit
3b4cb23112
@ -100,7 +100,7 @@ open class MainActivity : CompatActivity<MainViewModel, ActivityMainMd2Binding>(
|
||||
fragment: Fragment?,
|
||||
transactionType: FragNavController.TransactionType
|
||||
) = when (transactionType) {
|
||||
FragNavController.TransactionType.PUSH -> setDisplayHomeAsUpEnabled(true)
|
||||
FragNavController.TransactionType.PUSH -> setDisplayHomeAsUpEnabled(!navigation.isRoot)
|
||||
else -> Unit //dunno might be useful
|
||||
}
|
||||
|
||||
|
@ -89,15 +89,15 @@ class CompatNavigationDelegate<out Source>(
|
||||
}
|
||||
|
||||
private fun navigateToFragment(event: MagiskNavigationEvent) {
|
||||
val destination = event.navDirections.destination?.java ?: let {
|
||||
val destination = event.navDirections.destination ?: let {
|
||||
Timber.e("Cannot navigate to null destination")
|
||||
return
|
||||
}
|
||||
|
||||
source.baseFragments
|
||||
.indexOfFirst { it.java.name == destination.name }
|
||||
.takeIf { it > 0 }
|
||||
?.let { controller.switchTab(it) } ?: destination.newInstance()
|
||||
.indexOfFirst { it == destination }
|
||||
.takeIf { it >= 0 }
|
||||
?.let { controller.switchTab(it) } ?: destination.java.newInstance()
|
||||
.also { it.arguments = event.navDirections.args }
|
||||
.let { controller.pushFragment(it) }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user