use of io.reactivex.observers.DisposableObserver 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 io.reactivex.observers.DisposableObserver 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 io.reactivex.observers.DisposableObserver 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 io.reactivex.observers.DisposableObserver in project RxJava-Android-Samples by kaushikgopal.
the class RetrofitFragment method onListContributorsClicked.
@OnClick(R.id.btn_demo_retrofit_contributors)
public void onListContributorsClicked() {
_adapter.clear();
//
_disposables.add(_githubService.contributors(_username.getText().toString(), _repo.getText().toString()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableObserver<List<Contributor>>() {
@Override
public void onComplete() {
Timber.d("Retrofit call 1 completed");
}
@Override
public void onError(Throwable e) {
Timber.e(e, "woops we got an error while getting the list of contributors");
}
@Override
public void onNext(List<Contributor> contributors) {
for (Contributor c : contributors) {
_adapter.add(format("%s has made %d contributions to %s", c.login, c.contributions, _repo.getText().toString()));
Timber.d("%s has made %d contributions to %s", c.login, c.contributions, _repo.getText().toString());
}
}
}));
}
use of io.reactivex.observers.DisposableObserver in project quran_android by quran.
the class QuranPagePresenter method downloadImages.
public void downloadImages() {
screen.hidePageDownloadError();
compositeDisposable.add(quranPageWorker.loadPages(pages).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableObserver<Response>() {
@Override
public void onNext(Response response) {
if (screen != null) {
Bitmap bitmap = response.getBitmap();
if (bitmap != null) {
didDownloadImages = true;
screen.setPageBitmap(response.getPageNumber(), bitmap);
} else {
didDownloadImages = false;
final int errorCode = response.getErrorCode();
final int errorRes;
switch(errorCode) {
case Response.ERROR_SD_CARD_NOT_FOUND:
errorRes = R.string.sdcard_error;
break;
case Response.ERROR_DOWNLOADING_ERROR:
errorRes = R.string.download_error_network;
break;
default:
errorRes = R.string.download_error_general;
}
screen.setPageDownloadError(errorRes);
}
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
}));
}
Aggregations