當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。