use of com.mnnyang.gzuclassschedule.data.bean.Version in project GzuClassSchedule by mnnyang.
the class VersionUpdate method checkUpdate.
public void checkUpdate(final HttpCallback<Version> callback) {
OkHttpUtils.get().url(Url.URL_CHECK_UPDATE_APP).build().execute(new StringCallback() {
@Override
public void onError(Call call, Exception e, int id) {
e.printStackTrace();
callback.onFail(e.getMessage());
}
@Override
public void onResponse(String response, int id) {
try {
Gson gson = new Gson();
Version version = gson.fromJson(response, Version.class);
callback.onSuccess(version);
} catch (Exception e) {
e.printStackTrace();
callback.onFail("parse error");
}
}
});
}
use of com.mnnyang.gzuclassschedule.data.bean.Version in project GzuClassSchedule by mnnyang.
the class AboutPresenter method checkUpdate.
@Override
public void checkUpdate() {
mView.showNotice(app.mContext.getString(R.string.checking_for_updates));
final VersionUpdate versionUpdate = new VersionUpdate();
versionUpdate.checkUpdate(new HttpCallback<Version>() {
@Override
public void onSuccess(Version version) {
if (version == null) {
LogUtil.e(this, "version object is null");
return;
}
int localVersion = versionUpdate.getLocalVersion(app.mContext);
LogUtil.d(this, String.valueOf(version.getCode()));
if (version.getVersion() > localVersion) {
mView.showUpdateVersionInfo(version);
} else {
mView.showNotice(app.mContext.getString(R.string.already_the_latest_version));
}
}
@Override
public void onFail(String errMsg) {
LogUtil.e(this, errMsg);
ToastUtils.show(app.mContext.getString(R.string.access_err));
}
});
}
Aggregations