I'm tring to make an action bar back button leads to different locations depends on which fragment of layout is visible. I want to make it always back to previous activity despite one case, when going back from one fragment must be proceded by another fragment with info about screen rotation. I tried simple if statement but even when RiderArenaFragment is visible, it goes back to home activity.
override fun onActionBarButtonClicked(@IdRes id: Int) {
when (id) {
R.id.ab_back_btn -> {
if(RiderArenaFragment().isVisible) setFragment(RiderArenaInfoFragment())
else finish()
}
}
}