Files
expert-app/app/src/main/java/cn/shangyu/gdxzExpert/activity/MyDetailInfoActivity.java
T
2026-11-03 12:16:38 +08:00

1299 lines
44 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package cn.shangyu.gdxzExpert.activity;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gyf.immersionbar.ImmersionBar;
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 com.netease.nimlib.sdk.RequestCallbackWrapper;
import com.netease.nimlib.sdk.uinfo.constant.UserInfoFieldEnum;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.download.ImageDownloader.Scheme;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.shangyu.gdxzExpert.R;
import cn.shangyu.gdxzExpert.base.BaseActivity;
import cn.shangyu.gdxzExpert.bean.ChangeMyInfoBean;
import cn.shangyu.gdxzExpert.bean.ChangeMyInfoBean.InfoData;
import cn.shangyu.gdxzExpert.bean.ChangeMyInfoBean.SpecialData;
import cn.shangyu.gdxzExpert.bean.GetListBean;
import cn.shangyu.gdxzExpert.bean.GetListBean.ListData;
import cn.shangyu.gdxzExpert.bean.SettingInfoBean;
import cn.shangyu.gdxzExpert.http.HttpHelper;
import cn.shangyu.gdxzExpert.netease.contact.UserConstant;
import cn.shangyu.gdxzExpert.netease.contact.UserUpdateHelper;
import cn.shangyu.gdxzExpert.utils.CommonUtil;
import cn.shangyu.gdxzExpert.utils.Constant;
import cn.shangyu.gdxzExpert.utils.DateUtil;
import cn.shangyu.gdxzExpert.utils.GsonTools;
import cn.shangyu.gdxzExpert.utils.ImageOptions;
import cn.shangyu.gdxzExpert.utils.LogUtil;
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
import cn.shangyu.gdxzExpert.utils.StringUtil;
import cn.shangyu.gdxzExpert.utils.ToastUtil;
import cn.shangyu.gdxzExpert.utils.Url;
import cn.shangyu.gdxzExpert.utils.ValidateUtils;
import cn.shangyu.gdxzExpert.widge.pickerview.EditPopupWindow;
import cn.shangyu.gdxzExpert.widge.pickerview.OptionsPopupWindow;
import cn.shangyu.gdxzExpert.widge.pickerview.TimePopupWindow;
import cn.shangyu.gdxzExpert.widge.pickerview.TimePopupWindow.OnTimeSelectListener;
import cn.shangyu.gdxzExpert.widge.pickerview.TimePopupWindow.Type;
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
/**
* ModifyMyDataActivity.java
*
* @author
* @date 2015-10-26 Copyright (C) 2015 河南商宇科技有限公司 我的-个人资料 功能说明:我的资料(可以点击修改 保存)
*/
public class MyDetailInfoActivity extends BaseActivity implements
OnItemClickListener {
private View view;
private ImageView iv_select1;// 头像
private ImageView iv_select2;// 证件
private static final int TO_SELECT_PHOTO1 = 601;
private static final int TO_SELECT_PHOTO = 600;
private static final int TO_SELECT_EMAIL = 0;
private static final int TO_SELECT_PHONE = 1;
private static final int TO_SELECT_OFFICEPHONE = 2;
private static final int TO_SELECT_PROFILE = 3;
private TextView tv_select_birthday;
private int sex = 0;// 0男1女
private Button bt_submit_myinfo;
private String uuid;
private String name = "";
private String birthdayDate = "";
// public static String hospitalListUrl = Url.gethospitalList;//医院列表
public static String officeListUrl = Url.getofficeList;// 科室列表
public static String positionListUrl = Url.getpositionList;// 职称列表
public static String diseaseUrl = Url.getdisease;// 专长列表
public static String modifyUrl = Url.getmodify;// 修改个人资料
public static String getExpertByUuid = Url.getExpertByUuid;// 查看个人资料
private TextView tv_zhengshubianhao;
private TextView tv_name;
private TextView tv_phone;
private TextView tv_sex;
private TextView tv_email;
private TextView tv_hospital;
private TextView tv_offices;
private TextView tv_offices_phone;
private TextView tv_professional;
private TextView tv_disease;
private TextView tv_profile;
private String intro = "";
private String photo, photoBase64;
private String photo2, photoBase642;
private TimePopupWindow pwTime;
private RelativeLayout rl_select_birthday;
private String officePhonePost;
private String profilePost;
private String emailPost;
private String birthdayPost;
private String mobile;
private String[] specialPosintions;
private OptionsPopupWindow pwSexOptions;
private ArrayList<String> officeListItems = new ArrayList<String>();
private ArrayList<String> professionalListItems = new ArrayList<String>();
private ArrayList<String> officeListUuidItems = new ArrayList<String>();
private ArrayList<String> professionalUuidListItems = new ArrayList<String>();
private List<ListData> diseaseList = new ArrayList<ListData>();
private ArrayList<String> optionsSexItems = new ArrayList<String>();
private ArrayList<String> hospitalListUuidItems = new ArrayList<String>();
private ArrayList<String> hospitalListItems = new ArrayList<String>();
private EditPopupWindow editPw;
private OptionsPopupWindow pwOptions;
private PopupWindow popGridView;
private GridView gv_disease;
private MyAdapter adapter;
private String officeUuid = "";
private String positionUuid = "";
private int page = 1;
private String disease = "";
private String officeName = "";
private String positionName = "";
private static final String NEXT_PAGE = "-99";
private int checkNum = 0; // 记录选中的条目数量
private String positionPost;
private String officePost;
private String diseasePost;
private String email = "";
private String phone = "";
private String officePhone = "";
private String etofficeName = "";
private String diseaseName = "";
@Override
public void setTitle() {
top_title.setText("个人资料");
top_back_layout.setOnClickListener(this);
if(CommonUtil.BigModule())
{
top_title.setTextSize(23);
}
}
@Override
public View onCreateSuccessedView() {
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
if(CommonUtil.BigModule())
{
view = View.inflate(ct, R.layout.activity_my_info_activity_big, null);
}
else
{
view = View.inflate(ct, R.layout.activity_my_info_activity, null);
}
initView();
initData();
return view;
}
@Override
protected void onResume() {
super.onResume();
needreportPage("个人资料");
}
private void initView() {
// 头像
RelativeLayout rl_photo = (RelativeLayout) view.findViewById(R.id.rl_photo);
iv_select1 = view.findViewById(R.id.iv_select1);
// 证件编号
RelativeLayout rl_zhengshubianhao = (RelativeLayout) view
.findViewById(R.id.rl_zhengshubianhao);
tv_zhengshubianhao = (TextView) view
.findViewById(R.id.tv_zhengshubianhao);
// 证件图片
RelativeLayout rl_zhengshu = (RelativeLayout) view
.findViewById(R.id.rl_zhengshu);
iv_select2 = (ImageView) view.findViewById(R.id.iv_zhengshu);
// 姓名
RelativeLayout rl_name = (RelativeLayout) view
.findViewById(R.id.rl_name);
tv_name = (TextView) view.findViewById(R.id.tv_name);
// 性别
RelativeLayout rl_sex = (RelativeLayout) view.findViewById(R.id.rl_sex);
tv_sex = (TextView) view.findViewById(R.id.tv_sex);
// 手机号
RelativeLayout rl_phone = (RelativeLayout) view
.findViewById(R.id.rl_phone);
tv_phone = (TextView) view.findViewById(R.id.tv_phone);
// 邮箱
RelativeLayout rl_email = (RelativeLayout) view
.findViewById(R.id.rl_email);
tv_email = (TextView) view.findViewById(R.id.tv_email);
// 所属医院
RelativeLayout rl_hospital = (RelativeLayout) view
.findViewById(R.id.rl_hospital);
tv_hospital = (TextView) view.findViewById(R.id.tv_hospital);
// 所属科室
RelativeLayout rl_offices = (RelativeLayout) view
.findViewById(R.id.rl_offices);
tv_offices = (TextView) view.findViewById(R.id.tv_offices);
// 所属科室电话
RelativeLayout rl_offices_phone = (RelativeLayout) view
.findViewById(R.id.rl_offices_phone);
tv_offices_phone = (TextView) view.findViewById(R.id.tv_offices_phone);
// 职称
RelativeLayout rl_professional = (RelativeLayout) view
.findViewById(R.id.rl_professional);
tv_professional = (TextView) view.findViewById(R.id.tv_professional);
// 专长
RelativeLayout rl_disease = (RelativeLayout) view
.findViewById(R.id.rl_disease);
tv_disease = (TextView) view.findViewById(R.id.tv_disease);
// 个人简介
RelativeLayout rl_profile = (RelativeLayout) view
.findViewById(R.id.rl_profile);
tv_profile = (TextView) view.findViewById(R.id.tv_profile);
rl_select_birthday = (RelativeLayout) view
.findViewById(R.id.rl_select_birthday);
tv_select_birthday = (TextView) view
.findViewById(R.id.tv_select_birthday);
bt_submit_myinfo = (Button) view.findViewById(R.id.bt_submit_myinfo);
bt_submit_myinfo.setOnClickListener(this);
rl_select_birthday.setOnClickListener(this);
rl_phone.setOnClickListener(this);
rl_offices_phone.setOnClickListener(this);
rl_email.setOnClickListener(this);
rl_profile.setOnClickListener(this);
rl_photo.setOnClickListener(this);
rl_offices.setOnClickListener(this);// 所属科室
rl_professional.setOnClickListener(this);// 职称
rl_disease.setOnClickListener(this);// 专长
rl_zhengshu.setOnClickListener(this);
// rl_zhengshubianhao.setOnClickListener(this);
// rl_name.setOnClickListener(this);
// rl_sex.setOnClickListener(this);
// rl_hospital.setOnClickListener(this);
bottomSelectDate();
}
/**
*
* @author Administrator
* @date 2015-10-27 下午3:09:01
*
* 功能说明:初始化我的资料
*
* method
*/
private void initData() {
uuid = SharePrefUtil.getString(ct, "uuid", "");
String name = SharePrefUtil.getString(ct, "realName", "");
String photo = SharePrefUtil.getString(ct, Constant.photo, "");
mobile = SharePrefUtil.getString(ct, "mobile", "");
Log.d("parameterso","mobile0 ="+mobile);
String birthDate = SharePrefUtil.getString(ct, "birthDate", "");
String email = SharePrefUtil.getString(ct, "email", "");
sex = SharePrefUtil.getInt(ct, "sex", 0);
String hospitalName = SharePrefUtil.getString(ct, "hospitalName", "");
String officeName = SharePrefUtil.getString(ct, "officeName", "");
String officePhone = SharePrefUtil.getString(ct, "officePhone", "");
String positionName = SharePrefUtil.getString(ct, "positionName", "");
String certificate = SharePrefUtil.getString(ct, "certificate", "");
String certificateImg = SharePrefUtil.getString(ct, "certificateImg",
"");
String intro = SharePrefUtil.getString(ct, "intro", "");
// String disease = SharePrefUtil.getString(ct, "disease", "");
String diseaseName = SharePrefUtil.getString(ct, "diseaseName", "");
// 回显头像
if (!TextUtils.isEmpty(photo) && !"null".equals(photo)) {
ImageLoader.getInstance().displayImage(Url.urlHtml + photo,iv_select1,ImageOptions.getImageOptions(R.drawable.icon_touxiang_persion_gray_big));
}
// 回显姓名
if (!StringUtil.isEmpty(name)) {
tv_name.setText(name);
}
// 手机号
if (!StringUtil.isEmpty(mobile)) {
tv_phone.setText(mobile);
Log.d("parameterso","mobile1 ="+mobile);
}
// 性别
if (0 == sex) {
tv_sex.setText(getResources().getString(R.string.man));
} else {
tv_sex.setText(getResources().getString(R.string.women));
}
// 出生日期
if (!StringUtil.isEmpty(birthDate)) {
tv_select_birthday.setText(birthDate);
LogUtil.i("birthDate = "+birthDate);
if (birthDate.length() >= 10) {
pwTime.setTime(DateUtil.str2Date(birthDate, "yyyy-MM-dd"));
}
}
// 邮箱
if (!StringUtil.isEmpty(email)) {
tv_email.setText(email);
}
// 医院名称
if (!StringUtil.isEmpty(hospitalName)) {
tv_hospital.setText(hospitalName);
}
// 科室
if (!StringUtil.isEmpty(officeName)) {
tv_offices.setText(officeName);
}
// 科室电话
if (!StringUtil.isEmpty(officePhone)) {
tv_offices_phone.setText(officePhone);
}
// 职称
if (!StringUtil.isEmpty(positionName)) {
tv_professional.setText(positionName);
}
// 资格证书编号
if (!StringUtil.isEmpty(certificate)) {
tv_zhengshubianhao.setText(certificate);
}
// 证书图片
if (!StringUtil.isEmpty(certificateImg)) {
ImageLoader
.getInstance()
.displayImage(
Url.urlHtml + certificateImg,
iv_select2,
ImageOptions
.getImageOptions(R.drawable.ll_upload_certificateimg));
}
// 简介
if (!StringUtil.isEmpty(intro)) {
tv_profile.setText(intro);
}
// 专长
if (!StringUtil.isEmpty(diseaseName)) {
tv_disease.setText(diseaseName);
}
// 专长id
// if (!TextUtils.isEmpty(disease) && !"null".equals(disease)) {
// this.disease = disease;
// }
String result = SharePrefUtil.getString(ct, getExpertByUuid, "");
if (TextUtils.isEmpty(result)) {
showProgressDialog("正在加载");
}
getList(getExpertByUuid);
getList(officeListUrl);// 获取科室列表
getList(positionListUrl);// 获取职称列表
getList(diseaseUrl);// 获取专长
}
@Override
protected void processClick(View v) {
Intent intent;
// AGP 8.0+ R.id 不再是 final 常量,不能用于 switch,改用 if-else
int id = v.getId();
if (id == R.id.top_back_layout) {// 返回
String wrapPhoto = null;
if (!StringUtil.isEmpty(photo)) {
wrapPhoto = Scheme.FILE.wrap(photo);
intent = new Intent();
intent.putExtra("photo", wrapPhoto);
setResult(Constant.INFO_CODE, intent);
}
// if (TextUtils.isEmpty(photoBase64) &&
// TextUtils.isEmpty(birthdayPost)
// && TextUtils.isEmpty(emailPost) &&
// TextUtils.isEmpty(officePhonePost)
// && TextUtils.isEmpty(profilePost)) {
// LogUtil.i("没有需要提交的");
// }else{
submit();
// getList(modifyUrl);
SharePrefUtil.saveString(ct, "MyChangePhoto", wrapPhoto);
// }
this.finish();
hideSoftKeyboard();
} else if (id == R.id.rl_photo) {// 头像
intent = new Intent(ct, SelectedPhotoActivity.class);
startActivityForResult(intent, TO_SELECT_PHOTO);
} else if (id == R.id.rl_zhengshu) {
Intent i = new Intent(ct, SelectedPhotoActivity.class);
i.putExtra("isConstraint", true);// 是否等比例裁剪
startActivityForResult(i, TO_SELECT_PHOTO1);
// case R.id.rl_zhengshubianhao:
// ToastUtil.showToast("证书编号");
// break;
} else if (id == R.id.rl_phone) {// 电话
String phone = tv_phone.getText().toString().trim();
intent = new Intent(ct, EditPhoneActivity.class);
intent.putExtra("phone", phone);
startActivityForResult(intent, TO_SELECT_PHONE);
} else if (id == R.id.rl_email) {// 邮箱
String email = tv_email.getText().toString().trim();
intent = new Intent(ct, EditEmailActivity.class);
intent.putExtra("email", email);
startActivityForResult(intent, TO_SELECT_EMAIL);
} else if (id == R.id.rl_offices_phone) {// 科室电话
String officePhone = tv_offices_phone.getText().toString().trim();
intent = new Intent(ct, EditOfficePhoneActivity.class);
intent.putExtra("officePhone", officePhone);
startActivityForResult(intent, TO_SELECT_OFFICEPHONE);
} else if (id == R.id.rl_profile) {// 简介
String profile = tv_profile.getText().toString().trim();
intent = new Intent(ct, EditProfileActivity.class);
intent.putExtra("profile", profile);
startActivityForResult(intent, TO_SELECT_PROFILE);
} else if (id == R.id.rl_select_birthday) {// 选择生日
LogUtil.v("选择生日");
pwTime.showAtLocation(rl_select_birthday, Gravity.BOTTOM, 0, 0);
} else if (id == R.id.rl_disease) {// 专长
showDiseasePop(tv_disease);
} else if (id == R.id.rl_professional) {// 职称
showPwOptions("请选择职称", professionalListItems,professionalUuidListItems, tv_professional, 3);
} else if (id == R.id.rl_offices) {// 科室
showPwOptions("请选择科室", officeListItems, officeListUuidItems,tv_offices, 2);
} else if (id == R.id.bt_submit_myinfo) {
// 提交
// submit();
}
}
/**
* 弹出单项选择框 void
*/
private void showPwOptions(String title,
final ArrayList<String> optionsItems,
final ArrayList<String> optionsUuidItems, final TextView tv,
final int flag) {
// 选项选择器
pwOptions = new OptionsPopupWindow(ct);
pwOptions.setPopupTitle(title);
// 一级联动
pwOptions.setPicker(optionsItems);
// 设置选择的一级单位
// pwSexOptions.setLabels("医院");
// 设置默认选中的项目
int position = 0;
// if (flag == 1) {
// //医院单选
// if (!StringUtil.isBland(hospitalName)) {
// if (optionsItems != null && !optionsItems.isEmpty()) {
// for (int i = 0, size = optionsItems.size(); i < size; i++ ) {
// if (optionsItems.get(i).equals(hospitalName)) {
// position = i;
// }
// }
// }
// }
// } else
if (flag == 2) {
// 科室单选
if (!StringUtil.isBland(officeName)) {
if (optionsItems != null && !optionsItems.isEmpty()) {
for (int i = 0, size = optionsItems.size(); i < size; i++) {
if (optionsItems.get(i).equals(officeName)) {
position = i;
}
}
}
}
} else if (flag == 3) {
// 职称单选
if (!StringUtil.isBland(positionName)) {
if (optionsItems != null && !optionsItems.isEmpty()) {
for (int i = 0, size = optionsItems.size(); i < size; i++) {
if (optionsItems.get(i).equals(positionName)) {
position = i;
}
}
}
}
}
pwOptions.setSelectOptions(position);
pwOptions.showAtLocation(tv, Gravity.BOTTOM, 0, 0);
// 监听确定选择按钮
pwOptions
.setOnoptionsSelectListener(new OptionsPopupWindow.OnOptionsSelectListener() {
@Override
public void onOptionsSelect(int options1, int option2,
int options3) {
String tx = optionsItems.get(options1);
String uuid = optionsUuidItems.get(options1);
// 判断是否是下一页
tv.setText(tx);
if (flag == 2) {
officeUuid = uuid;
officeName = tx;
} else if (flag == 3) {
positionUuid = uuid;
positionName = tx;
}
LogUtil.i("tx==" + tx + "uuid=" + uuid);
// }
}
});
}
/*
* 弹出修改信息弹出框
*/
private void showDiseasePop(View parent) {
if (popGridView != null && popGridView.isShowing()) {
popGridView.dismiss();
}
View view = getLayoutInflater().inflate(R.layout.popwindow_grid, null);
popGridView = new PopupWindow(view, LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
popGridView.setBackgroundDrawable(new ColorDrawable(0));
popGridView.setOutsideTouchable(true);
popGridView.setAnimationStyle(R.style.timepopwindow_anim_style);
popGridView.update();
popGridView.setFocusable(true);
TextView btnCancle = (TextView) view.findViewById(R.id.btn_cancle);
TextView btnSure = (TextView) view.findViewById(R.id.btn_sure);
gv_disease = (GridView) view.findViewById(R.id.gv_disease);
gv_disease.setOnItemClickListener(this);
adapter = new MyAdapter(diseaseList);
checkNum = 0;
for (int i = 0; i < diseaseList.size(); i++) {
String uuid2 = diseaseList.get(i).uuid;
adapter.getIsSelected().put(i, false);
if (specialPosintions != null) {
for (int j = 0; j < specialPosintions.length; j++) {
if (uuid2.equals(specialPosintions[j])) {
adapter.getIsSelected().put(i, true);
LogUtil.i("i=====" + i);
checkNum++;
}
}
}
}
gv_disease.setAdapter(adapter);
// adapter.notifyDataSetChanged();
btnCancle.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
getCancleCheck();
popGridView.dismiss();
}
});
btnSure.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
getCheck();
popGridView.dismiss();
}
});
popGridView.showAtLocation(gv_disease, Gravity.BOTTOM, 0, 0);
}
/**
*
*
* 类名称:MyAdapter 类描述: 创建人:苏三元 时间:2015-10-27 下午4:34:36 版权:河南商宇科技有限公司--版权所有
* (c) 2015
*
*/
private class MyAdapter extends BaseAdapter {
// 用来控制CheckBox的选中状况
private HashMap<Integer, Boolean> isSelected;
private List<ListData> list;
public MyAdapter(List<ListData> diseaseList) {
this.isSelected = new HashMap<Integer, Boolean>();
this.list = diseaseList;
// 初始化数据
// initDate();
}
private void initDate() {
for (int i = 0; i < list.size(); i++) {
String uuid2 = list.get(i).uuid;
// checkNum = 0;
/*
* if (specialPosintions != null) { for (int j = 0; j <
* specialPosintions.length; j++) { if
* (uuid2.equals(specialPosintions[j])) { getIsSelected().put(i,
* true); LogUtil.i("i==" + i); checkNum ++; }else{
* getIsSelected().put(i, false); } } }else{
* getIsSelected().put(i, false); }
*/
}
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
VHolder holder = null;
if (convertView == null) {
// 获得ViewHolder对象
holder = new VHolder();
// 导入布局并赋值给convertview
convertView = View.inflate(ct, R.layout.item_date_time, null);
holder.cb = (CheckBox) convertView
.findViewById(R.id.cb_list_title);
holder.cb.setTextSize(13);
// 为view设置标签
convertView.setTag(holder);
} else {
// 取出holder
holder = (VHolder) convertView.getTag();
}
holder.cb.setText(list.get(position).name);// stringArrays[position]
holder.cb.setChecked(getIsSelected().get(position));
return convertView;
}
public HashMap<Integer, Boolean> getIsSelected() {
return isSelected;
}
}
public static class VHolder {
CheckBox cb;
}
// 得到专长
private void getCheck() {
disease = "";
String diseaseName = "";
specialPosintions = new String[diseaseList.size()];
for (int i = 0; i < diseaseList.size(); i++) {
Boolean isCheck = adapter.getIsSelected().get(i);
if (isCheck) {
specialPosintions[i] = diseaseList.get(i).uuid;
disease += diseaseList.get(i).uuid + ",";
diseaseName += diseaseList.get(i).name + "、";
LogUtil.i("disease=" + disease + "=diseaseName=" + diseaseName);
}
}
// 保存到sp为了以后使用
SharePrefUtil.saveString(ct, "disease", disease);
// 去掉最后一个“、”
if (!TextUtils.isEmpty(diseaseName) && diseaseName.length() > 0) {
diseaseName = diseaseName.substring(0, diseaseName.length() - 1);
tv_disease.setText(diseaseName.replace("(甲、乙、丙、丁、戊肝)",""));//"肝炎(甲、乙、丙、丁、戊肝)",
SharePrefUtil.saveString(ct, "diseaseName", diseaseName);
} else {
// tv_disease.setText("");
}
}
// 得到专长
private void getCancleCheck() {
disease = "";
String diseaseName = "";
specialPosintions = new String[diseaseList.size()];
for (int i = 0; i < diseaseList.size(); i++) {
Boolean isCheck = adapter.getIsSelected().get(i);
if (isCheck) {
specialPosintions[i] = diseaseList.get(i).uuid;
diseaseName += diseaseList.get(i).name + "、";
}
}
if (TextUtils.isEmpty(diseaseName)) {
// tv_disease.setText("");
}
}
/**
* 实例化时间选择器,与选择时间回调 bottomSelectDate
*
* void
*/
private void bottomSelectDate() {
// 时间选择器
pwTime = new TimePopupWindow(this, Type.YEAR_MONTH_DAY);
// pwTime.setTime(new Date());
pwTime.setTime(DateUtil.str2Date("1970-01-01", "yyyy-MM-dd"));
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
int year = calendar.get(Calendar.YEAR);
// 设置标题
pwTime.setPopupTitle("请选择出生日期");
// 设置起始时间
pwTime.setRange(1900, year);
// 时间选择后回调
pwTime.setOnTimeSelectListener(new OnTimeSelectListener() {
@Override
public void onTimeSelect(Date date) {
birthdayPost = DateUtil.date2Str(date, "yyyy-MM-dd");
tv_select_birthday.setText(birthdayPost);
// showProgressDialog("提交中...");
// getList(modifyUrl);
}
});
}
// 提交
public void submit() {
birthdayDate = tv_select_birthday.getText().toString().trim();
name = tv_name.getText().toString().trim();
email = tv_email.getText().toString().trim();
intro = tv_profile.getText().toString().trim();
phone = tv_phone.getText().toString().trim();
officePhone = tv_offices_phone.getText().toString().trim();
positionName = tv_professional.getText().toString().trim();
etofficeName = tv_offices.getText().toString().trim();
diseaseName = tv_disease.getText().toString().trim();
officeName = etofficeName;
showProgressDialog("修改中...");
getList(modifyUrl);
needreportSimple("modify");
}
private Map<Integer, UserInfoFieldEnum> fieldMap;
private void update(Serializable content) {
RequestCallbackWrapper callback = new RequestCallbackWrapper() {
@Override
public void onResult(int code, Object result, Throwable exception) {
}
};
fieldMap =new HashMap<>();
fieldMap.put(UserConstant.KEY_NICKNAME,UserInfoFieldEnum.Name);
UserUpdateHelper.update(fieldMap.get(UserConstant.KEY_NICKNAME),content,callback);
}
/**
* 解析并处理数据
*
* @param result
*/
private void processData(String url, String result) {
LogUtil.i("result = "+result);
if (modifyUrl.equals(url)) {
SettingInfoBean bean = GsonTools.fromGsonToBean(result,
SettingInfoBean.class);
if ("1".equals(bean.code)) {
SettingInfoBean.InfoData data = bean.data;
if (data != null) {
String realName = data.realName;
update(realName);
int sex = data.sex;
String hospitalName = data.hospitalName;
String birthDate = data.birthDate;
mobile = data.mobile;
Log.d("parameterso","mobile2 ="+mobile);
String photo = data.photo;
String email = data.email;
String hospitalUuid = data.hospitalUuid;
String officeName = data.officeName;
String officePhone = data.officePhone;
String officeUuid = data.officeUuid;
String positionUuid = data.positionUuid;
String positionName = data.positionName;
String certificate = data.certificate;
String certificateImg = data.certificateImg;
String qrcode = data.qrcode;
// String isStar = data.isStar;
// int countyId = data.countyId;
// int provId = data.provId;
// int cityId = data.cityId;
// 保存个人资料到SP文件
if (!StringUtil.isEmpty(realName)) {
SharePrefUtil.saveString(ct, Constant.realName,
realName);
}
if (!StringUtil.isEmpty(mobile)
&& ValidateUtils.isMobileNum(mobile)) {
SharePrefUtil.saveString(ct, Constant.mobile, mobile);
Log.d("parameterso","mobile3 ="+mobile);
}
if (!StringUtil.isEmpty(photo)) {
SharePrefUtil.saveString(ct, Constant.photo, photo);
}
if (!StringUtil.isEmpty(email)) {
SharePrefUtil.saveString(ct, "email", email);
}
if (!StringUtil.isEmpty(birthDate)) {
SharePrefUtil.saveString(ct, "birthDate", birthDate);
}
if (!StringUtil.isEmpty(hospitalName)) {
SharePrefUtil.saveString(ct, "hospitalUuid",
hospitalUuid);
SharePrefUtil.saveString(ct, "hospitalName",
hospitalName);
}
if (!StringUtil.isEmpty(officeName)) {
SharePrefUtil.saveString(ct, "officeUuid", officeUuid);
SharePrefUtil.saveString(ct, "officeName", officeName);
}
if (!StringUtil.isEmpty(officePhone)) {
SharePrefUtil
.saveString(ct, "officePhone", officePhone);
}
if (!StringUtil.isEmpty(intro)) {
SharePrefUtil.saveString(ct, "intro", intro);
}
if (!StringUtil.isEmpty(certificate)) {
SharePrefUtil
.saveString(ct, "certificate", certificate);
}
if (!StringUtil.isEmpty(certificateImg)) {
SharePrefUtil.saveString(ct, "certificateImg",
certificateImg);
}
if (!StringUtil.isEmpty(qrcode)) {
SharePrefUtil.saveString(ct, "qrcode", qrcode);
}
SharePrefUtil.saveInt(ct, "sex", sex);
SharePrefUtil.saveString(ct, "positionUuid", positionUuid);
SharePrefUtil.saveString(ct, "positionName", positionName);
SharePrefUtil.saveString(ct, "officeName", officeName);
SharePrefUtil.saveString(ct, "officeUuid", officeUuid);
// SharePrefUtil.saveInt(ct, "cityId", cityId);
// SharePrefUtil.saveInt(ct, "countyId", countyId);
// SharePrefUtil.saveString(ct, "isStar", isStar);
// SharePrefUtil.saveInt(ct, "provId", provId);
// SharePrefUtil.saveInt(ct, "state", state);
// SharePrefUtil.saveString(ct, "MyChangePhoto",
// Url.urlHtml+photo);
LogUtil.i("data==" + data.toString());
}
// closeProgressDialog();
// ToastUtil.showToast("修改成功");
} else {
SharePrefUtil.saveString(ct, "MyChangePhoto", null);
// closeProgressDialog();
// ToastUtil.showToast("修改失败,请重试");
}
} else if (getExpertByUuid.equals(url)) {
ChangeMyInfoBean bean = GsonTools.fromGsonToBean(result,
ChangeMyInfoBean.class);
saveInfo(bean);
} else {
GetListBean bean = GsonTools.fromGsonToBean(result,
GetListBean.class);
// 数据为空
if (bean.data != null && bean.data.size() > 0) {
if (officeListUrl.equals(url)) {
officeListUuidItems.clear();
officeListItems.clear();
for (int i = 0; i < bean.data.size(); i++) {
officeListUuidItems.add(bean.data.get(i).officeUuid);
officeListItems.add(bean.data.get(i).officeName);
}
} else if (positionListUrl.equals(url)) {
professionalUuidListItems.clear();
professionalListItems.clear();
for (int i = 0; i < bean.data.size(); i++) {
professionalUuidListItems.add(bean.data.get(i).uuid);
professionalListItems.add(bean.data.get(i).name);
}
} else if (diseaseUrl.equals(url)) {
bean.data.get(0).des = "肝炎";//去除甲乙丙丁"肝炎(甲、乙、丙、丁、戊肝)",
bean.data.get(0).name = "肝炎";
diseaseList.clear();
diseaseList.addAll(bean.data);// 肝胆病标签列表
// adapter = new MyAdapter(diseaseList);
// gv_disease.setAdapter(adapter);
}
} else {
ToastUtil.showToast("获取失败,请重试");
}
}
}
// 保存数据到本地
public void saveInfo(ChangeMyInfoBean bean) {
if ("1".equals(bean.code)) {
InfoData data = bean.expert;
if (data != null) {
String realName = data.realName;
int sex = data.sex;
String birthDate = data.birthDate;
mobile = data.mobile;
Log.d("parameterso","mobile4 ="+mobile);
String userName = data.userName;
String photo = data.photo;
String email = data.email;
String hospitalUuid = data.hospitalUuid;
String hospitalName = data.hospitalName;
String officeName = data.officeName;
String officePhone = data.officePhone;
String officeUuid = data.officeUuid;
String positionUuid = data.positionUuid;
String positionName = data.positionName;
String certificate = data.certificate;
String certificateImg = data.certificateImg;
String qrcode = data.qrcode;
String intro = data.intro;
String isStar = data.isStar;
// int countyId = data.countyId;
// int provId = data.provId;
// int cityId = data.cityId;
// 保存个人资料到SP文件
SharePrefUtil.saveString(ct, "qrcode", qrcode);
// SharePrefUtil.saveInt(ct, "cityId", cityId);
// SharePrefUtil.saveInt(ct, "countyId", countyId);
// SharePrefUtil.saveInt(ct, "provId", provId);
SharePrefUtil.saveInt(ct, "sex", sex);
SharePrefUtil.saveString(ct, "isStar", isStar);
if (data.state > 0) {
SharePrefUtil.saveInt(ct, "state", data.state);
}
LogUtil.i("data==" + data.toString());
// 回显头像
if (!StringUtil.isEmpty(photo)) {
ImageLoader
.getInstance()
.displayImage(
Url.urlHtml + photo,
iv_select1,
ImageOptions
.getImageOptions(R.drawable.icon_touxiang_persion_gray_big));
SharePrefUtil.saveString(ct, Constant.photo, photo);
}
// 回显姓名
if (!StringUtil.isEmpty(realName)) {
tv_name.setText(realName);
SharePrefUtil.saveString(ct, Constant.realName, realName);
}
// 手机号
if (!StringUtil.isEmpty(mobile)
&& ValidateUtils.isMobileNum(mobile)) {
tv_phone.setText(mobile);
SharePrefUtil.saveString(ct, Constant.mobile, mobile);
Log.d("parameterso","mobile5 ="+mobile);
} else if (!StringUtil.isEmpty(userName)
&& ValidateUtils.isMobileNum(userName)) {
tv_phone.setText(userName);
SharePrefUtil.saveString(ct, Constant.SP_IS_FIRST_NAME,
Constant.mobile, userName);// 手机号
SharePrefUtil.saveString(ct, Constant.mobile, userName);
}
// 性别
if (0 == sex) {
tv_sex.setText(getResources().getString(R.string.man));
} else {
tv_sex.setText(getResources().getString(R.string.women));
}
// 出生日期
if (!StringUtil.isEmpty(birthDate)) {
tv_select_birthday.setText(birthDate);
if (birthDate.length() >= 10) {
pwTime.setTime(DateUtil.str2Date(birthDate,
"yyyy-MM-dd"));
}
SharePrefUtil.saveString(ct, "birthDate", birthDate);
}
// 邮箱
if (!StringUtil.isEmpty(email)) {
tv_email.setText(email);
SharePrefUtil.saveString(ct, "email", email);
}
// 医院名称
if (!StringUtil.isEmpty(hospitalName)) {
tv_hospital.setText(hospitalName);
SharePrefUtil.saveString(ct, "hospitalUuid", hospitalUuid);
SharePrefUtil.saveString(ct, "hospitalName", hospitalName);
}
// 科室
if (!StringUtil.isEmpty(officeName)) {
tv_offices.setText(officeName);
SharePrefUtil.saveString(ct, "officeUuid", officeUuid);
SharePrefUtil.saveString(ct, "officeName", officeName);
}
// 科室电话
if (!StringUtil.isEmpty(officePhone)) {
tv_offices_phone.setText(officePhone);
SharePrefUtil.saveString(ct, "officePhone", officePhone);
}
// 职称
if (!StringUtil.isEmpty(positionName)) {
tv_professional.setText(positionName);
SharePrefUtil.saveString(ct, "positionUuid", positionUuid);
SharePrefUtil.saveString(ct, "positionName", positionName);
}
// 资格证书编号
if (!StringUtil.isEmpty(certificate)) {
tv_zhengshubianhao.setText(certificate);
SharePrefUtil.saveString(ct, "certificate", certificate);
}
// 证书图片
if (!StringUtil.isEmpty(certificateImg)) {
ImageLoader.getInstance().displayImage(
Url.urlHtml + certificateImg, iv_select2);
SharePrefUtil.saveString(ct, "certificateImg",
certificateImg);
}
// 简介
if (!StringUtil.isEmpty(intro)) {
tv_profile.setText(intro);
SharePrefUtil.saveString(ct, "intro", intro);
}
List<SpecialData> special = bean.specialy;// 专长
// 根据专长uuid进行查询专长名称
if (special != null && special.size() > 0) {
String disease = "";
String diseaseNames = "";
for (int j = 0; j < special.size(); j++) {
disease += special.get(j).diseaseUuid + ",";
diseaseNames += special.get(j).diseaseName + "、";
}
if (diseaseNames.length() > 0) {
// 去掉最后一个“、”
diseaseNames = diseaseNames.substring(0,diseaseNames.length() - 1).replace("(甲、乙、丙、丁、戊肝)","");
}
// 专长
tv_disease.setText(diseaseNames);
SharePrefUtil.saveString(ct, "disease", disease);
SharePrefUtil.saveString(ct, "diseaseName", diseaseNames);
LogUtil.i("disease==" + disease + "diseaseNames=="
+ diseaseNames);
}
}
closeProgressDialog();
} else {
closeProgressDialog();
ToastUtil.showToast("资料加载失败,请重试");
}
}
// 获取数据
private void getList(final String loadUrl) {
RequestParams params = new RequestParams();// 封装参数
officeName = tv_offices.getText().toString().trim();
// disease = tv_disease.getText().toString().trim();
if (modifyUrl.equals(loadUrl)) {
params.addBodyParameter("uuid", uuid);// 唯一标识 必填
mobile = SharePrefUtil.getString(ct, "mobile", "");
params.addBodyParameter("userName", mobile);// 真实姓名 必填
params.addBodyParameter("type", String.valueOf(2));// 第一次修改资料填1
//params.addBodyParameter("mobile", mobile);// 手机号 // 在我的模块修改填2
params.addBodyParameter("diseaseUuids", disease);// 专家专长(多个专长以逗号隔开)
Log.d("parameterso","mobile ="+mobile); // 必填
params.addBodyParameter("officeUuid", officeUuid);// 科室uuid
params.addBodyParameter("officeName", officeName);// 科室名称
params.addBodyParameter("positionUuid", positionUuid);// 职称uuid
// params.addBodyParameter("positionName", positionName);//职称名称
if (!StringUtil.isEmpty(photoBase64)) {
params.addBodyParameter("photo", photoBase64);// 头像(base64)
}
if (!StringUtil.isEmpty(photoBase642)) {
params.addBodyParameter("certificateImg", photoBase642);// 头像(base64)
}
if (!StringUtil.isEmpty(birthdayPost)) {
params.addBodyParameter("birthDate", birthdayPost);// 出生日期
}
if (!StringUtil.isEmpty(emailPost)) {
params.addBodyParameter("email", emailPost);// 邮箱
}
if (!StringUtil.isEmpty(officePhonePost)) {
params.addBodyParameter("officePhone", officePhonePost);// 科室电话
}
if (!StringUtil.isEmpty(profilePost)) {
params.addBodyParameter("intro", profilePost);// 简介
}
if (!StringUtil.isEmpty(diseasePost)) {
params.addBodyParameter("diseaseName", diseasePost);// 专长
}
if (!StringUtil.isEmpty(officePost)) {
params.addBodyParameter("officeName", officePost);// 科室
}
if (!StringUtil.isEmpty(positionPost)) {
params.addBodyParameter("positionName", positionPost);// 职称
}
// params.addBodyParameter("sex", selectSex+"");//性别(0男 1女)
// params.addBodyParameter("mobile", phone);//手机号
// params.addBodyParameter("provId", provinceId);//省id
// params.addBodyParameter("cityId", cityId);//市id
// params.addBodyParameter("countyId", disctictId);//区县id
// params.addBodyParameter("intro", intro);//简介
// params.addBodyParameter("hospitalUuid", hospitalUuid);//坐诊医院uuid
// params.addBodyParameter("hospitalName", hospitalName);//坐诊医院名称
// params.addBodyParameter("certificate", certificate);//资格证书
// params.addBodyParameter("certificateImg", picBase642);//资格证书图片
// (base64)
// 查看个人资料
} else if (getExpertByUuid.equals(loadUrl)) {
params.addBodyParameter("uuid", uuid);// 唯一标识 必填
}
HttpHelper.loadData(HttpMethod.POST, loadUrl, params,
new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> info) {
if (!modifyUrl.equals(loadUrl)) {
SharePrefUtil.saveString(ct, loadUrl, info.result);
}
processData(loadUrl, info.result);
}
@Override
public void onFailure(HttpException arg0, String arg1) {
closeProgressDialog();
LogUtil.i("数据请求失败了: " + arg1);
}
});
}
@Override
public ResultState onLoad() {
return ResultState.STATE_SUCCESSED;
}
/**
* F 跳转之后返回的结果
*
* @param requestCode
* 表示是哪个Intent跳转的
* @param resultCode
* 返回的结果码
* @param data
* 数据
*/
@Override
protected void onActivityResult(int requestCode, int resultCode,
final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// 邮箱
if (resultCode == Activity.RESULT_OK && requestCode == TO_SELECT_EMAIL) {
emailPost = data.getStringExtra("email");
tv_email.setText(emailPost);
}
// 手机号
if (resultCode == Activity.RESULT_OK && requestCode == TO_SELECT_PHONE) {
String phone = data.getStringExtra("phone");
SharePrefUtil.saveString(MyDetailInfoActivity.this,
Constant.mobile, phone);
tv_phone.setText(phone);
}
// 科室电话
if (resultCode == Activity.RESULT_OK
&& requestCode == TO_SELECT_OFFICEPHONE) {
officePhonePost = data.getStringExtra("officePhone");
tv_offices_phone.setText(officePhonePost);
}
// 简介
if (resultCode == Activity.RESULT_OK
&& requestCode == TO_SELECT_PROFILE) {
profilePost = data.getStringExtra("profile");
tv_profile.setText(profilePost);
}
// 头像
if (resultCode == Activity.RESULT_OK && requestCode == TO_SELECT_PHOTO) {
// imageView不设null, 第一次上传成功后,第二次在选择上传的时候会报错。
photo = data.getStringExtra(SelectedPhotoActivity.KEY_PHOTO_PATH);
photoBase64 = data
.getStringExtra(SelectedPhotoActivity.KEY_PHOTO_BASE64);
LogUtil.i("photo=" + photo + ", picBase64=" + photoBase64);
String imageUrl = Scheme.FILE.wrap(photo);
LogUtil.i("imageUrl==" + imageUrl);
ImageLoader.getInstance().displayImage(imageUrl, iv_select1,
ImageOptions.getImageOptions(R.drawable.add_photo_normal));
// showProgressDialog("提交中...");
// getList(modifyUrl,true);
}
// 证书
if (resultCode == Activity.RESULT_OK && requestCode == TO_SELECT_PHOTO1) { // imageView不设null,
// 第一次上传成功后,第二次在选择上传的时候会报错。
photo2 = data.getStringExtra(SelectedPhotoActivity.KEY_PHOTO_PATH);
photoBase642 = data
.getStringExtra(SelectedPhotoActivity.KEY_PHOTO_BASE64);
String imageUrl = Scheme.FILE.wrap(photo2);
LogUtil.i("imageUrl==" + imageUrl);
ImageLoader.getInstance().displayImage(imageUrl, iv_select2,
ImageOptions.getImageOptions(R.drawable.add_photo_normal));
}
}
// 手机返回键
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
LogUtil.i("photo=" + photo);
String wrapPhoto = null;
if (!StringUtil.isEmpty(photo)) {
wrapPhoto = Scheme.FILE.wrap(photo);
Intent intent = getIntent();
intent.putExtra("photo", wrapPhoto);
setResult(Constant.INFO_CODE, intent);
}
// if (TextUtils.isEmpty(photoBase64) && TextUtils.isEmpty(birthdayPost)
// && TextUtils.isEmpty(emailPost) && TextUtils.isEmpty(officePhonePost)
// && TextUtils.isEmpty(profilePost)) {
// LogUtil.i("没有需要提交的");
// }else{
SharePrefUtil.saveString(ct, "MyChangePhoto", wrapPhoto);
submit();
// getList(modifyUrl);
// }
super.onBackPressed();
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// 取得ViewHolder对象,这样就省去了通过层层的findViewById去实例化我们需要的cb实例的步骤
VHolder holder = (VHolder) arg1.getTag();
LogUtil.i("checkNum=" + checkNum + "arg2=" + arg2);
if (!holder.cb.isChecked()) {
if (checkNum >= 10) {
ToastUtil.showToast("最多选十项");
return;
}
}
// 改变CheckBox的状态
holder.cb.toggle();
// 将CheckBox的选中状况记录下来
adapter.getIsSelected().put(arg2, holder.cb.isChecked());
// 调整选定条目
if (holder.cb.isChecked() == true) {
checkNum++;
} else {
checkNum--;
if (checkNum < 0) {
checkNum = 0;
}
}
}
}