I am currently self learning on implementing the MVVM architecture in Android. I'm completely new so please help me out. I'll explain the app that I'm working on first.
I would like to make an app that polls a remote server every N seconds and display the updated data in the UI. In the UI, the user should be able to delete and edit data as well (from the existing list of data, no updating the server).
At the moment I have packages and classes for the Model, Repository, ViewModel and View layers. Repository class returns data in MutableLiveData type, ViewModel calls Repository class and returns the data in LiveData type and View observes the LiveData by calling the ViewModel class.
Currently, I am receiving the Network on Main Exception
which from what I understand, I have to create an AsyncTask to handle this. However, it's depreciated so I would like to use other options like Executor.
A Java suggestion would be better preferred. Which layer should Executor class should be in? Furthermore, how can I poll the server every N seconds? Which class should be responsible for polling and in which layer?