Пример #1
0
  @Override
  public void onDownloadProgressChange(final DownloadInfo downloadInfo) {
    //        Observable.create(new Observable.OnSubscribe<DownloadInfo>() {
    //            @Override
    //            public void call(Subscriber<? super DownloadInfo> subscriber) {
    //                subscriber.onNext(downloadInfo);
    //            }
    //        })
    //        Observable.just(downloadInfo)
    //                .observeOn(AndroidSchedulers.mainThread())
    //                .filter(new Func1<DownloadInfo, Boolean>() {
    //                    @Override
    //                    public Boolean call(DownloadInfo downloadInfo) {
    //                        return appInfo.getId() == downloadInfo.getId();
    //                    }
    //                })
    //                .subscribe(new Action1<DownloadInfo>() {
    //                    @Override
    //                    public void call(DownloadInfo downloadInfo) {
    //                        refreshUI(downloadInfo.getCurrentState(),downloadInfo.getProgress());
    //                    }
    //                });

    // 状态发生切换的时候,UI的具体的变化过程
    if (downloadInfo.getId() == appInfo.getId()) {
      UIUtil.runInMainThread(
          new Runnable() {
            @Override
            public void run() {
              // 根据不同的状态和进度条百分比更新UI操作
              refreshUI(downloadInfo.getCurrentState(), downloadInfo.getProgress());
            }
          });
    }
  }