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


Java CompositeDisposable類代碼示例

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


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

示例1: QuestionPresenter

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
QuestionPresenter(QuestionContract.View view, RequestFactory requestFactory,
    TriviaSharedPreferences triviaSharedPreferences, int amount, String categoryId,
    String difficulty, String questionType) {
  this.view = view;
  this.requestFactory = requestFactory;
  this.triviaSharedPreferences = triviaSharedPreferences;
  this.amount = amount;
  this.categoryId = categoryId;
  this.difficulty = difficulty;
  this.questionType = questionType;

  sessionToken = triviaSharedPreferences.getSessionToken();
  questionsList = new ArrayList<>();
  questionPosition = 0;
  numberOfCorrectAnswers = 0;

  compositeDisposable = new CompositeDisposable();
  view.setPresenter(this);
}
 
開發者ID:dfloureiro,項目名稱:opentrivia,代碼行數:20,代碼來源:QuestionPresenter.java

示例2: onBindViewHolder

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
@Override
public void onBindViewHolder(ChapterViewHolder holder, int position) {

    CompositeDisposable compositeDisposable = new CompositeDisposable();

    holder.binding.webview.loadUrl(BLANK_URL);
    holder.binding.webview.setUrlInterceptor(strategy.urlInterceptor);

    SpineReference spineReference = epub.getBook().getSpine().getSpineReferences().get(position);
    holder.binding.webview.loadEpubPage(epub, spineReference, epubView.getSettings());

    Bridge bridge = new Bridge();
    holder.binding.webview.setInternalBridge(bridge);

    handleLocation(position, holder.binding.webview);

    bridge.xPath()
            .doOnNext(xPath -> {
                EpubLocation location = EpubLocation.fromXPath(strategy.getCurrentChapter(), xPath);
                strategy.setCurrentLocation(location);
            })
            .subscribeWith(new BaseDisposableObserver<>())
            .addTo(compositeDisposable);
}
 
開發者ID:smartmobilefactory,項目名稱:EpubReaderAndroid,代碼行數:25,代碼來源:ChapterAdapter.java

示例3: test

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
@Test public void test() {


        CompletableSubject subject = CompletableSubject.create();
        Completable source = subject.hide();


        TestObserver testObserver = new TestObserver();
        CompositeDisposable composite = new CompositeDisposable();
        Disposable disposable = source
                .compose(DisposableAttach.<String>to(composite))
                .subscribeWith(testObserver);

        assertTrue(composite.size() == 1);
        composite.dispose();
        assertTrue(composite.size() == 0);
        assertTrue(composite.isDisposed());
        assertTrue(disposable.isDisposed());
        assertTrue(testObserver.isDisposed());
    }
 
開發者ID:cp949,項目名稱:DisposableAttach,代碼行數:21,代碼來源:DisposableAttachCompletableTest.java

示例4: test

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
@Test public void test() {

        MaybeSubject<String> subject = MaybeSubject.create();
        Maybe<String> maybeSource = subject.hide();


        TestObserver testObserver = new TestObserver();
        CompositeDisposable composite = new CompositeDisposable();
        Disposable disposable = maybeSource
                .compose(DisposableAttach.<String>to(composite))
                .subscribeWith(testObserver);

        subject.onSuccess("Foo");
        testObserver.assertValue("Foo");
        assertTrue(composite.size() == 1);
        composite.dispose();
        assertTrue(composite.size() == 0);
        assertTrue(composite.isDisposed());
        assertTrue(disposable.isDisposed());
        assertTrue(testObserver.isDisposed());
    }
 
開發者ID:cp949,項目名稱:DisposableAttach,代碼行數:22,代碼來源:DisposableAttachMaybeTest.java

示例5: setupLyricsView

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
private void setupLyricsView() {
    mDisposable = new CompositeDisposable();
    //mLyricView.setLineSpace(15.0f);
    mLyricView.setTextSize(fontSize);
    //mLyricView.setTranslationY(DensityUtil.getScreenWidth(getActivity()) + DensityUtil.dip2px(getActivity(), 120));
    mLyricView.setOnPlayerClickListener(new LyricView.OnPlayerClickListener() {
        @Override
        public void onPlayerClicked(long progress, String content) {
            MusicPlayerRemote.seekTo((int) progress);
        }
    });
    rotate();
    //mLyricView.setTouchable(true);
    //mLyricView.setPlayable(true);

    //mLyricView.setDefaultColor(Color.WHITE);
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:18,代碼來源:LyricsActivity.java

示例6: onCreate

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    mCompositeDisposable = new CompositeDisposable();
    mApiInterface = ApiClient.getClient().create(LastFmInterface.class);
    mApp = (Common) getApplicationContext();

    mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationBuilder = new Notification.Builder(this);

    mNotificationBuilder.setContentTitle(getResources().getString(R.string.downloading_album_arts))
            .setContentText(getResources().getString(R.string.downloading_art_for))
            .setSmallIcon(R.mipmap.ic_music_file);

    startForeground(mNotificationId, mNotificationBuilder.build());

    mCompositeDisposable.add(Observable.fromCallable(() -> downloadAndUpdateArts())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeWith(downloadAndUpdateObserver));

}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:24,代碼來源:AlbumsArtDownloadService.java

示例7: onCreateView

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Bundle args = getArguments();
    mAccountInfoType = AccountInfoType.safeValueOf( args.getString( ARG_INFO_TYPE));

    mCompositeDisposable = new CompositeDisposable();

    View view = inflater.inflate(R.layout.dialog_input_account, container, false);

    ActivityComponent component = getActivityComponent();
    if (component != null) {
        component.inject(this);
    }

    return view;
}
 
開發者ID:mithrilcoin-io,項目名稱:EosCommander,代碼行數:18,代碼來源:InputAccountDialog.java

