io.reactivex.android.schedulers.AndroidSchedulers Java Examples

The following examples show how to use io.reactivex.android.schedulers.AndroidSchedulers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From Android-OkGraphQl with Apache License 2.0 6 votes vote down vote up
private void query_variables_directives() {
    okGraphql

            .query(
                    "Hero($episode: Episode, $withFriends: Boolean!) {" +
                            "  hero(episode: $episode) {" +
                            "    name" +
                            "    friends @include(if: $withFriends) {" +
                            "      name" +
                            "    }" +
                            "  }"
            )


            .variable("episode", "JEDI")
            .variable("withFriends", false)

            .cast(StarWarsResponse.class)

            .toSingle()
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(
                    data -> text1.setText(data.toString()),
                    throwable -> text1.setText(throwable.getLocalizedMessage())
            );
}
 
Example #2
Source File: HomePresenter.java    From Mp3Cutter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void play(Activity activity) {
    // 播放
    if (TextUtils.isEmpty(mSelMp3Path)) {
        Toast.makeText(activity,
                activity.getString(R.string.dialog_cutter_warning_sel),
                Toast.LENGTH_SHORT).show();
        return;
    }
    mMediaPlayer.start();
    mView.setPlayBtnWithStatus(true);
    mView.setVisualizerViewEnaled(true);
    seekToForIsMin();
    //开启进度rx轮询事件
    mDisposable = mUpdateProgressObservable.observeOn(AndroidSchedulers.mainThread()).
            subscribe(mUpdateProgressConsumer);
}
 
Example #3
Source File: BookListFragment.java    From NovelReader with MIT License 6 votes vote down vote up
@Override
protected void initClick() {
    super.initClick();
    mBookListAdapter.setOnLoadMoreListener(
            () -> {
               mPresenter.loadBookList(mBookListType,mTag,mStart,mLimit);
            }
    );
    mBookListAdapter.setOnItemClickListener(
            (view,pos) -> {
                BookListBean bean = mBookListAdapter.getItem(pos);
                BookListDetailActivity.startActivity(getContext(),bean.get_id());
            }
    );

    Disposable disposable = RxBus.getInstance()
            .toObservable(BookSubSortEvent.class)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(
                    event -> {
                        mTag = event.bookSubSort;
                        showRefresh();
                    }
            );
    addDisposable(disposable);
}
 
Example #4
Source File: DetailPresenter.java    From lifecycle-component with Apache License 2.0 6 votes vote down vote up
public void requestDetailInfo(int id){
    mModel.getDetailInfo(id)
            .subscribeOn(Schedulers.io())
            .retryWhen(new RetryWithDelay(3, 2))//遇到错误时重试,第一个参数为重试几次,第二个参数为重试的间隔
            .doOnSubscribe(disposable -> {
                mRootView.showLoading();//显示下拉刷新的进度条
            }).subscribeOn(AndroidSchedulers.mainThread())
            .observeOn(AndroidSchedulers.mainThread())
            .doFinally(() -> {
                mRootView.hideLoading();//隐藏下拉刷新的进度条
            })
            .compose(RxLifecycleUtils.bindToLifecycle(mRootView))//使用 Rxlifecycle,使 Disposable 和 Activity 一起销毁
            .subscribe(new ErrorHandleSubscriber<ZhihuDetailBean>(mErrorHandler) {
                @Override
                public void onNext(ZhihuDetailBean zhihuDetailBean) {
                    mRootView.shonContent(zhihuDetailBean);
                }
            });
}
 
Example #5
Source File: DataLoadDemo11.java    From DataLoader with Apache License 2.0 6 votes vote down vote up
@SuppressLint("CheckResult")
@Override
public void load(final MutableLiveData<String> result) {
    Observable
            .fromCallable(new Callable<String>() {
                @Override
                public String call() throws Exception {
                    return "DataLoadDemo11 called";
                }
            })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<String>() {
                @Override
                public void accept(String s) throws Exception {
                    result.setValue(s);
                }
            });
}
 
Example #6
Source File: IconShowPresenter.java    From MBEStyle with GNU General Public License v3.0 6 votes vote down vote up
public Disposable getWhatsNewIcons() {
    return Observable.fromArray(mView.getResources().getStringArray(R.array.whatsnew))
            .map(new Function<String, IconBean>() {
                @Override
                public IconBean apply(@NonNull String s) throws Exception {
                    IconBean bean = new IconBean();
                    bean.id = mView.getResources().getIdentifier(s, "drawable", BuildConfig.APPLICATION_ID);
                    bean.name = s;

                    return bean;
                }
            }).toList().subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<List<IconBean>>() {
                @Override
                public void accept(List<IconBean> list) throws Exception {
                    mView.onLoadData(list);
                }
            });
}
 
