当前位置: 首页>>代码示例>>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;未经允许,请勿转载。