本文整理汇总了Java中rx.android.schedulers.AndroidSchedulers类的典型用法代码示例。如果您正苦于以下问题:Java AndroidSchedulers类的具体用法?Java AndroidSchedulers怎么用?Java AndroidSchedulers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AndroidSchedulers类属于rx.android.schedulers包,在下文中一共展示了AndroidSchedulers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showLoading
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@Override
public void showLoading() {
Timber.tag(TAG).w("showLoading");
Observable.just(1)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<Integer>() {
@Override
public void call(Integer integer) {
}
});
}
示例2: loadData
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@Override
public void loadData() {
RetrofitHelper.getBiliGoAPI()
.getNewBangumiSerialList()
.compose(this.bindToLifecycle())
.doOnSubscribe(this::showProgressBar)
.map(NewBangumiSerialInfo::getList)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listBeans -> {
newBangumiSerials.addAll(listBeans);
finishTask();
}, throwable -> {
hideProgressBar();
});
}
示例3: search
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
private void search() {
RxView.clicks(mSearchBtn)
.throttleFirst(2, TimeUnit.SECONDS)
.map(aVoid -> mSearchEdit.getText().toString().trim())
.filter(s -> !TextUtils.isEmpty(s))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(s -> {
KeyBoardUtil.closeKeybord(mSearchEdit,
TotalStationSearchActivity.this);
showSearchAnim();
clearData();
content = s;
getSearchData();
});
}
示例4: onTouchEvent
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
/**
* 重写onTouchEvent, 当用户的手在MyScrollView上面的时候,
* 直接将MyScrollView滑动的Y方向距离回调给onScroll方法中,当用户抬起手的时候,
* MyScrollView可能还在滑动,所以当用户抬起手我们隔5毫秒给handler发送消息,在handler处理
* MyScrollView滑动的距离
*/
@Override
public boolean onTouchEvent(MotionEvent ev) {
if(onScrollListener != null){
lastScrollX = this.getScrollX();
onScrollListener.onScroll(this.getScrollX());
}
switch(ev.getAction()){
case MotionEvent.ACTION_UP:
Observable.timer(500, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
.subscribe(new Action1<Long>() {
@Override
public void call(Long aLong) {
if(onScrollListener != null){
onScrollListener.onScrollStop();
}
}
});
break;
}
return super.onTouchEvent(ev);
}
示例5: loadData
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@Override
public void loadData() {
RetrofitHelper.getBiliAppAPI()
.getVideoDetails(av)
.compose(this.bindToLifecycle())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(videoDetails -> {
mVideoDetailsInfo = videoDetails.getData();
LogUtil.test(" VideoDetails finishTask" + mVideoDetailsInfo.getTitle());
finishTask();
}, throwable -> {
mFAB.setClickable(false);
mFAB.setBackgroundTintList(ColorStateList.valueOf(
getResources().getColor(R.color.gray_20)));
});
}
示例6: getSearchResultList
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@Override
public void getSearchResultList(String query) {
Subscription rxSubscription = bookApi.getSearchResult(query).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<SearchDetail>() {
@Override
public void onNext(SearchDetail bean) {
List<SearchDetail.SearchBooks> list = bean.books;
if (list != null && !list.isEmpty() && mView != null) {
mView.showSearchResultList(list);
}
}
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
LogUtils.e(e.toString());
}
});
addSubscrebe(rxSubscription);
}
示例7: handleResult
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
public static <T> Observable.Transformer<ApiResponse<T>, ApiResponse<T>> handleResult() {
return new Observable.Transformer<ApiResponse<T>, ApiResponse<T>>() {
@Override
public Observable<ApiResponse<T>> call(Observable<ApiResponse<T>> tObservable) {
return tObservable.flatMap(new Func1<ApiResponse<T>, Observable<ApiResponse<T>>>() {
@Override
public Observable<ApiResponse<T>> call(ApiResponse<T> response) {
if (response.state.code == 0) {
return createData(response);
} else {
return Observable.error(new ApiException(response.state));
}
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
}
};
}
示例8: loadData
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@Override
protected void loadData() {
Observable.just(readAssetsJson())
.compose(bindToLifecycle())
.map(s -> new Gson().fromJson(s, RegionTypesInfo.class))
.map(RegionTypesInfo::getData)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(dataBeans -> {
regionTypes.addAll(dataBeans);
finishTask();
}, throwable -> {
});
}
示例9: getCode
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
/**
* 获取验证码
*/
public void getCode(HttpResultListener<Boolean> listener, final String tel) {
mApi.getCode(tel)
.map(new HttpResultFuncNoList())
.map(new Func1<String, Boolean>() {
@Override
public Boolean call(String s) {
if (s.equals("ok")) {
return true;
} else {
return false;
}
}
})
.subscribeOn(Schedulers.io())//在工作线程请求网络
.observeOn(AndroidSchedulers.mainThread())//在主线程处理结果
.subscribe(new HttpResultSubscriber<>(listener));
}
示例10: localData
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
public Observable<String> localData(){
return Observable.create(new Observable.OnSubscribe<String>() {
@Override
public void call(Subscriber<? super String> subscriber) {
String data = getLocalData();
if(data!=null)
{
userId=data;
println("local:"+Thread.currentThread());
subscriber.onNext(userId+" "+"source:local");
subscriber.onCompleted();
}else {
subscriber.onCompleted();
}
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io());
}
示例11: getBookReviewDetail
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@Override
public void getBookReviewDetail(String id) {
Subscription rxSubscription = bookApi.getBookReviewDetail(id).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BookReview>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
LogUtils.e("getBookReviewDetail:" + e.toString());
}
@Override
public void onNext(BookReview data) {
mView.showBookReviewDetail(data);
}
});
addSubscrebe(rxSubscription);
}
示例12: update
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
@Override
public void update(long read, long count, boolean done) {
if(downInfo.getCountLength()>count){
read=downInfo.getCountLength()-count+read;
}else{
downInfo.setCountLength(count);
}
downInfo.setReadLength(read);
if (mSubscriberOnNextListener.get() != null) {
/*接受进度消息,造成UI阻塞,如果不需要显示进度可去掉实现逻辑,减少压力*/
rx.Observable.just(read).observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<Long>() {
@Override
public void call(Long aLong) {
/*如果暂停或者停止状态延迟,不需要继续发送回调,影响显示*/
if(downInfo.getState()==DownState.PAUSE||downInfo.getState()==DownState.STOP)return;
downInfo.setState(DownState.DOWN);
mSubscriberOnNextListener.get().updateProgress(aLong,downInfo.getCountLength());
}
});
}
}
示例13: requestDelPackageGoods
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
/**
* 删除包裹中商品申报信息
*
* @param goodsId
* @param inventoryId
*/
public void requestDelPackageGoods(int goodsId, int inventoryId) {
mModel.deleteGoods(goodsId, inventoryId)
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new ErrorHandleSubscriber<BaseJson<String>>(mErrorHandler) {
@Override
public void onNext(BaseJson<String> listBaseJson) {
if (listBaseJson.getStatus() == 0) {
mRootView.showMessage("操作成功");
requestPackageDetail(mPackagesId);
} else {
mRootView.showMessage(listBaseJson.getMsgs());
}
}
});
}
示例14: setColor
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
public void setColor(@ColorInt Integer destinationColor){
if(isInEditMode()){
mPaint.setColor(destinationColor);
this.invalidate();
return;
}
int currentColor = mPaint.getColor();
Integer[] intermediateColors = new Integer[10];
for(int i=1;i<=10;i++)
intermediateColors[i-1] = UiUtils.blendColors(destinationColor,currentColor,0.1f*i);
// Timer observable that will emit every half second.
Observable<Long> timerObservable = Observable.interval(0, 20, TimeUnit.MILLISECONDS);
Observable<Integer> colorsObservable = Observable.from(intermediateColors);
// First, zip the timer and circle views observables, so that we get one circle view every half a second.
Observable.zip(colorsObservable, timerObservable, (color, aLong) -> color)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(color -> {
mPaint.setColor(color);
this.invalidate();
});
}
示例15: loadSavedStories
import rx.android.schedulers.AndroidSchedulers; //导入依赖的package包/类
private void loadSavedStories(final SavedStoriesCardAdapter savedStoriesCardAdapter, HackerNewsApiClient service) {
savedStoriesCardAdapter.clear();
mSwipeRefreshLayout.setRefreshing(true);
Observable.from(mDatabaseService.getItems().keySet())
.map(Integer::valueOf)
.concatMapEager(id -> service.getItem(id))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<Item>() {
@Override
public void onCompleted() {
mSwipeRefreshLayout.setRefreshing(false);
}
@Override
public void onError(Throwable e) {
Log.e("NETWORKERROR", "Something went wrong" + e.getMessage(), e);
}
@Override
public void onNext(Item item) {
savedStoriesCardAdapter.addData(item);
}
});
}