示例8: onCreate

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  mLoginObservable = Observable
      .timer(TIME_DELAY, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
      .map(aLong -> "User id is " + UUID.randomUUID().toString());
  mLoginFlowable = Flowable
      .timer(TIME_DELAY, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
      .map(aLong -> "User id is " + UUID.randomUUID().toString());

  mCompositeDisposable = new CompositeDisposable();

  findViewById(R.id.button_observable).setOnClickListener(this);
  findViewById(R.id.button_flowable).setOnClickListener(this);
}
 
開發者ID:tranngoclam,項目名稱:rx-progress-dialog,代碼行數:18,代碼來源:MainActivity.java

示例9: integrationLoginTestScenario2

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
/**
 * {@link ProjectRepository} login() api call
 * - get accessToken after successful login (failed)
 */
@Test
public void integrationLoginTestScenario2() throws Exception {
    Assert.assertEquals(projectRepository.getRepositoryState(),
            ProjectRepository.repositoryStates.INIT);
    Assert.assertNull(projectRepository.getData());

    CompositeDisposable disposable = new CompositeDisposable();

    disposable.add(projectRepository.login(dummyApiBadUrl, targetContext, dummyLogin, dummyPassword)
            .subscribeOn(Schedulers.io())
            .doOnError(throwable -> Assert.fail())
            .subscribe(appDataRxResponse -> {

                    Assert.assertNotNull(appDataRxResponse);
                    Assert.assertNull(appDataRxResponse.data);
                    Assert.assertEquals(RxStatus.LOGIN_ERROR, appDataRxResponse.status);

                    disposable.dispose();
            }));
}
 
開發者ID:jakdor,項目名稱:LabDayApp,代碼行數:25,代碼來源:ProjectRepositoryIntegrationTest.java

示例10: onCreate

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        sp = PreferenceManager.getDefaultSharedPreferences(this);
        checkPermission();
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        mCompositeDisposable = new CompositeDisposable();
        initRecyclerView();
        loadProviders();
//        mRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);
//        mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
//            @Override
//            public void onRefresh() {
//                mRefreshLayout.setRefreshing(true);
//                loadProviders();
//                runLayoutAnimation();
//                mRefreshLayout.setRefreshing(false);
//            }
//        });
    }
 
開發者ID:AlexeyZatsepin,項目名稱:CP-Tester,代碼行數:23,代碼來源:MainActivity.java

示例11: InitView

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
public void  InitView()
{
    //init Composite
    mCompositeDisposable = new CompositeDisposable();
  //init AppCompatButton
 btn_loading_observe=(AppCompatButton)findViewById(R.id.btn_loading_observe);
 btn_loadig_flowable=(AppCompatButton)findViewById(R.id.btn_loading_flowable);

    //btn observe
    btn_loading_observe.setOnClickListener(view->{

        mCompositeDisposable.add(RxProgress.from(MainActivity.this)
                .withMessage("Logging in...")
                .forObservable(user_Observable)
                .subscribe(id -> getMessage(id),
                        throwable -> Log.w(TAG, throwable.getMessage())));

    });

    //btn Flowable
    btn_loadig_flowable.setOnClickListener(view ->{

        mCompositeDisposable.add(RxProgress.from(MainActivity.this)
                .forFlowable(user_Flowable, BackpressureStrategy.DROP)
                .subscribe(id -> getMessage(id),
                        throwable -> Log.w(TAG, throwable.getMessage())));

    } );


}
 
開發者ID:datalink747,項目名稱:RxProgress,代碼行數:32,代碼來源:MainActivity.java

示例12: MonthAdapter

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
public MonthAdapter(Context context, DateTime currentMonth) {
    this.context = context;
    this.subscriptions = new CompositeDisposable();
    this.calendar = AUCalendar.getInstance();
    this.layoutResId = R.layout.calendar_cell;
    this.currentMonth = currentMonth.withDayOfMonth(1).withMillisOfDay(0);
    initFromCalendar();
    subscribe();
}
 
開發者ID:MOLO17,項目名稱:CustomizableCalendar,代碼行數:10,代碼來源:MonthAdapter.java

示例13: before

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
@CallSuper
@Before
public void before() {
    initMocks(this);

    testScheduler = new TestScheduler();
    compositeDisposableHelper = new CompositeDisposableHelper(new CompositeDisposable(),
            new TestSchedulerProvider(testScheduler));

    view = createView();
    presenter = createPresenter();
    presenter.attachView(view);
}
 
開發者ID:graviton57,項目名稱:TheNounProject,代碼行數:14,代碼來源:BasePresenterTest.java

示例14: onCreate

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
  Toothpick.inject(this, Toothpick.openScopes(RxNetwork.class, this));

  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  subscriptions = new CompositeDisposable();
}
 
開發者ID:greyfoxit,項目名稱:RxNetwork,代碼行數:10,代碼來源:MainActivity.java

示例15: addSubscription

import io.reactivex.disposables.CompositeDisposable; //導入依賴的package包/類
/**
 * 保存訂閱後的disposable
 * @param o
 * @param disposable
 */
public void addSubscription(Object o, Disposable disposable) {
    if (mSubscriptionMap == null) {
        mSubscriptionMap = new HashMap<>();
    }
    String key = o.getClass().getName();
    if (mSubscriptionMap.get(key) != null) {
        mSubscriptionMap.get(key).add(disposable);
    } else {
        //一次性容器,可以持有多個並提供 添加和移除。
        CompositeDisposable disposables = new CompositeDisposable();
        disposables.add(disposable);
        mSubscriptionMap.put(key, disposables);
    }
}
 
開發者ID:simplezhli,項目名稱:RxPay,代碼行數:20,代碼來源:BusUtil.java


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