use of com.apollographql.apollo.api.Response in project RandomWebm by alkocher.
the class ToggleVotesUtil method toggleLike.
public void toggleLike(String webmId, boolean hasLike, boolean hasDislike) {
ApolloMutationCall<ToggleLikeMutation.Data> likeMutationCall = WebmApolloClient.getWebmApolloClient().mutate(new ToggleLikeMutation(webmId, hasLike, hasDislike));
mDisposable.add(Rx2Apollo.from(likeMutationCall).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribeWith(new DisposableObserver<Response<ToggleLikeMutation.Data>>() {
@Override
public void onNext(Response<ToggleLikeMutation.Data> dataResponse) {
}
@Override
public void onError(Throwable e) {
webmData.showErrorSnackbar();
}
@Override
public void onComplete() {
webmData.showSuccessSnackbar();
}
}));
}
use of com.apollographql.apollo.api.Response in project RandomWebm by alkocher.
the class WebmDetailsFetcher method fetchWebmDetails.
public void fetchWebmDetails() {
ApolloCall<WebmQuery.Data> webmQuery = WebmApolloClient.getWebmApolloClient().query(new WebmQuery(webmId));
disposable.add(Rx2Apollo.from(webmQuery).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribeWith(new DisposableObserver<Response<WebmQuery.Data>>() {
@Override
public void onNext(Response<WebmQuery.Data> dataResponse) {
webmData.render(dataResponse.data());
}
@Override
public void onError(Throwable e) {
webmData.showErrorSnackbar();
}
@Override
public void onComplete() {
}
}));
}
use of com.apollographql.apollo.api.Response in project RandomWebm by alkocher.
the class WebmListFragment method fetchWebmList.
private void fetchWebmList() {
errorCheckConnection.setVisibility(View.GONE);
errorNoResults.setVisibility(View.GONE);
bottomLayout.setVisibility(View.VISIBLE);
ApolloCall<WebmListQuery.Data> webmListQuery = WebmApolloClient.getWebmApolloClient().query(new WebmListQuery(PAGE_SIZE, Order.valueOf(order), ++currentPage, tagName, likedWebms));
disposables.add(Rx2Apollo.from(webmListQuery).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableObserver<Response<WebmListQuery.Data>>() {
@Override
public void onNext(Response<WebmListQuery.Data> dataResponse) {
setWebmData(dataResponse.data());
}
@Override
public void onError(Throwable e) {
swipeContainer.setRefreshing(false);
errorCheckConnection.setVisibility(View.VISIBLE);
Log.e(TAG, e.getMessage(), e);
}
@Override
public void onComplete() {
swipeContainer.setRefreshing(false);
bottomLayout.setVisibility(View.GONE);
}
}));
}
use of com.apollographql.apollo.api.Response in project apollo-android by apollographql.
the class ApolloInterceptorTest method applicationInterceptorCanMakeMultipleRequestsToServer.
@Test
public void applicationInterceptorCanMakeMultipleRequestsToServer() throws Exception {
server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_CHANGE));
EpisodeHeroNameQuery query = createHeroNameQuery();
ApolloInterceptor interceptor = createChainInterceptor();
client = createApolloClient(interceptor);
enqueueAndAssertResponse(server, FILE_EPISODE_HERO_NAME_WITH_ID, client.query(query), new Predicate<Response<EpisodeHeroNameQuery.Data>>() {
@Override
public boolean test(Response<EpisodeHeroNameQuery.Data> response) throws Exception {
assertThat(response.data().hero().name()).isEqualTo("Artoo");
return true;
}
});
}
use of com.apollographql.apollo.api.Response in project apollo-android by apollographql.
the class ApolloInterceptorTest method onShortCircuitingResponseSubsequentInterceptorsAreNotCalled.
@Test
public void onShortCircuitingResponseSubsequentInterceptorsAreNotCalled() throws IOException, ApolloException {
EpisodeHeroNameQuery query = createHeroNameQuery();
final InterceptorResponse expectedResponse = prepareInterceptorResponse(query);
ApolloInterceptor firstInterceptor = createShortcutInterceptor(expectedResponse);
ApolloInterceptor secondInterceptor = createChainInterceptor();
client = ApolloClient.builder().serverUrl(server.url("/")).okHttpClient(okHttpClient).addApplicationInterceptor(firstInterceptor).addApplicationInterceptor(secondInterceptor).build();
assertResponse(client.query(query), new Predicate<Response<EpisodeHeroNameQuery.Data>>() {
@Override
public boolean test(Response<EpisodeHeroNameQuery.Data> response) throws Exception {
assertThat(expectedResponse.parsedResponse.get()).isEqualTo(response);
return true;
}
});
}
Aggregations