Fixed error in navigation implementation

This commit is contained in:
Viktor De Pasquale 2019-10-16 18:53:38 +02:00
parent 974cb1167f
commit 3b4cb23112
2 changed files with 5 additions and 5 deletions

View File

@ -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
}

View File

@ -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) }
}