0

In my application I want to hide data fetching at the start from the user. As I already read I should do this with the usage of themes. I have created new theme, setted everything and... I'm stuck.

My app is based on MVVM architecture and basically I have only one activity which has FragmentContainerView in which I am changing the fragments. So in the manifest file I already have this splash screen theme and as far as I know, I should change the theme when data is fetched. But how to do it? Should I instantiate ViewModel in activity, call refresh (this method fetches the data), and observe some LiveData to know if data has been fetched and if yes then change theme?

Tried to find some instructions/tutorials about this but haven't found anything useful. Will be grateful for any tips or tutorials from which I can learn.

Thanks!

gawron103
  • 167
  • 6
  • 21

1 Answers1

1

Hmm... I don't think this will work because you need to set the theme before on create is called. See here: Change Activity's theme programmatically

I would suggest instead of making a splash theme, make a splash fragment and do your data fetching logic there. You can then navigate and popUpto the home screen( Assuming you're using navigation components)