I have a navigation graph like this
It's a folder/file listing app, when click a folder it will navigate to the same fragment with new instance by the action defined by the graph. After I navigate to some folders and currently in Folder D, a breadcrumb of buttons like below.
Root -> Folder A -> Folder B -> Folder C -> Folder D
When I click on Folder B on the breadcrumb, how can I pop or navigate back to the "Folder B" fragment that is in the back stack?
Edit: Navigation code
// Handle click a folder, navigate to new listing fragment
private fun onItemClick(
adapter: BaseQuickAdapter<Any, BaseViewHolder>,
view: View,
position: Int
){
val item = adapter.getItem(position) as? CloudFile ?: return
if (item.isDirectory){
findNavController().navigate(R.id.action_cloudFileListing, bundleOf(ARG_CLOUD_FOLDER to item), getNavOptions())
}
}
private fun getNavOptions(): NavOptions? {
return NavOptions.Builder()
.setEnterAnim(R.anim.enter_from_right)
.setExitAnim(R.anim.exit_to_left)
.setPopEnterAnim(R.anim.enter_from_left)
.setPopExitAnim(R.anim.exit_to_right)
.build()
}