Example #7
Source File: ListActivity.java    From sqlitemagic with Apache License 2.0 6 votes vote down vote up
private void wireData() {
  subscriptions = new CompositeDisposable();
  subscriptions.add(Select
      .from(ITEM)
      .where(ITEM.LIST.is(itemList))
      .orderBy(ITEM.COMPLETE.asc(), ITEM.DESCRIPTION.asc())
      .observe()
      .runQuery()
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(adapter::setData));
  subscriptions.add(Observable.combineLatest(Select
          .from(ITEM_LIST)
          .where(ITEM_LIST.ID.is(itemList.id()))
          .takeFirst()
          .observe()
          .runQuery(),
      Item.countItemsFor(itemList)
          .runQuery(),
      (itemList, count) -> String.format("%s (%s)", itemList.name(), count))
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(this::setTitle));
}
 
Example #8
Source File: AnnouncementPresenter.java    From incubator-taverna-mobile with Apache License 2.0 6 votes vote down vote up
public void loadAnnouncementDetails(String id) {
    checkViewAttached();
    compositeDisposable.add(mDataManager.getAnnouncementDetail(id)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(Schedulers.io())
            .subscribeWith(new DisposableObserver<DetailAnnouncement>() {

                @Override
                public void onNext(DetailAnnouncement detailAnnouncement) {
                    getMvpView().showAnnouncementDetail(detailAnnouncement);
                }

                @Override
                public void onError(Throwable e) {
                    Log.d(LOG_TAG, e.getMessage());
                    getMvpView().showWaitProgress(false);
                    getMvpView().showSnackBar(R.string.failed_to_fetch_announcement);
                }

                @Override
                public void onComplete() {
                    getMvpView().showWaitProgress(false);
                }
            }));
}
 
Example #9
Source File: LeaderboardBar.java    From 1Rramp-Android with MIT License 6 votes vote down vote up
/**
 * fetch leaderboard
 */
private void loadLeaders() {
  RetrofitServiceGenerator.getService().getLeaderboardList()
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribeWith(new SingleObserver<LeaderboardModel>() {
      @Override
      public void onSubscribe(Disposable d) {
        compositeDisposable.add(d);
      }

      @Override
      public void onSuccess(LeaderboardModel leaderboardModel) {
        handleLeaderBoardList(leaderboardModel);
      }

      @Override
      public void onError(Throwable e) {
      }
    });
}
 
Example #10
Source File: UserService.java    From V2EX with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 从设置页面获取用户信息并返回结果
 *
 * @param responseListener 请求结果回调接口
 */
public static void getInfo(ResponseListener<Account> responseListener){

    mUserApi.getSettingPage()
            .compose(RxUtil.io2computation())
            .flatMap((Function<String, ObservableSource<Account>>) s -> {
                ErrorEnum.ERR_PAGE_NEED_LOGIN.check(s);
                ErrorEnum.ERR_PAGE_NEED_LOGIN0.check(s);
                return getAccount(s);
            })
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new RxObserver<Account>() {
                @Override
                public void _onError(String msg) {
                    super._onError(msg);
                    responseListener.onFailed(msg);
                }
                @Override
                public void _onNext(Account account) {
                    responseListener.onComplete(account);
                }
            });
}
 
Example #11
Source File: ImportWalletViewModel.java    From alpha-wallet-android with MIT License 6 votes vote down vote up
public void onSeed(String walletAddress, KeyService.AuthenticationLevel level)
{
    if (walletAddress == null)
    {
        progress.postValue(false);
        System.out.println("ERROR");
        badSeed.postValue(true);
    }
    else
    {
        progress.postValue(true);
        //begin key storage process
        disposable = importWalletInteract.storeHDWallet(walletAddress, level, ensResolver)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(wallet::postValue, this::onError); //signal to UI wallet import complete
    }
}
 
Example #12
Source File: MyService.java    From BetterWay with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化提醒时间
 */
private void initDuraion() {
    io.reactivex.Observable.create(new ObservableOnSubscribe<Integer>() {
        @Override
        public void subscribe(ObservableEmitter<Integer> e) throws Exception {
            SharedPreferences sharedPreferences =
                    getSharedPreferences("com.android.betterway_preferences", Context.MODE_PRIVATE);
            weatherWarn = sharedPreferences.getBoolean("weather_warn", false);
            if (weatherWarn) {
                String d = sharedPreferences.getString("warning_time", "15");
                int dur = Integer.parseInt(d);
                e.onNext(dur);
            } else {
                e.onNext(0);
            }
        }
    }).observeOn(Schedulers.io())
            .subscribeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<Integer>() {
                @Override
                public void accept(Integer integer) throws Exception {
                    duration = integer;
                }
            });
}
 
