Search in sources :

Example 1 with VersionBean

use of com.codeest.geeknews.model.bean.VersionBean in project GeekNews by codeestX.

the class MainPresenter method checkVersion.

@Override
public void checkVersion(final String currentVersion) {
    Subscription rxSubscription = mRetrofitHelper.fetchVersionInfo().compose(RxUtil.<MyHttpResponse<VersionBean>>rxSchedulerHelper()).compose(RxUtil.<VersionBean>handleMyResult()).filter(new Func1<VersionBean, Boolean>() {

        @Override
        public Boolean call(VersionBean versionBean) {
            return Integer.valueOf(currentVersion.replace(".", "")) < Integer.valueOf(versionBean.getCode().replace(".", ""));
        }
    }).map(new Func1<VersionBean, String>() {

        @Override
        public String call(VersionBean bean) {
            StringBuilder content = new StringBuilder("版本号: v");
            content.append(bean.getCode());
            content.append("\r\n");
            content.append("版本大小: ");
            content.append(bean.getSize());
            content.append("\r\n");
            content.append("更新内容:\r\n");
            content.append(bean.getDes().replace("\\r\\n", "\r\n"));
            return content.toString();
        }
    }).subscribe(new CommonSubscriber<String>(mView) {

        @Override
        public void onNext(String s) {
            mView.showUpdateDialog(s);
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : Subscription(rx.Subscription) VersionBean(com.codeest.geeknews.model.bean.VersionBean) Func1(rx.functions.Func1)

Example 2 with VersionBean

use of com.codeest.geeknews.model.bean.VersionBean in project GeekNews by codeestX.

the class SettingPresenter method checkVersion.

@Override
public void checkVersion(final String currentVersion) {
    Subscription rxSubscription = mRetrofitHelper.fetchVersionInfo().compose(RxUtil.<MyHttpResponse<VersionBean>>rxSchedulerHelper()).compose(RxUtil.<VersionBean>handleMyResult()).subscribe(new CommonSubscriber<VersionBean>(mView, "获取版本信息失败 T T") {

        @Override
        public void onNext(VersionBean versionBean) {
            if (Integer.valueOf(currentVersion.replace(".", "")) < Integer.valueOf(versionBean.getCode().replace(".", ""))) {
                mView.showUpdateDialog(versionBean);
            } else {
                mView.showError("已经是最新版本~");
            }
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : Subscription(rx.Subscription) VersionBean(com.codeest.geeknews.model.bean.VersionBean)

Aggregations

VersionBean (com.codeest.geeknews.model.bean.VersionBean)2 Subscription (rx.Subscription)2 Func1 (rx.functions.Func1)1