Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save varundwarkani/db6950736306bd1d1cc8d1d83b45554a to your computer and use it in GitHub Desktop.
Save varundwarkani/db6950736306bd1d1cc8d1d83b45554a to your computer and use it in GitHub Desktop.
public class UpcomingMatchesDataSourceFactory extends DataSource.Factory<Integer, UpcomingMatch> {
private UpcomingMatchesRepository upcomingMatchesRepository;
private MutableLiveData<PageKeyedDataSource<Integer, UpcomingMatch>> pageKeyedDataSourceMutableLiveData = new MutableLiveData<>();
public UpcomingMatchesDataSourceFactory(UpcomingMatchesRepository upcomingMatchesRepository) {
this.upcomingMatchesRepository = upcomingMatchesRepository;
}
@Override
public DataSource create() {
UpcomingMatchesDataSource upcomingMatchesDataSource = new UpcomingMatchesDataSource(upcomingMatchesRepository);
pageKeyedDataSourceMutableLiveData.postValue(upcomingMatchesDataSource);
return upcomingMatchesDataSource;
}
public MutableLiveData<PageKeyedDataSource<Integer, UpcomingMatch>> getPageKeyedDataSourceMutableLiveData() {
return pageKeyedDataSourceMutableLiveData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment