|  |  |  | 
|---|
|  |  |  | import com.doumee.keyCabinet.http.param.BaseResponse; | 
|---|
|  |  |  | import com.doumee.keyCabinet.http.param.DevAppVersionParam; | 
|---|
|  |  |  | import com.doumee.keyCabinet.http.param.RequestBaseObject; | 
|---|
|  |  |  | import com.doumee.keyCabinet.utils.ParamsUtil; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class UpdateUtil { | 
|---|
|  |  |  | public static String newVerName = ""; | 
|---|
|  |  |  | 
|---|
|  |  |  | // thread.interrupt(); | 
|---|
|  |  |  | // } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public boolean isShowing() { | 
|---|
|  |  |  | if(updateDialog!=null&&updateDialog.isShowing()){ | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(downloadDialog!=null&&downloadDialog.isShowing()){ | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static interface VersionCallBack{ | 
|---|
|  |  |  | void isNeedUpdate(boolean isUpdate); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void getUpgradeInfo() { | 
|---|
|  |  |  | if (true) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | RequestBaseObject<DevAppVersionParam> request = new RequestBaseObject<>(); | 
|---|
|  |  |  | DevAppVersionParam param = new DevAppVersionParam(); | 
|---|
|  |  |  | param.setVersionCode(BuildConfig.VERSION_CODE); | 
|---|
|  |  |  | param.setType("2"); | 
|---|
|  |  |  | request.setParam(param); | 
|---|
|  |  |  | activity.getVM().getRetrofitService(Apis.class).getVersion(MApplication.getConfigBean().getLanguage(),MApplication.getCookie(),MApplication.getConfigBean().getShopId(), | 
|---|
|  |  |  | MApplication.getConfigBean().getGymId(), ParamsUtil.encodeRequestBody(request)) | 
|---|
|  |  |  | activity.getVM().getRetrofitService(Apis.class).getVersion() | 
|---|
|  |  |  | .compose(RxUtils.schedulersTransformer()) | 
|---|
|  |  |  | .subscribe(new SimpleObserver<BaseResponse<AndroidVersionBean>>(activity.getVM().rxJavaGcManager) { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onNext(@NonNull BaseResponse<AndroidVersionBean> response) { | 
|---|
|  |  |  | if ("000000".equals(response.getErrorCode())) { | 
|---|
|  |  |  | if (response.getRecord()!=null) { | 
|---|
|  |  |  | versionCallBack.isNeedUpdate(true); | 
|---|
|  |  |  | AndroidVersionBean data = response.getRecord(); | 
|---|
|  |  |  | upgradeurl=data.getUpdateUrl(); | 
|---|
|  |  |  | updatelog=data.getUpdateContent(); | 
|---|
|  |  |  | newVerName = response.getRecord().getVersionName(); | 
|---|
|  |  |  | doNewVersionUpdate(true); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | if (200==response.getCode()) { | 
|---|
|  |  |  | if (response.getData()!=null) { | 
|---|
|  |  |  | AndroidVersionBean data = response.getData(); | 
|---|
|  |  |  | if(data!=null&&data.getVersionNum()!=null&&data.getVersionNum()>BuildConfig.VERSION_CODE){ | 
|---|
|  |  |  | versionCallBack.isNeedUpdate(true); | 
|---|
|  |  |  | upgradeurl=data.getFullFileUrl(); | 
|---|
|  |  |  | updatelog=data.getContent(); | 
|---|
|  |  |  | newVerName = data.getVersionInfo(); | 
|---|
|  |  |  | doNewVersionUpdate(data.getIsForce()==1); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | versionCallBack.isNeedUpdate(false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | versionCallBack.isNeedUpdate(false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private UpdateDialog updateDialog; | 
|---|
|  |  |  | // 更新新版本 | 
|---|
|  |  |  | public void doNewVersionUpdate(boolean type) { | 
|---|
|  |  |  | StringBuffer sb = new StringBuffer(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // sb.append(updatelog+"\n\n\r"); | 
|---|
|  |  |  | // new UpdateDialog(activity).show(); | 
|---|
|  |  |  | final UpdateDialog updateDialog = new UpdateDialog(activity); | 
|---|
|  |  |  | if(updateDialog!=null&&updateDialog.isShowing()){ | 
|---|
|  |  |  | updateDialog.dismiss(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | updateDialog = new UpdateDialog(activity); | 
|---|
|  |  |  | updateDialog.setText(sb.toString(),newVerName); | 
|---|
|  |  |  | updateDialog.setOnOtemListener(new UpdateDialog.UpdialogListener() { | 
|---|
|  |  |  |  | 
|---|