Search in sources :

Example 1 with WebmListQuery

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

Aggregations

Response (com.apollographql.apollo.api.Response)1 WebmListQuery (com.example.aleksejkocergin.myapplication.WebmListQuery)1 DisposableObserver (io.reactivex.observers.DisposableObserver)1