mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 23:17: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?,
|
fragment: Fragment?,
|
||||||
transactionType: FragNavController.TransactionType
|
transactionType: FragNavController.TransactionType
|
||||||
) = when (transactionType) {
|
) = when (transactionType) {
|
||||||
FragNavController.TransactionType.PUSH -> setDisplayHomeAsUpEnabled(true)
|
FragNavController.TransactionType.PUSH -> setDisplayHomeAsUpEnabled(!navigation.isRoot)
|
||||||
else -> Unit //dunno might be useful
|
else -> Unit //dunno might be useful
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,15 +89,15 @@ class CompatNavigationDelegate<out Source>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun navigateToFragment(event: MagiskNavigationEvent) {
|
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")
|
Timber.e("Cannot navigate to null destination")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
source.baseFragments
|
source.baseFragments
|
||||||
.indexOfFirst { it.java.name == destination.name }
|
.indexOfFirst { it == destination }
|
||||||
.takeIf { it > 0 }
|
.takeIf { it >= 0 }
|
||||||
?.let { controller.switchTab(it) } ?: destination.newInstance()
|
?.let { controller.switchTab(it) } ?: destination.java.newInstance()
|
||||||
.also { it.arguments = event.navDirections.args }
|
.also { it.arguments = event.navDirections.args }
|
||||||
.let { controller.pushFragment(it) }
|
.let { controller.pushFragment(it) }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user