I have a two fragments, A and B. Let say fragment A is a person form and B is a city searcher.
In fragment A, I query the database server for some data, and until I get this info I display a ProgressBar
. Once all data is available and set to each of the form fields in the layout, I set the ProgressBar
to GONE
.
From fragment A, user can open fragment B (I use FragmentTransaction.replace()
) to search for the city. However, when the user press back or choses a city (I close fragment B using FragmentManager.popBackStack()
) and gets back to fragment A, the view of fragment A is created again, so the ProgressBar
is visible.
Since I already loaded all information from the server, my code doesn't reach the section where I set the ProgressBar
visibility to GONE
.
Ideally, when creating fragment A view again savedInstanceState
shouldn't be null (I save some stuff in onSaveInstanceState()
), so in that case I could hide the ProgressBar
, but savedInstanceState
is always null.
Is there anyway to know from fragment A if view is being recreated because user is back after closing fragment B? I can only think about creating a variable to control if ProgressBar
should be displayed...