Skip to main content

Posts

Showing posts with the label ViewModel with Context

WP Android App using REST and Volley with LiveData and ViewModel Part3

In last two part of our WP Android App using REST volley tutorial we have learned about how to fetch the post using REST api from wordpress website. In this part of the article we are going to implement the ViewModel and LiveData component to avoid the refresh every time when any configuration change happening in your app. When configuration change happen in any android application. A common event which trigger the configuration change is the screen rotation. So whenever any configuration change event happen then application will fetch the details from server. Which is creating unnecessary call to backend server and network. Solution of the Configuration Change Data reset issue As explained  above whenever any configuration change happen data is getting reset and application try to fetch the details from the server. As solution of this problem we are going to implement the ViewModel and LiveData architecture component to our application. First of all we are explaining here what we al...

How to use LiveData and ViewModel as Async Task Loader

We often required to load some data which take a long time to load. For this, we use the Async Task Loader to load the data in the background. But now we have an alternative for this work and we can use the LiveData and ViewModel as Async Task Loader. In this article, I am going to explain how to use the LiveData and ViewModel as Async Task Loader. LiveData and ViewModel as Async Task Loader Here to explain the use of LiveData and ViewModel to load the data like Async Task Loader we will create an app to list all installed package on a device. Below is the sample of the app which we are going to develop in this article of How to use LiveData and ViewModel as Async Task Loader. In this Article, I am going to create a demo app to list all app installed on your device. We will create four class and will go with each of the class one by one. AppData.java: It is the POJO to store the details of the apps like AppName, Package Name, Icon. AppDataModel.java: It is the main class in which we w...