Skip to content Skip to sidebar Skip to footer

Android Paging Library - Which Datasource I Should Use

What I Want: I want to implement Android Paging Library with network call only. What I Understood: So, DataSource has three classes that I can extend. PageKeyedDataSource: If your

Solution 1:

Actually you forgot to post the value inside DataSource.Factory().

Inside GitHubUserViewModel.java class change your DataSource.Factory method code to :

DataSource.Factory<Integer, GitHubUserModel> dataSourceFactory = newDataSource.Factory<Integer, GitHubUserModel>() {
            @Overridepublic DataSource<Integer, GitHubUserModel> create() {
                GitHubUserDataSourcegitHubUserDataSource=newGitHubUserDataSource(mApiEndPoints);
                mGitHubLiveData.postValue(gitHubUserDataSource); // add this line.return gitHubUserDataSource;
            }
        };

Read more about postValue() method here - MutableLiveData.

Post a Comment for "Android Paging Library - Which Datasource I Should Use"