use of com.benmu.framework.http.okhttp.callback.StringCallback in project WeexErosFramework by bmfe.
the class VersionChecker method readyUpdate.
private void readyUpdate() {
mUpdateUrl = BMWXEnvironment.mPlatformConfig.getUrl().getBundleUpdate();
if (TextUtils.isEmpty(mUpdateUrl))
return;
if (Constant.INTERCEPTOR_ACTIVE.equals(SharePreferenceUtil.getInterceptorActive(mContext))) {
mCurrentStatus = Constant.Version.UPDATING;
VersionManager versionManager = ManagerFactory.getManagerService(VersionManager.class);
versionManager.checkBundleUpdate(mContext, mUpdateUrl, true, new StringCallback() {
@Override
public void onError(Call call, Exception e, int id) {
Log.e(TAG, "获取更新失败");
mCurrentStatus = Constant.Version.SLEEP;
}
@Override
public void onResponse(String response, int id) {
VersionBean version = ManagerFactory.getManagerService(ParseManager.class).parseObject(response, VersionBean.class);
if (version == null) {
Log.e(TAG, "返回结果异常");
mCurrentStatus = Constant.Version.SLEEP;
return;
}
switch(version.resCode) {
case // 需要更新
0:
if (!TextUtils.isEmpty(version.data.path)) {
if (version.data.diff) {
// 更新插分包
Log.e(TAG, "检查插分包");
download(version, false);
} else {
// 下载全量包
Log.e(TAG, "检查全量包");
downloadCompleteZip();
}
} else {
// 下载全量包
Log.e(TAG, "检查全量包");
downloadCompleteZip();
}
break;
case 401:
Log.e(TAG, "JS文件查询失败!");
mCurrentStatus = Constant.Version.SLEEP;
break;
case 4000:
Log.e(TAG, "当前版本已是最新!");
mCurrentStatus = Constant.Version.SLEEP;
break;
default:
Log.e(TAG, "resCode:" + version.resCode);
mCurrentStatus = Constant.Version.SLEEP;
break;
}
}
});
}
}
use of com.benmu.framework.http.okhttp.callback.StringCallback in project WeexErosFramework by bmfe.
the class VersionChecker method downloadCompleteZip.
/**
* 下载全量包
*/
private void downloadCompleteZip() {
VersionManager versionManager = ManagerFactory.getManagerService(VersionManager.class);
versionManager.checkBundleUpdate(mContext, mUpdateUrl, false, new StringCallback() {
@Override
public void onError(Call call, Exception e, int id) {
L.e(TAG, "检查全量包失败!,更新失败");
}
@Override
public void onResponse(String response, int id) {
VersionBean version = ManagerFactory.getManagerService(ParseManager.class).parseObject(response, VersionBean.class);
if (version != null && !TextUtils.isEmpty(version.data.path)) {
L.e(TAG, "检查全量包成功!,开始下载");
download(version, true);
}
}
});
}
Aggregations