當前位置: 首頁>>代碼示例>>Java>>正文


Java DisposableObserver類代碼示例

本文整理匯總了Java中io.reactivex.observers.DisposableObserver的典型用法代碼示例。如果您正苦於以下問題:Java DisposableObserver類的具體用法?Java DisposableObserver怎麽用?Java DisposableObserver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DisposableObserver類屬於io.reactivex.observers包,在下文中一共展示了DisposableObserver類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDisposableObserver

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
private DisposableObserver<String> getDisposableObserver() {

        return new DisposableObserver<String>() {

            @Override
            public void onNext(String response) {
                Log.d(TAG, "onResponse response : " + response);
            }

            @Override
            public void onError(Throwable e) {
                Log.d(TAG, "onError " + e.getMessage());
            }

            @Override
            public void onComplete() {
                Log.d(TAG, "onCompleted");
            }
        };
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:SubscriptionActivity.java

示例2: getCompanies

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
private void getCompanies() {
    Disposable disposable = companiesRepository
            .getCompanies()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeWith(new DisposableObserver<List<Company>>() {
                @Override
                public void onNext(List<Company> value) {
                    view.showCompanies(value);
                }

                @Override
                public void onError(Throwable e) {

                }

                @Override
                public void onComplete() {

                }
            });
    compositeDisposable.add(disposable);
}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:24,代碼來源:CompaniesPresenter.java

示例3: myToList

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
public static <T> ObservableOperator<List<T>, T> myToList() {
        return observer -> new DisposableObserver<T>() {
            ArrayList<T> list = new ArrayList<>();

            @Override
            public void onNext(T value) {
//add to List, but don't pass anything downstream
                list.add(value);
            }

            @Override
            public void onError(Throwable t) {
                observer.onError(t);
            }

            @Override
            public void onComplete() {
                observer.onNext(list); //push List downstream
                observer.onComplete();
            }
        };
    }
 
開發者ID:PacktPublishing,項目名稱:Learning-RxJava,代碼行數:23,代碼來源:Ch9_8.java

示例4: getObserver

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
private DisposableObserver<Long> getObserver() {
    return new DisposableObserver<Long>() {

        @Override
        public void onNext(Long value) {
            textView.append(" onNext : value : " + value);
            textView.append(AppConstant.LINE_SEPARATOR);
            Log.d(TAG, " onNext : value : " + value);
        }

        @Override
        public void onError(Throwable e) {
            textView.append(" onError : " + e.getMessage());
            textView.append(AppConstant.LINE_SEPARATOR);
            Log.d(TAG, " onError : " + e.getMessage());
        }

        @Override
        public void onComplete() {
            textView.append(" onComplete");
            textView.append(AppConstant.LINE_SEPARATOR);
            Log.d(TAG, " onComplete");
        }
    };
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:IntervalExampleActivity.java

示例5: onRunSchedulerExampleButtonClicked

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
void onRunSchedulerExampleButtonClicked() {
    disposables.add(sampleObservable()
        // Run on a background thread
        .subscribeOn(Schedulers.io())
        // Be notified on the main thread
        .observeOn(AndroidSchedulers.mainThread())
        .subscribeWith(new DisposableObserver<String>() {
            @Override public void onComplete() {
                Log.d(TAG, "onComplete()");
            }

            @Override public void onError(Throwable e) {
                Log.e(TAG, "onError()", e);
            }

            @Override public void onNext(String string) {
                Log.d(TAG, "onNext(" + string + ")");
            }
        }));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:MainActivity.java

示例6: changeCycle

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
private void changeCycle(Cycle cycle) {
    if (addSubscriptionAdaptor != null) {
        addSubscriptionAdaptor.clearData();
    }
    if (disposableUpdates != null) {
        disposableUpdates.dispose();
    }
    disposableUpdates = subscribeToSubscriptionUpdates.execute(
            new DisposableObserver<UserSubscriptionDto>() {
                @Override public void onNext(@NonNull UserSubscriptionDto subscriptionDto) {
                    showUsersCollectionInView(subscriptionDto);
                }

                @Override public void onError(@NonNull Throwable throwable) {

                }

                @Override public void onComplete() {

                }
            }, cycle == null ? Params.forCaseAll() : Params.forCase(cycle));
}
 
開發者ID:riteshakya037,項目名稱:Subs,代碼行數:23,代碼來源:UserSubscriptionListPresenterImpl.java

示例7: startLocationScan

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
private void startLocationScan() {

        RxLocation rxLocation = new RxLocation(this);

        LocationRequest locationRequest = LocationRequest.create()
                .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                .setInterval(TimeUnit.SECONDS.toMillis(5));

        rxLocationObserver = rxLocation.location()
                .updates(locationRequest)
                .subscribeOn(Schedulers.io())
                .flatMap(location -> rxLocation.geocoding().fromLocation(location).toObservable())
                .observeOn(Schedulers.io())
                .subscribeWith(new DisposableObserver<Address>() {
                    @Override public void onNext(Address address) {

                        boolean isLocationsEnabled = App.INSTANCE.getSharedPreferences().isLocationsEnabled();
                        if (isLocationsEnabled) {
                            mOWDevice.setGpsLocation(address);
                        } else if (rxLocationObserver != null) {
                            rxLocationObserver.dispose();
                        }
                    }

                    @Override public void onError(Throwable e) {
                        Log.e(TAG, "onError: error retreiving location", e);
                    }

                    @Override public void onComplete() {
                        Log.d(TAG, "onComplete: ");
                    }
                });
    }
 
開發者ID:ponewheel,項目名稱:android-ponewheel,代碼行數:34,代碼來源:MainActivity.java

示例8: disposeOnResume

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
private void disposeOnResume() {
    Disposable d = Observable
            .interval(1, TimeUnit.SECONDS)
            .subscribeWith(new DisposableObserver<Long>() {
                @Override
                public void onNext(Long value) {
                    Log.d(TAG, "Timer A:" + value.toString() + " Seconds");
                }

                @Override
                public void onError(Throwable e) {
                    Log.e(TAG, "onError", e);
                }

                @Override
                public void onComplete() {
                    Log.d(TAG, "onComplete");
                }
            });

    /*
     * Dispose observer on ActivityEvent.RESUME
     */
    dispose(d, ActivityEvent.RESUME);
}
 
開發者ID:mahmed8003,項目名稱:RxLifecycle,代碼行數:26,代碼來源:MainActivity.java

示例9: disposeOnDestroy

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
private void disposeOnDestroy() {
    Disposable d = Observable
            .interval(1, TimeUnit.SECONDS)
            .subscribeWith(new DisposableObserver<Long>() {
                @Override
                public void onNext(Long value) {
                    Log.d(TAG, "Timer B:" + value.toString() + " Seconds");
                }

                @Override
                public void onError(Throwable e) {
                    Log.e(TAG, "onError", e);
                }

                @Override
                public void onComplete() {
                    Log.d(TAG, "onComplete");
                }
            });

    /*
     * Dispose observer
     */
    dispose(d);
}
 
開發者ID:mahmed8003,項目名稱:RxLifecycle,代碼行數:26,代碼來源:MainActivity.java

示例10: checkIfPageIsBookmarked

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
private void checkIfPageIsBookmarked(Integer... pages) {
  compositeDisposable.add(bookmarkModel.getIsBookmarkedObservable(pages)
      .observeOn(AndroidSchedulers.mainThread())
      .subscribeWith(new DisposableObserver<Pair<Integer, Boolean>>() {

        @Override
        public void onNext(Pair<Integer, Boolean> result) {
          bookmarksCache.put(result.first, result.second);
        }

        @Override
        public void onError(Throwable e) {
        }

        @Override
        public void onComplete() {
          supportInvalidateOptionsMenu();
        }
      }));
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:21,代碼來源:PagerActivity.java

示例11: bind

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
@Override
public void bind(PagerActivity what) {
  minimumPage = Constants.NO_PAGE;
  maximumPage = Constants.NO_PAGE;
  lastPage = Constants.NO_PAGE;

  disposable = what.getViewPagerObservable()
      .subscribeWith(new DisposableObserver<Integer>() {
        @Override
        public void onNext(Integer value) {
          onPageChanged(value);
        }

        @Override
        public void onError(Throwable e) {
        }

        @Override
        public void onComplete() {
        }
      });
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:23,代碼來源:RecentPagePresenter.java

示例12: onRunSchedulerExampleButtonClicked

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
void onRunSchedulerExampleButtonClicked() {
    disposables.add(sampleObservable()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeWith(new DisposableObserver<String>() {
                @Override
                public void onComplete() {
                    Log.d(TAG, "onComplete()");
                }

                @Override
                public void onError(Throwable e) {
                    Log.e(TAG, "onError()", e);
                }

                @Override
                public void onNext(String string) {
                    Log.d(TAG, "onNext(" + string + ")");
                }
            }));
}
 
開發者ID:jinseongho,項目名稱:RxAndroidExample,代碼行數:22,代碼來源:MainActivity.java

示例13: getAyahCoordinates

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
private void getAyahCoordinates(Integer... pages) {
  compositeDisposable.add(
      Observable.fromArray(pages)
          .flatMap(coordinatesModel::getAyahCoordinates)
          .observeOn(AndroidSchedulers.mainThread())
          .subscribeWith(new DisposableObserver<Pair<Integer, Map<String, List<AyahBounds>>>>() {
            @Override
            public void onNext(Pair<Integer, Map<String, List<AyahBounds>>> coordinates) {
              if (screen != null) {
                screen.setAyahCoordinatesData(coordinates.first, coordinates.second);
              }
            }

            @Override
            public void onError(Throwable e) {
            }

            @Override
            public void onComplete() {
              if (quranSettings.shouldHighlightBookmarks()) {
                getBookmarkedAyahs(pages);
              }
            }
          })
  );
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:27,代碼來源:QuranPagePresenter.java

示例14: getUserProfile

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
private void getUserProfile() {
    manage(getUserProfile.execute(new DisposableObserver<UserProfile>() {
        @Override public void onNext(@NonNull UserProfile userProfile) {
            userProfileView.setName(userProfile.getUserFullName());
            userProfileView.setEmail(userProfile.getUserEmail());
            maxSubs = userProfile.getSubAvailable();
            updateCounts();
        }

        @Override public void onError(@NonNull Throwable e) {

        }

        @Override public void onComplete() {

        }
    }, null));
}
 
開發者ID:riteshakya037,項目名稱:Subs,代碼行數:19,代碼來源:UserProfileFragmentPresenterImpl.java

示例15: initialize

import io.reactivex.observers.DisposableObserver; //導入依賴的package包/類
public void initialize(SubscriptionType subscriptionType) {
    manage(subscribeToSubscriptionUpdates.execute(new DisposableObserver<SubscriptionDto>() {
        @Override public void onNext(@NonNull SubscriptionDto subscriptionDto) {
            showUsersCollectionInView(subscriptionDto);
        }

        @Override public void onError(@NonNull Throwable throwable) {

        }

        @Override public void onComplete() {

        }
    }, SubscribeToSubscriptionUpdates.Params.forCase(subscriptionType)));
    this.hideViewRetry();
    this.showViewLoading();
}
 
開發者ID:riteshakya037,項目名稱:Subs,代碼行數:18,代碼來源:SubscriptionListPresenterImpl.java


注:本文中的io.reactivex.observers.DisposableObserver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。