3
This commit is contained in:
@@ -15,8 +15,15 @@ import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import com.lidroid.xutils.exception.HttpException;
|
||||
import com.lidroid.xutils.http.RequestParams;
|
||||
import com.lidroid.xutils.http.ResponseInfo;
|
||||
import com.lidroid.xutils.http.callback.RequestCallBack;
|
||||
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
|
||||
import cn.shangyu.gdxzExpert.activity.LoginNewActivity;
|
||||
import cn.shangyu.gdxzExpert.application.BaseApplication;
|
||||
import cn.shangyu.gdxzExpert.application.BaseApplication;
|
||||
import cn.shangyu.gdxzExpert.bean.ChangeMyInfoBean;
|
||||
import cn.shangyu.gdxzExpert.http.HttpHelper;
|
||||
/**
|
||||
*
|
||||
* UIUtils.java
|
||||
@@ -192,6 +199,110 @@ public class UIUtils {
|
||||
return isLogined() && SharePrefUtil.getInt(getContext(), "state", 0) == 6;
|
||||
}
|
||||
|
||||
public interface OnDoctorStateRefreshListener {
|
||||
void onStateRefreshed(int state, String checkInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 getExpertByUuid 返回的专家详情及审核状态同步到本地 SharePrefUtil
|
||||
*/
|
||||
public static void syncExpertInfoToSp(Context context, ChangeMyInfoBean bean) {
|
||||
if (bean == null || !"1".equals(bean.code) || bean.expert == null) {
|
||||
return;
|
||||
}
|
||||
Context ctx = context != null ? context : getContext();
|
||||
ChangeMyInfoBean.InfoData data = bean.expert;
|
||||
if (data.state > 0) {
|
||||
SharePrefUtil.saveInt(ctx, "state", data.state);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.checkInfo)) {
|
||||
SharePrefUtil.saveString(ctx, "checkInfo", data.checkInfo);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.realName)) {
|
||||
SharePrefUtil.saveString(ctx, Constant.realName, data.realName);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.photo)) {
|
||||
SharePrefUtil.saveString(ctx, Constant.photo, data.photo);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.hospitalUuid)) {
|
||||
SharePrefUtil.saveString(ctx, "hospitalUuid", data.hospitalUuid);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.hospitalName)) {
|
||||
SharePrefUtil.saveString(ctx, "hospitalName", data.hospitalName);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.officeUuid)) {
|
||||
SharePrefUtil.saveString(ctx, "officeUuid", data.officeUuid);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.officeName)) {
|
||||
SharePrefUtil.saveString(ctx, "officeName", data.officeName);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.officePhone)) {
|
||||
SharePrefUtil.saveString(ctx, "officePhone", data.officePhone);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.positionUuid)) {
|
||||
SharePrefUtil.saveString(ctx, "positionUuid", data.positionUuid);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.positionName)) {
|
||||
SharePrefUtil.saveString(ctx, "positionName", data.positionName);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.certificate)) {
|
||||
SharePrefUtil.saveString(ctx, "certificate", data.certificate);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.certificateImg)) {
|
||||
SharePrefUtil.saveString(ctx, "certificateImg", data.certificateImg);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.qrcode)) {
|
||||
SharePrefUtil.saveString(ctx, "qrcode", data.qrcode);
|
||||
}
|
||||
if (!StringUtil.isEmpty(data.isStar)) {
|
||||
SharePrefUtil.saveString(ctx, "isStar", data.isStar);
|
||||
}
|
||||
SharePrefUtil.saveInt(ctx, "sex", data.sex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 当账号已登录但尚未认证通过(state != 6)时,静默向服务端拉取最新审核状态(state)并同步到本地
|
||||
*/
|
||||
public static void refreshDoctorStateIfNeeded(final Context context, final OnDoctorStateRefreshListener listener) {
|
||||
if (!isLogined() || isDoctorVerified()) {
|
||||
return;
|
||||
}
|
||||
final Context ctx = context != null ? context : getContext();
|
||||
String uuid = SharePrefUtil.getString(ctx, Constant.uuid, "");
|
||||
if (StringUtil.isEmpty(uuid)) {
|
||||
return;
|
||||
}
|
||||
RequestParams params = new RequestParams();
|
||||
params.addBodyParameter("uuid", uuid);
|
||||
HttpHelper.loadData(HttpMethod.POST, Url.getExpertByUuid, params, new RequestCallBack<String>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseInfo<String> info) {
|
||||
if (info == null || StringUtil.isEmpty(info.result)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ChangeMyInfoBean bean = GsonTools.fromGsonToBean(info.result, ChangeMyInfoBean.class);
|
||||
if (bean != null && "1".equals(bean.code) && bean.expert != null) {
|
||||
SharePrefUtil.saveString(ctx, Url.getExpertByUuid, info.result);
|
||||
syncExpertInfoToSp(ctx, bean);
|
||||
if (listener != null) {
|
||||
String checkInfo = !StringUtil.isEmpty(bean.expert.checkInfo)
|
||||
? bean.expert.checkInfo
|
||||
: SharePrefUtil.getString(ctx, "checkInfo", "");
|
||||
listener.onStateRefreshed(bean.expert.state, checkInfo);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException arg0, String arg1) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验是否已通过医师资质审核(state == 6)
|
||||
* - 未登录账号:跳 LoginNewActivity
|
||||
|
||||
Reference in New Issue
Block a user