Example #13
Source File: MainActivity.java    From RxAndroid-Examples with Apache License 2.0 6 votes vote down vote up
private void initSearchFeature(StudentAdapter adapter) {
    RxSearchObservable.fromSearchView(svKey)
            .debounce(500, TimeUnit.MILLISECONDS)
            .filter(text -> !text.isEmpty())
            .distinctUntilChanged()
            .switchMap(new Function<String, ObservableSource<ArrayList<String>>>() {
                @Override
                public ObservableSource<ArrayList<String>> apply(@NonNull String key) throws Exception {
                    return DataSource.getSearchData(key);
                }
            })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(names -> {
                adapter.removeAllNames();
                adapter.addStudentNames(names);
            });
}
 
Example #14
Source File: MessagesScreen.java    From adamant-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    presenter.onResume();
    navigatorHolder.setNavigator(navigator);

    MessagesPresenter localPresenter = presenter;
    messageInputDisposable = RxTextView
            .textChanges(newMessageText)
            .debounce(500, TimeUnit.MILLISECONDS)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(
                    localPresenter::onChangeMessageText,
                    error -> LoggerHelper.e(getClass().getSimpleName(), error.getMessage(), error)
            );

    endlessScrollListener = new EndlessUpScrollListener(layoutManager) {
        @Override
        public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
            presenter.loadMore();
        }
    };
    endlessScrollListener.setVisibleThreshold(12);
    messagesList.addOnScrollListener(endlessScrollListener);
}
 
Example #15
Source File: PackagesSelectorActivity.java    From DocUIProxy-Android with GNU General Public License v3.0 5 votes vote down vote up
private void loadAppInfoListAsync() {
    mProgressBar.setVisibility(View.VISIBLE);
    mDisposables.clear();
    mDisposables.add(Single.fromCallable(this::loadAppInfoList)
            .toFlowable()
            .flatMap(Flowable::fromIterable)
            .sorted()
            .toList()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe((res, err) -> {
                mProgressBar.setVisibility(View.GONE);
                if (err != null) {
                    err.printStackTrace();
                    return;
                }
                mAdapter.updateData(res);
                if (mLastSelectedPackages != null) {
                    final List<String> packages = new ArrayList<>(mLastSelectedPackages);
                    if (!packages.contains(WECHAT_PACKAGE_NAME)) {
                        packages.add(WECHAT_PACKAGE_NAME);
                    }
                    mAdapter.updateCheckedPackages(packages);
                }
            })
    );
}
 
Example #16
Source File: MainActivity.java    From RxShell with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    RxCmdShell rxCommandShell = RxCmdShell.builder().build();
    rxCommandShell.open()
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(session -> {
                execute.setVisibility(View.VISIBLE);
                MainActivity.this.session = session;
            });
}
 
Example #17
Source File: QQLoginInstance.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
@Override
public void fetchUserInfo(final BaseToken token) {
    Flowable.create(new FlowableOnSubscribe<QQUser>() {
        @Override
        public void subscribe(@NonNull FlowableEmitter<QQUser> qqUserEmitter) throws Exception {
            OkHttpClient client = new OkHttpClient();
            Request request = new Request.Builder().url(buildUserInfoUrl(token, URL)).build();

            try {
                Response response = client.newCall(request).execute();
                JSONObject jsonObject = new JSONObject(response.body().string());
                QQUser user = QQUser.parse(token.getOpenid(), jsonObject);
                qqUserEmitter.onNext(user);
            } catch (IOException | JSONException e) {
                ShareLogger.e(INFO.FETCH_USER_INOF_ERROR);
                qqUserEmitter.onError(e);
            }
        }
    }, BackpressureStrategy.DROP)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<QQUser>() {
                @Override
                public void accept(@NonNull QQUser qqUser) throws Exception {
                    mLoginListener.loginSuccess(
                            new LoginResult(LoginPlatform.QQ, token, qqUser));
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) {
                    mLoginListener.loginFailure(new Exception(throwable));
                }
            });
}
 
Example #18
Source File: BookSourcePresenterImpl.java    From HaoReader with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void refreshGroup() {
    Observable.create((ObservableOnSubscribe<List<String>>) emitter -> {
        emitter.onNext(BookSourceManager.getGroupList());
        emitter.onComplete();
    }).subscribeOn(RxExecutors.getDefault())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new SimpleObserver<List<String>>() {
                @Override
                public void onNext(List<String> list) {
                    mView.upGroupMenu(list);
                }
            });
}
 
Example #19
Source File: LoginPresenter.java    From flowless with Apache License 2.0 5 votes vote down vote up
public void login() {
    showLoading();
    loginInteractor.login(username, password).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
        hideLoading();
        if(result) {
            view.handleLoginSuccess(); // can View be null here?
        } else {
            view.handleLoginError();
        }
    });
}
 
Example #20
Source File: RuleListPresenter.java    From XposedSmsCode with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void loadAllRules() {
    Disposable disposable = DBManager.get(mContext)
            .queryAllSmsCodeRulesRx()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(smsCodeRules -> mView.displayRules(smsCodeRules));
    mCompositeDisposable.add(disposable);
}
 
Example #21
Source File: ReadBookPresenterImpl.java    From HaoReader with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void cleanCache() {
    if (bookShelf == null) {
        return;
    }

    mView.showLoading("正在清除缓存");
    Single.create((SingleOnSubscribe<Boolean>) emitter -> {
        BookshelfHelp.cleanBookCache(bookShelf);
        emitter.onSuccess(true);
    }).subscribeOn(RxExecutors.getDefault())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new SingleObserver<Boolean>() {
                @Override
                public void onSubscribe(Disposable d) {

                }

                @Override
                public void onSuccess(Boolean aBoolean) {
                    RxBus.get().post(RxBusTag.CLEAN_BOOK_CACHE, true);
                    mView.toast("缓存清除成功");
                    mView.dismissHUD();
                }

                @Override
                public void onError(Throwable e) {
                    mView.toast("缓存清除失败");
                    mView.dismissHUD();
                }
            });
}
 
Example #22
Source File: JwcApiFactory.java    From SmallGdufe-Android with GNU General Public License v3.0 5 votes vote down vote up
public void getCet(String zkzh,String name, Observer<Cet> sub ) {
    ApiUtils.getApi(AppConfig.jwPwd).create(JwcApi.class).getCet(zkzh,name)
    .map(new HttpResultFunc<Cet>())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribeOn(Schedulers.io())
    .subscribe(sub);
}
 
Example #23
Source File: MainActivity.java    From RxPalette with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);

    RxPaletteSampleApplication.get()
            .getImgurApi()
            .getAlbum("jx90V")
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new DisposableSingleObserver<ImgurResponse<Album>>() {
                @Override
                public void onSuccess(ImgurResponse<Album> albumImgurResponse) {
                    Adapter adapter = new Adapter(albumImgurResponse.data.images);
                    progressBar.setVisibility(View.GONE);
                    recyclerView.setVisibility(View.VISIBLE);
                    recyclerView.setAdapter(adapter);
                }

                @Override
                public void onError(Throwable e) {
                    Toast.makeText(MainActivity.this, "Error: " + e, Toast.LENGTH_LONG).show();
                    Log.e("ERROR", "OnError", e);
                }
            });
}
 
Example #24
Source File: TreatmentsFragment.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public synchronized void onResume() {
    super.onResume();
    disposable.add(RxBus.INSTANCE
            .toObservable(EventExtendedBolusChange.class)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(event -> updateGui(), FabricPrivacy::logException)
    );
    updateGui();
}
 
Example #25
Source File: ExperimentDetailsFragment.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  AppSingleton.getInstance(getContext())
      .whenExportBusyChanges()
      .takeUntil(destroyed.happens())
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(
          busy -> {
            // This fragment may be gone by the time this code executes. Check getContext
            // and give up if it is null.
            if (getContext() == null) {
              return;
            }
            setProgressBarVisible(busy);
          });
  appAccount = WhistlePunkApplication.getAccount(getContext(), getArguments(), ARG_ACCOUNT_KEY);
  localSyncManager =
      AppSingleton.getInstance(getContext()).getLocalSyncManager(appAccount);
  experimentLibraryManager =
      AppSingleton.getInstance(getContext()).getExperimentLibraryManager(appAccount);
  experimentId = getArguments().getString(ARG_EXPERIMENT_ID);
  claimExperimentsMode = getArguments().getBoolean(ARG_CLAIM_EXPERIMENTS_MODE);
  setHasOptionsMenu(true);
  actionController =
      new ActionController(appAccount, getExperimentId(), new SnackbarManager(), getContext());
  if (claimExperimentsMode) {
    WhistlePunkApplication.getUsageTracker(getActivity())
        .trackEvent(
            TrackerConstants.CATEGORY_CLAIMING_DATA,
            TrackerConstants.ACTION_VIEW_EXPERIMENT,
            null,
            0);
  }
}
 
