Commit 3b4cb231 authored by Viktor De Pasquale's avatar Viktor De Pasquale

Fixed error in navigation implementation

parent 974cb116
......@@ -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) }
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment