From 3b4cb23112ff4077c7a54181502402e953689d75 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Wed, 16 Oct 2019 18:53:38 +0200 Subject: [PATCH] Fixed error in navigation implementation --- .../java/com/topjohnwu/magisk/redesign/MainActivity.kt | 2 +- .../magisk/redesign/compat/CompatNavigationDelegate.kt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt index cdabd6a83..85a60f756 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt @@ -100,7 +100,7 @@ open class MainActivity : CompatActivity( fragment: Fragment?, transactionType: FragNavController.TransactionType ) = when (transactionType) { - FragNavController.TransactionType.PUSH -> setDisplayHomeAsUpEnabled(true) + FragNavController.TransactionType.PUSH -> setDisplayHomeAsUpEnabled(!navigation.isRoot) else -> Unit //dunno might be useful } diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatNavigationDelegate.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatNavigationDelegate.kt index 3fe6b5123..ec224af66 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatNavigationDelegate.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/compat/CompatNavigationDelegate.kt @@ -89,15 +89,15 @@ class CompatNavigationDelegate( } 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) } }