Closed badadin closed 6 years ago
Show your navigator. P.S.: and update Cicerone version :smile:
I have the last version of Cicerone at this moment (3.0.0) Here is my Navigator (just copied example from https://habr.com/company/mobileup/blog/314838/) and modified it):
private val navigator = object : SupportFragmentNavigator(supportFragmentManager, R.id.fragmentContainer) {
override fun createFragment(screenKey: String, data: Any): Fragment? {
return when (screenKey) {
CHART_SCREEN -> ChartFragment.getInstance()
CALENDAR_SCREEN -> CalendarFragment.getInstance()
else -> null
}
}
override fun showSystemMessage(message: String) {
Toast.makeText(this@MainActivity, message, Toast.LENGTH_SHORT).show()
}
override fun exit() {
finish()
}
}
You are trying to navigate to the screen without passing a parameter, so you must allow the parameter to be null. Just make your data parameter optional:
override fun createFragment(screenKey: String, data: Any?): Fragment? {
You are trying to navigate to the screen without passing a parameter, so you must allow the parameter to be null. Just make your data parameter optional:
override fun createFragment(screenKey: String, data: Any?): Fragment? {
Exactly! Thank you very much! Вот я тупой :)
If I use router.navigateTo() without passing data as a second parameter like this:
App.INSTANCE.router.navigateTo(SCREEN_NAME)
the app crashes with IllegalArgumentException. Part of stacktrace:Part of Router.java:
So if the data is null it will crash. But if I pass some data for example: App.INSTANCE.router.navigateTo(SCREEN_NAME, "123") everything wotks great.