当前位置: 首页>>代码示例>>Java>>正文


Java AndroidSchedulers类代码示例

本文整理汇总了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) {
                }
            });
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:12,代码来源:UserRecordActivity.java

示例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();
      });
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:20,代码来源:NewBangumiSerialActivity.java

示例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();
        });
  }
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:18,代码来源:TotalStationSearchActivity.java

示例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);
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:28,代码来源:MyHorizontalScrollView.java

示例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)));
            });
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:21,代码来源:VideoDetailsActivity.java

示例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);
}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:25,代码来源:SearchPresenter.java

示例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());
        }
    };
}
 
开发者ID:luffyke,项目名称:beegoapix-android-demo,代码行数:18,代码来源:RxHelper.java

示例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 -> {

      });
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:18,代码来源:HomeRegionFragment.java

示例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));
}
 
开发者ID:linsir6,项目名称:TripBuyer,代码行数:21,代码来源:A.java

示例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());
}
 
开发者ID:Aiushtha,项目名称:Go-RxJava,代码行数:21,代码来源:Fragment_CacheDemo.java

示例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);
}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:23,代码来源:BookReviewDetailPresenter.java

示例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());
                    }
                });
    }
}
 
开发者ID:wzgiceman,项目名称:RxRetrofit-tokean,代码行数:23,代码来源:ProgressDownSubscriber.java

示例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());
                    }
                }
            });

}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:26,代码来源:PackagePresenter.java

示例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();
            });


}
 
开发者ID:Bruno125,项目名称:Unofficial-Ups,代码行数:27,代码来源:RoundCircleView.java

示例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);
                }
            });
}
 
开发者ID:dandanes7,项目名称:lurkerhn,代码行数:26,代码来源:SavedStoriesActivity.java


注:本文中的rx.android.schedulers.AndroidSchedulers类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。