Transition: Fragment A > Fragment B
Fragment A goes through onDestroyView()
and does NOT go through any other tear down methods.
Transition: Fragment B is popped and Fragment A is restored
Fragment A goes through onAttach()
and onCreate()
. Why is this the case? Shouldn't Fragment A only have to recreate its view?
How fragments are being replaced (in Kotlin):
private fun replaceFragment(fragment: Fragment, @IdRes frameId: Int, fragmentTag: String) {
val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
transaction.replace(frameId, fragment, fragmentTag)
transaction.addToBackStack(fragmentTag)
transaction.commit()
}
Popping the backstack this way:
supportFragmentManager.popBackStack()