Closed zakrodionov closed 4 years ago
override fun backToFragment(fragment: Class<out Fragment>, refresh: Boolean) {
val lastCurrentStackIndex = fragNavController.currentStack?.lastIndex ?: 0
val indexOfFragment =
fragNavController.currentStack?.indexOfLast { it.javaClass == fragment } ?: -1
if (indexOfFragment == -1) {
fragNavController.clearStack()
fragNavController.pushFragment(fragment.newInstance())
} else {
fragNavController.popFragments(lastCurrentStackIndex - indexOfFragment)
}
if (refresh) {
(fragNavController.currentFrag as? BaseFragment)?.refresh()
}
}
While using so
It would be convenient if there was navigation in a certain fragment. For example, we have a chain a -> b -> c -> d -> e->, and I would like to return,for example, from e to b.