morristech
5/10/2018 - 8:33 AM

NetworkBoundResource.interface.java

// ResultType: Type for the Resource data
// RequestType: Type for the API response
public abstract class NetworkBoundResource<ResultType, RequestType> {
    @WorkerThread
    protected abstract void saveCallResult(@NonNull RequestType item);
    @MainThread
    protected abstract boolean shouldFetch(@Nullable ResultType data);
    @NonNull @MainThread
    protected abstract LiveData<ResultType> loadFromDb();
    @NonNull @MainThread
    protected abstract LiveData<ApiResponse<RequestType>> createCall();
}