Example #26
Source File: SearchActivity.java    From RxJava2-Android-Samples with Apache License 2.0 5 votes vote down vote up
private void setUpSearchObservable() {
    RxSearchObservable.fromView(searchView)
            .debounce(300, TimeUnit.MILLISECONDS)
            .filter(new Predicate<String>() {
                @Override
                public boolean test(String text) {
                    if (text.isEmpty()) {
                        textViewResult.setText("");
                        return false;
                    } else {
                        return true;
                    }
                }
            })
            .distinctUntilChanged()
            .switchMap(new Function<String, ObservableSource<String>>() {
                @Override
                public ObservableSource<String> apply(String query) {
                    return dataFromNetwork(query)
                            .doOnError(throwable -> {
                                // handle error
                            })
                            // continue emission in case of error also
                            .onErrorReturn(throwable -> "");
                }
            })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<String>() {
                @Override
                public void accept(String result) {
                    textViewResult.setText(result);
                }
            });
}
 
Example #27
Source File: PseudoCacheFragment.java    From RxJava-Android-Samples with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.btn_pseudoCache_merge)
public void onMergeBtnClicked() {
  infoText.setText(R.string.msg_pseudoCache_demoInfo_merge);
  wireupDemo();

  Observable.merge(getCachedDiskData(), getFreshNetworkData())
      .subscribeOn(Schedulers.io()) // we want to add a list item at time of subscription
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(
          new DisposableObserver<Contributor>() {
            @Override
            public void onComplete() {
              Timber.d("done loading all data");
            }

            @Override
            public void onError(Throwable e) {
              Timber.e(e, "arr something went wrong");
            }

            @Override
            public void onNext(Contributor contributor) {
              contributionMap.put(contributor.login, contributor.contributions);
              adapterDetail.clear();
              adapterDetail.addAll(mapAsList(contributionMap));
            }
          });
}
 
Example #28
Source File: AuthPresenter.java    From Capstone-Project with MIT License 5 votes vote down vote up
@Override
public void retrieveClientAuthToken(final Context context) {
    mCompositeDisposable.add(ProductHuntRestApi.getApi()
            .oAuthClient(OAuth.getClientAuthRequestBody())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeWith(new DisposableObserver<OAuthData>() {
                @Override
                public void onComplete() {
                    // Done
                }

                @Override
                public void onError(Throwable e) {
                    mView.unableToFetchAuthToken(e.getMessage());
                }

                @Override
                public void onNext(OAuthData oAuthData) {
                    Bundle args = new Bundle();
                    args.putString(AccountManager.KEY_ACCOUNT_NAME, Constants.Authenticator.PRODUCT_HUNT);
                    args.putString(AccountManager.KEY_ACCOUNT_TYPE, Constants.Authenticator.PREDATOR_ACCOUNT_TYPE);
                    args.putString(AccountManager.KEY_AUTHTOKEN, oAuthData.getAccessToken());

                    PredatorAccount.addAccount(context,
                            Constants.Authenticator.PRODUCT_HUNT,
                            Constants.Authenticator.PREDATOR_ACCOUNT_TYPE,
                            oAuthData.getAccessToken(),
                            Constants.Authenticator.AUTH_TYPE_CLIENT);

                    // valid token is retrieved
                    PredatorSharedPreferences.setValidToken(context, true);
                    PredatorSharedPreferences.setAuthTokenType(context, Constants.Authenticator.AUTH_TYPE_CLIENT);

                    mView.onAuthTokenRetrieved(args, MSG_TOKEN_SUCCESS);
                }
            }));
}
 
Example #29
Source File: FetchTokensInteract.java    From alpha-wallet-android with MIT License 5 votes vote down vote up
public Observable<OrderContractAddressPair> updateBalancePair(Token token, MagicLinkData order)
{
    return tokenRepository.fetchActiveTokenBalance(order.ownerAddress, token)
            .map(updateToken -> mapToPair(updateToken, order))
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread());
}
 
Example #30
Source File: SingleLife.java    From rxjava-RxLife with Apache License 2.0 5 votes vote down vote up
private void subscribeActual(SingleObserver<? super T> observer) {
    Single<T> upStream = this.upStream;
    if (onMain) {
        upStream = upStream.observeOn(AndroidSchedulers.mainThread());
    }
    upStream.onTerminateDetach().subscribe(new LifeSingleObserver<>(observer, scope));
}