diff --git a/library/src/main/kotlin/com/github/terrakok/cicerone/androidx/AppNavigator.kt b/library/src/main/kotlin/com/github/terrakok/cicerone/androidx/AppNavigator.kt index 7a1a29d..6611684 100644 --- a/library/src/main/kotlin/com/github/terrakok/cicerone/androidx/AppNavigator.kt +++ b/library/src/main/kotlin/com/github/terrakok/cicerone/androidx/AppNavigator.kt @@ -17,7 +17,7 @@ open class AppNavigator @JvmOverloads constructor( protected val activity: FragmentActivity, protected val containerId: Int, protected val fragmentManager: FragmentManager = activity.supportFragmentManager, - protected val fragmentFactory: FragmentFactory = FragmentFactory() + protected val fragmentFactory: FragmentFactory = fragmentManager.fragmentFactory ) : Navigator { protected val localStackCopy = mutableListOf() @@ -109,6 +109,7 @@ open class AppNavigator @JvmOverloads constructor( ) { val fragment = screen.createFragment(fragmentFactory) val transaction = fragmentManager.beginTransaction() + transaction.setReorderingAllowed(true) setupFragmentTransaction( transaction, fragmentManager.findFragmentById(containerId), diff --git a/library/stub-android/src/main/java/androidx/fragment/app/FragmentManager.java b/library/stub-android/src/main/java/androidx/fragment/app/FragmentManager.java index 9fc01fc..d5a58c3 100644 --- a/library/stub-android/src/main/java/androidx/fragment/app/FragmentManager.java +++ b/library/stub-android/src/main/java/androidx/fragment/app/FragmentManager.java @@ -36,6 +36,10 @@ public Fragment findFragmentById(int id) { throw new RuntimeException("Stub!"); } + public FragmentFactory getFragmentFactory() { + throw new RuntimeException("Stub!"); + } + public interface BackStackEntry { int getId(); diff --git a/library/stub-android/src/main/java/androidx/fragment/app/FragmentTransaction.java b/library/stub-android/src/main/java/androidx/fragment/app/FragmentTransaction.java index 5474548..ee398b8 100644 --- a/library/stub-android/src/main/java/androidx/fragment/app/FragmentTransaction.java +++ b/library/stub-android/src/main/java/androidx/fragment/app/FragmentTransaction.java @@ -6,6 +6,10 @@ */ public class FragmentTransaction { + public FragmentTransaction setReorderingAllowed(boolean reorderingAllowed) { + throw new RuntimeException("Stub!"); + } + public FragmentTransaction add(int containerViewId, Fragment fragment, String tag) { throw new RuntimeException("Stub!"); } diff --git a/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/animations/ProfileActivity.kt b/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/animations/ProfileActivity.kt index 6cdf062..2b65fba 100644 --- a/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/animations/ProfileActivity.kt +++ b/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/animations/ProfileActivity.kt @@ -46,7 +46,7 @@ class ProfileActivity : AppCompatActivity() { super.onPause() } - private val navigator: Navigator = object : AppNavigator(this, R.id.container, supportFragmentManager, supportFragmentManager.fragmentFactory) { + private val navigator: Navigator = object : AppNavigator(this, R.id.container) { override fun setupFragmentTransaction(fragmentTransaction: FragmentTransaction, currentFragment: Fragment?, nextFragment: Fragment?) { if (currentFragment is ProfileFragment diff --git a/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/bottom/TabContainerFragment.kt b/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/bottom/TabContainerFragment.kt index c6759c8..011ff71 100644 --- a/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/bottom/TabContainerFragment.kt +++ b/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/bottom/TabContainerFragment.kt @@ -23,7 +23,7 @@ import javax.inject.Inject class TabContainerFragment : Fragment(), RouterProvider, BackButtonListener { private val navigator: Navigator by lazy { - AppNavigator(activity!!, R.id.ftc_container, childFragmentManager, childFragmentManager.fragmentFactory) + AppNavigator(activity!!, R.id.ftc_container, childFragmentManager) } @Inject diff --git a/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/main/MainActivity.kt b/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/main/MainActivity.kt index 9e3761f..e7def6b 100644 --- a/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/main/MainActivity.kt +++ b/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/main/MainActivity.kt @@ -31,7 +31,7 @@ class MainActivity : MvpAppCompatActivity(), ChainHolder { @Inject lateinit var navigatorHolder: NavigatorHolder - private val navigator: Navigator = object : AppNavigator(this, R.id.main_container, supportFragmentManager, supportFragmentManager.fragmentFactory) { + private val navigator: Navigator = object : AppNavigator(this, R.id.main_container) { override fun applyCommands(commands: Array) { super.applyCommands(commands) diff --git a/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/start/StartActivity.kt b/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/start/StartActivity.kt index d2661cf..5c178d0 100644 --- a/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/start/StartActivity.kt +++ b/sample/src/main/java/com/github/terrakok/cicerone/sample/ui/start/StartActivity.kt @@ -29,7 +29,7 @@ class StartActivity : MvpAppCompatActivity(), StartActivityView { @InjectPresenter lateinit var presenter: StartActivityPresenter - private val navigator: Navigator = AppNavigator(this, -1, supportFragmentManager, supportFragmentManager.fragmentFactory) + private val navigator: Navigator = AppNavigator(this, -1) @ProvidePresenter fun createStartActivityPresenter() = StartActivityPresenter(router)