Closed OyaCanli closed 5 years ago
I added two more commits: -I replaced ObservableField with LiveData, since according to this article published today: “Android Data Binding Library — From Observable Fields to LiveData in two steps” by Jose Alcérreca https://link.medium.com/C6b1SZ6WlV it is now what Google advises. -I also reorganized packages.
I refactored connectivity check again: connectivity check is done in viewmodel as we talked before. But considering the situation that user might quit the app with back button and return hours later, I made some small changes. So now: If user quits the app with back button and returns later: -He can still see the old data (if system didn't kill the app of course) -IF there is no internet, he can still see the data but he also sees a snack warning. -If turns on the internet and click retry, new data is fetched and shown. -And UIState doesn't turn to NETWORK_ERROR state if there is data. It shows a snack, but it shows also the list, if there is some old data.
I also moved the openWebSite method to the fragment. I had put it in viewmodel, with the aim to demonstrate method references. But as far as I understand, it is not good practice to put something with a reference to a view inside viewmodel. So I moved it back to the fragment.