Skip to content

Instantly share code, notes, and snippets.

@inan-mahmud
Created October 3, 2019 08:34
Show Gist options
  • Save inan-mahmud/2e3cd302207a10c03008bb08d22413b6 to your computer and use it in GitHub Desktop.
Save inan-mahmud/2e3cd302207a10c03008bb08d22413b6 to your computer and use it in GitHub Desktop.
public class EventDataSourceFactory extends DataSource.Factory {
private String date;
private Context context;
private MutableLiveData<PageKeyedDataSource<Integer, EventsItem>> liveDataSource = new MutableLiveData<>();
public EventDataSourceFactory(String date, Context context) {
this.date = date;
this.context = context;
}
@Override
public DataSource create() {
EventDataSource eventDataSource = new EventDataSource(context, date);
liveDataSource.postValue(eventDataSource);
return eventDataSource;
}
public MutableLiveData<PageKeyedDataSource<Integer, EventsItem>> getLiveDataSource() {
return liveDataSource;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment