Search in sources :

Example 1 with ToggleLikeMutation

use of com.example.aleksejkocergin.myapplication.ToggleLikeMutation 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();
        }
    }));
}
Also used : Response(com.apollographql.apollo.api.Response) DisposableObserver(io.reactivex.observers.DisposableObserver) WebmData(com.example.aleksejkocergin.randomwebm.interfaces.WebmData) ToggleLikeMutation(com.example.aleksejkocergin.myapplication.ToggleLikeMutation)

Aggregations

Response (com.apollographql.apollo.api.Response)1 ToggleLikeMutation (com.example.aleksejkocergin.myapplication.ToggleLikeMutation)1 WebmData (com.example.aleksejkocergin.randomwebm.interfaces.WebmData)1 DisposableObserver (io.reactivex.observers.DisposableObserver)1