Prevent navigating to the same fragment
As per this issue,
Feel free to set a OnNavigationItemReselectedListener, which takes precedence over the
OnNavigationItemSelectedListener
set by NavigationUI.
val navController = Navigation.findNavController(this, R.id.nav_host)
bottom_navigation.setupWithNavController(navController)
bottom_navigation.setOnNavigationItemReselectedListener {
// Do nothing to ignore the reselection
}
inside setOnItemSelectedListener use :
if( item.getItemId() == navController.getCurrentDestination().getId()){ return true; }
because OnNavigationItemSelectedListener is deprecated now.