package cn.shangyu.gdxzExpert.activity; import static cn.shangyu.gdxzExpert.base.BaseFragment.mActivity; import static cn.shangyu.gdxzExpert.netease.ptop.MessageFragment.cancelBackground; import static cn.shangyu.gdxzExpert.netease.ptop.MessageFragment.lucencyBackground; import static cn.shangyu.gdxzExpert.utils.HttpMD5SendInfoUtil.hasrealtoken; import static cn.shangyu.gdxzExpert.utils.HttpMD5SendInfoUtil.sendJsonPostParamTokenMD5; import static cn.shangyu.gdxzExpert.utils.UIUtils.getContext; import android.Manifest; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.provider.MediaStore; import android.text.Editable; import android.text.InputType; import android.text.TextWatcher; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.webkit.WebSettings; import android.widget.AdapterView; import android.widget.Button; import android.widget.EditText; import android.widget.GridView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.core.content.FileProvider; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.github.dfqin.grantor.PermissionListener; import com.github.dfqin.grantor.PermissionsUtil; import com.google.gson.Gson; import com.gyf.immersionbar.ImmersionBar; import com.hjq.window.EasyWindow; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener; import com.zhy.http.okhttp.OkHttpUtils; import com.zhy.http.okhttp.callback.StringCallback; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.SimpleDateFormat; 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.application.BaseApplication; import cn.shangyu.gdxzExpert.base.BaseActivity; import cn.shangyu.gdxzExpert.bean.AddBitmaps; import cn.shangyu.gdxzExpert.bean.AddCaseNewRecordAdapter; import cn.shangyu.gdxzExpert.bean.BaseBeanNew; import cn.shangyu.gdxzExpert.bean.BaseInfoBean; import cn.shangyu.gdxzExpert.bean.PhotoItem; import cn.shangyu.gdxzExpert.bean.SimpleBean; import cn.shangyu.gdxzExpert.bean.imBean; import cn.shangyu.gdxzExpert.bean.projectQueryForm4; import cn.shangyu.gdxzExpert.http.OnCallBackFromNet; import cn.shangyu.gdxzExpert.utils.Base64Util; import cn.shangyu.gdxzExpert.utils.DateUtil; import cn.shangyu.gdxzExpert.utils.GsonTools; 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.UIUtils; import cn.shangyu.gdxzExpert.utils.UpdateVersionUtils; import cn.shangyu.gdxzExpert.utils.Url; import cn.shangyu.gdxzExpert.utils.ValidateUtils; import cn.shangyu.gdxzExpert.view.KeyboardLayout; import cn.shangyu.gdxzExpert.view.PhotoView; import cn.shangyu.gdxzExpert.widge.pickerview.TimePopupWindow; import cn.shangyu.gdxzExpert.widget.ECAlertDialog; import cn.shangyu.gdxzExpert.widget.LoadingPage; import okhttp3.Call; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; public class InfomationActivity extends BaseActivity implements AdapterView.OnItemClickListener { KeyboardLayout detailMainRL; @Override public void setTitle() { top_title.setText("基本信息"); } View view; TextView new_suifang; TextView yiwen1,yiwen2,tv_bir; RadioGroup grop3,grop5; LinearLayout l1,l2; TextView t1,t2; EditText year1,month1,year2,month2,phone,ed_other,tv_birs; int mon1=0,mon2=0,y1=0,y2=0; private GridView mGv_photos; private Bitmap mAddBitmap; private ArrayList mBitmaps; private AddBitmaps mAddBitmaps; private AddCaseNewRecordAdapter gv_adapter; private RelativeLayout rl_addcase_bigphoto; private ViewPager mPager; private View selectedPhotoView; private TextView ll_selected_carmera;// 从照相机 private TextView ll_selected_photo;// 从相册 private PopupWindow mPopupWindowDialog; private TextView tv_cancel;// 取消 private Uri photoUri;// 图片路径 public static final int SELECT_PIC_BY_TACK_PHOTO = 101; // 使用照相机拍照获取图片 public static final int SELECT_PIC_BY_PICK_PHOTO = 102; // 使用相册中的图片 private static final int PHOTO_RESOULT = 103;// 照相 private File temp; String patientcaseId,patientNo,name,baseinfoDataStatus; RadioButton tab_rbn_1,tab_rbn_2,tab_rbn_3,tab_rbn_4,tab_rbn_5,tab_rbn_6 , tab_rbn_31,tab_rbn_32,tab_rbn_41,tab_rbn_42,tab_rbn_51,tab_rbn_52 ,tab_rbn_61,tab_rbn_62,tab_rbn_71,tab_rbn_72 ,tab_rbn_81,tab_rbn_82,tab_rbn_91,tab_rbn_92,tab_rbn_101,tab_rbn_102 ,tab_rbn_111,tab_rbn_112,tab_rbn_121,tab_rbn_122; @Override public View onCreateSuccessedView() { view= UIUtils.inflate(R.layout.activity_infomation); detailMainRL = view.findViewById(R.id.main_ll); tab_rbn_1=view.findViewById(R.id.tab_rbn_1); tab_rbn_2=view.findViewById(R.id.tab_rbn_2); tab_rbn_3=view.findViewById(R.id.tab_rbn_3); tab_rbn_4=view.findViewById(R.id.tab_rbn_4); tab_rbn_5=view.findViewById(R.id.tab_rbn_5); tab_rbn_6=view.findViewById(R.id.tab_rbn_6); tab_rbn_31=view.findViewById(R.id.tab_rbn_31); tab_rbn_32=view.findViewById(R.id.tab_rbn_32); tab_rbn_41=view.findViewById(R.id.tab_rbn_41); tab_rbn_42=view.findViewById(R.id.tab_rbn_42); tab_rbn_51=view.findViewById(R.id.tab_rbn_51); tab_rbn_52=view.findViewById(R.id.tab_rbn_52); tab_rbn_61=view.findViewById(R.id.tab_rbn_61); tab_rbn_62=view.findViewById(R.id.tab_rbn_62); tab_rbn_71=view.findViewById(R.id.tab_rbn_71); tab_rbn_72=view.findViewById(R.id.tab_rbn_72); tab_rbn_81=view.findViewById(R.id.tab_rbn_81); tab_rbn_82=view.findViewById(R.id.tab_rbn_82); tab_rbn_91=view.findViewById(R.id.tab_rbn_91); tab_rbn_92=view.findViewById(R.id.tab_rbn_92); tab_rbn_101=view.findViewById(R.id.tab_rbn_101); tab_rbn_102=view.findViewById(R.id.tab_rbn_102); tab_rbn_111=view.findViewById(R.id.tab_rbn_111); tab_rbn_112=view.findViewById(R.id.tab_rbn_112); tab_rbn_121=view.findViewById(R.id.tab_rbn_121); tab_rbn_122=view.findViewById(R.id.tab_rbn_122); phone=view.findViewById(R.id.phone); phone.setInputType(InputType.TYPE_CLASS_NUMBER); baseinfoDataStatus=getIntent().getStringExtra("dataStatus"); tv_birs=view.findViewById(R.id.tv_birs); tv_birs.setInputType(InputType.TYPE_CLASS_NUMBER); detailMainRL.setOnkbdStateListener(new KeyboardLayout.onKeyboaddsChangeListener() { public void onKeyBoardStateChange(int state) { switch (state) { case KeyboardLayout.KEYBOARD_STATE_HIDE: // if(StringUtil.isEmpty(tv_birs.getText().toString())) // { // tv_bir.setText("请选择患者出生日期"); // return; // } if(StringUtil.isEmpty(tv_birs.getText().toString())||Integer.valueOf(tv_birs.getText().toString())<18||Integer.valueOf(tv_birs.getText().toString())>50) { if(StringUtil.isEmpty(birthdayPost)) { tv_birs.setText(""); } else { tv_birs.setText(DateUtil.getAgeByBirthdays(birthdayPost)+""); } if(InfomationActivity.this.isFinishing()) { return ; } ToastUtil.showToast("患者入组时年龄范围为18~50,该患者年龄不合格"); return ; } Calendar cal = Calendar.getInstance(); int yearNow=0; if(!StringUtil.isEmpty(tv_birs.getText().toString())) { yearNow = cal.get(Calendar.YEAR)- Integer.valueOf(tv_birs.getText().toString()); } birthdayPost=yearNow+"-01-01"; tv_bir.setText(birthdayPost.substring(0,4) +"("+DateUtil.getAgeByBirthdays(birthdayPost)+"岁"+")"); break; case KeyboardLayout.KEYBOARD_STATE_SHOW: // Log.d("resultJson ","键盘弹出状态"); break; } } }); // TextWatcher textWatcher = new TextWatcher() { // private int beforeTextLength = 0; // // @Override // public void beforeTextChanged(CharSequence s, int start, int count, int after) { // beforeTextLength = s.length(); // } // // @Override // public void onTextChanged(CharSequence s, int start, int before, int count) { // // 不做处理 // } // // @Override // public void afterTextChanged(Editable s) { // if (s.length() > 11) { // 假设限制输入位数为10 // s.delete(11, s.length()); // 删除多余的字符 // } // int currentTextLength = s.length(); // if (beforeTextLength > currentTextLength) { // // 当用户删除字符时,也应该更新beforeTextLength // beforeTextLength = currentTextLength; // } // } // }; // // phone.addTextChangedListener(textWatcher); ed_other=view.findViewById(R.id.ed_other); new_suifang=view.findViewById(R.id.new_suifang); new_suifang.setOnClickListener(this); view.findViewById(R.id.change_data).setOnClickListener(this); yiwen1=view.findViewById(R.id.yiwen1); yiwen1.setOnClickListener(this); yiwen2=view.findViewById(R.id.yiwen2); yiwen2.setOnClickListener(this); tv_bir=view.findViewById(R.id.tv_bir); tv_bir.setOnClickListener(this); grop3=view.findViewById(R.id.grop3); grop5=view.findViewById(R.id.grop5); l1=view.findViewById(R.id.l1); l2=view.findViewById(R.id.l2); t1=view.findViewById(R.id.t1); t2=view.findViewById(R.id.t2); year1=view.findViewById(R.id.year1); year2=view.findViewById(R.id.year2); month1=view.findViewById(R.id.month1); month2=view.findViewById(R.id.month2); patientcaseId=getIntent().getStringExtra("patientcaseId"); patientNo=getIntent().getStringExtra("patientNo"); name=getIntent().getStringExtra("name"); bottomSelectDate(); initView(); init(); gettokens(Url.getBaseInfo); return view; } public void init() { // grop3.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { // @Override // public void onCheckedChanged(RadioGroup radioGroup, int i) { // if(i==R.id.tab_rbn_31) // { // l1.setVisibility(View.VISIBLE); // if(tab_rbn_51.isChecked()) // { // l2.setVisibility(View.VISIBLE); // } // else // { // l2.setVisibility(View.GONE); // } // // } // else // { // l1.setVisibility(View.GONE); // l2.setVisibility(View.GONE); // } // // } // }); grop5.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int i) { if(tab_rbn_32.isChecked()) { l2.setVisibility(View.GONE); return; } if(i==R.id.tab_rbn_51) { l2.setVisibility(View.VISIBLE); } else { l2.setVisibility(View.GONE); } } }); year1.setInputType(InputType.TYPE_CLASS_NUMBER); year2.setInputType(InputType.TYPE_CLASS_NUMBER); month1.setInputType(InputType.TYPE_CLASS_NUMBER); month2.setInputType(InputType.TYPE_CLASS_NUMBER); year1.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if(editable!=null&&!StringUtil.isEmpty(editable.toString())) { y1=Integer.valueOf(editable.toString()); } else { y1=0; } setyear(); } }); month1.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if(editable!=null&&!StringUtil.isEmpty(editable.toString())) { mon1=Integer.valueOf(editable.toString()); } else { mon1=0; } setyear(); } }); year2.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if(editable!=null&&!StringUtil.isEmpty(editable.toString())) { y2=Integer.valueOf(editable.toString()); } else { y2=0; } setyear2(); } }); month2.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if(editable!=null&&!StringUtil.isEmpty(editable.toString())) { mon2= Integer.valueOf(editable.toString()); ; } else { mon2=0; } setyear2(); } }); } public void setyear() { t1.setText("("+String.format("%.2f", y1+mon1/12.00)+"年"+")"); } public void setyear2() { t2.setText("("+String.format("%.2f", y2+mon2/12.00)+"年"+")"); } private void initView() { mGv_photos = (GridView) view.findViewById(R.id.gv_case_photos); rl_addcase_bigphoto = view.findViewById(R.id.rl_addcase_bigphoto); mPager = (ViewPager) view.findViewById(R.id.pager); mAddBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.new_selected); mBitmaps = new ArrayList(); mAddBitmaps = new AddBitmaps(true, mAddBitmap, null); // mBitmaps.add(mAddBitmaps); gv_adapter = new AddCaseNewRecordAdapter(InfomationActivity.this, mBitmaps, mAddBitmaps); mGv_photos.setOnItemClickListener(this); mGv_photos.setAdapter(gv_adapter); } private String birthdayPost=""; private TimePopupWindow pwTime; /** * 实例化时间选择器,与选择时间回调 bottomSelectDate * * void */ Date inittime=DateUtil.str2Date("1980-01-01", "yyyy-MM-dd"); private void bottomSelectDate() { // 时间选择器 pwTime = new TimePopupWindow(this, TimePopupWindow.Type.YEAR); pwTime.setTime(inittime); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); int year = calendar.get(Calendar.YEAR); // 设置标题 pwTime.setPopupTitle("请选择出生日期"); // 设置起始时间 pwTime.setRange(1900, year); // 时间选择后回调 pwTime.setOnTimeSelectListener(new TimePopupWindow.OnTimeSelectListener() { @Override public void onTimeSelect(Date date) { birthdayPost = DateUtil.date2Str(date, "yyyy-MM-dd"); inittime=date; pwTime.setTime(inittime); if(DateUtil.getAgeByBirthdays(birthdayPost)<18||DateUtil.getAgeByBirthdays(birthdayPost)>50) { ToastUtil.showToast("患者入组时年龄范围为18~50,该患者年龄不合格"); } else { tv_bir.setText(birthdayPost.substring(0,4) +"("+DateUtil.getAgeByBirthdays(birthdayPost)+"岁"+")"); tv_birs.setText(DateUtil.getAgeByBirthdays(birthdayPost)+""); } } }); } @Override public LoadingPage.ResultState onLoad() { return LoadingPage.ResultState.STATE_SUCCESSED; } @Override protected void processClick(View v) { switch (v.getId()) { case R.id.yiwen2: showyiwen("年龄",getString(R.string.nianlin)); break; case R.id.yiwen1: showyiwen("诊断标准",getString(R.string.zhenduan)); break; case R.id.tv_bir: pwTime.showAtLocation(tv_bir, Gravity.BOTTOM, 0, 0); break; case R.id.new_suifang: popwindow(v,"确认保存新的信息?"); // hideSoftKeyboard(); // v.postDelayed(new Runnable() { // @Override // public void run() { // popwindow("确认保存新的信息?"); // } // },300); break; case R.id.change_data: popwindow(v,"确认本数据项已全部完成?"); // hideSoftKeyboard(); // v.postDelayed(new Runnable() { // @Override // public void run() { // popwindow("确认本数据项已全部完成?"); // } // },300); break; } } private ECAlertDialog buildAlert; public void popwindow(View v,String content) { lucencyBackground(InfomationActivity.this); // 一个自定义的布局,作为显示的内容 View contentView = LayoutInflater.from(InfomationActivity.this) .inflate(R.layout.common_dialog_generic, null); ((TextView)(contentView.findViewById(R.id.dialog_tv_message))).setText(content); ((TextView)(contentView.findViewById(R.id.dialog_tv_message))).setTextSize(16); ((TextView)(contentView.findViewById(R.id.dialog_tv_title))).setText("温馨提示"); ((TextView)(contentView.findViewById(R.id.dialog_tv_title))).setTextColor(getResources().getColor(R.color.top_title)); contentView.findViewById(R.id.dialog_layout_title).setVisibility(View.VISIBLE); Button leftBtn = contentView.findViewById(R.id.dilaog_button1); leftBtn.setText("取消"); ((ViewGroup.MarginLayoutParams)leftBtn.getLayoutParams()).rightMargin=1; leftBtn.setVisibility(View.VISIBLE); Button rightBtn = contentView. findViewById(R.id.dilaog_button3); ((ViewGroup.MarginLayoutParams)rightBtn.getLayoutParams()).leftMargin=1; rightBtn.setVisibility(View.VISIBLE); rightBtn.setText("确认"); contentView.findViewById(R.id.dialog_layout_button).setVisibility(View.VISIBLE); // Button btn_sure = (Button) contentView.findViewById(R.id.btn_sure); // Button btn_cancel = (Button) contentView.findViewById(R.id.btn_cancel); // TextView tv_tishi=contentView.findViewById(R.id.tv_tishi); // btn_sure.setText("确认"); // btn_cancel.setText("取消"); // tv_tishi.setText(content); final PopupWindow popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); popupWindow.setBackgroundDrawable(new ColorDrawable(0)); // 设置允许在外点击消失 popupWindow.setOutsideTouchable(true); //进入退出动画 // popupWindow.setAnimationStyle(R.style.timepopwindow_anim_style); // 使其聚集获取焦点 popupWindow.setFocusable(true); // popupWindow.setTouchable(true); rightBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { popupWindow.dismiss(); if(content.contains("保存")) { sendpre(); } else{ baseinfoDataStatus="2"; sendpre(); } } }); leftBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { popupWindow.dismiss(); } }); popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { cancelBackground(InfomationActivity.this); } }); popupWindow .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0); // buildAlert = ECAlertDialog.buildAlert(InfomationActivity.this, content, "取消", // "确认", new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // // TODO Auto-generated method stub // buildAlert.dismiss(); // } // }, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // if(content.contains("保存")) // { // sendpre(); // // } // else{ // baseinfoDataStatus="2"; // sendpre(); // hideSoftKeyboard(); // } // // buildAlert.dismiss(); // // } // }); // buildAlert.setTitle("温馨提示"); // buildAlert.setTitleColor(getResources().getColor( // R.color.top_title)); // buildAlert.show(); } public void showyiwen(String title,String content) { EasyWindow.with(InfomationActivity.this).setGravity(Gravity.CENTER) .setContentView(R.layout.float_cent_dialogqs).setBackgroundDimAmount(0.5f) .setText(R.id.tv_infotitle, title) .setText(R.id.tv_tishi, content) .setText(android.R.id.message, "确定") .setOutsideTouchable(false) .setOnClickListener(android.R.id.message, new EasyWindow.OnClickListener() { @Override public void onClick(EasyWindow window, TextView view) { window.cancel(); } }).show(); } @Override public void onItemClick(AdapterView adapterView, View view, int position, long l) { hideSoftKeyboard(); if (mBitmaps.get(position).isAdd()) { selectedPhotoView = UIUtils.inflate(R.layout.activity_selected_photo2); ll_selected_carmera = (TextView) selectedPhotoView .findViewById(R.id.btn_camera); ll_selected_photo = (TextView) selectedPhotoView .findViewById(R.id.btn_img); tv_cancel = (TextView) selectedPhotoView .findViewById(R.id.btn_cancle); ImageView imageView = (ImageView) selectedPhotoView .findViewById(R.id.imageView); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mPopupWindowDialog != null && mPopupWindowDialog.isShowing()) { mPopupWindowDialog.dismiss(); } } }); initSelectedHeadPopupwindow(); if (mPopupWindowDialog != null) { mPopupWindowDialog.showAtLocation(this.view, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, ImmersionBar.getNavigationBarHeight(this)); } selectedPhoto(); } else { rl_addcase_bigphoto.setVisibility(View.VISIBLE); PagerSetAdapter(position); } } /** * 初始化头像选择pop */ private void initSelectedHeadPopupwindow() { // TODO Auto-generated method stub mPopupWindowDialog = new PopupWindow(selectedPhotoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mPopupWindowDialog.setFocusable(true); mPopupWindowDialog.update(); mPopupWindowDialog.setBackgroundDrawable(new BitmapDrawable( getResources(), (Bitmap) null)); mPopupWindowDialog.setOutsideTouchable(true); } /** * 选择图片 */ private void selectedPhoto() { // TODO Auto-generated method stub ll_selected_carmera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (PermissionsUtil.hasPermission(InfomationActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) { //有访问摄像头的权限 takePhoto11();// 拍照获取 } else { EasyWindow.with(InfomationActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000) .setContentView(R.layout.float_top_dialog_new).show(); PermissionsUtil.requestPermission(InfomationActivity.this, new PermissionListener() { @Override public void permissionGranted(@NonNull String[] permissions) { EasyWindow.cancelAll(); //用户授予了访问摄像头的权限 takePhoto11();// 拍照获取 } @Override public void permissionDenied(@NonNull String[] permissions) { EasyWindow.cancelAll(); //用户拒绝了访问摄像头的申请 } }, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE}); } }else { takePhoto();// 拍照获取 } } }); ll_selected_photo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (PermissionsUtil.hasPermission(InfomationActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) { //有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录 Intent intent = new Intent(mActivity, PhotoAlbumActivity.class); intent.putExtra("photonum", "" + (mBitmaps.size() - 1)); intent.putExtra("maxphotonum",9); startActivityForResult(intent, SELECT_PIC_BY_PICK_PHOTO); } else { EasyWindow.with(InfomationActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000) .setContentView(R.layout.float_top_dialog_photo).show(); PermissionsUtil.requestPermission(InfomationActivity.this, new PermissionListener() { @Override public void permissionGranted(@NonNull String[] permissions) { EasyWindow.cancelAll(); Intent intent = new Intent(InfomationActivity.this, PhotoAlbumActivity.class); intent.putExtra("photonum", "" + (mBitmaps.size() - 1)); intent.putExtra("maxphotonum",9); startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO); } @Override public void permissionDenied(@NonNull String[] permissions) { EasyWindow.cancelAll(); //用户拒绝了访问读写的申请 } }, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE}); } }else { Intent intent = new Intent(InfomationActivity.this, PhotoAlbumActivity.class); intent.putExtra("photonum", "" + (mBitmaps.size() - 1)); intent.putExtra("maxphotonum",9); startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO); } } }); tv_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mPopupWindowDialog != null && mPopupWindowDialog.isShowing()) { mPopupWindowDialog.dismiss(); } } }); } private void takePhoto11() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);// 设置打开相机 File photoFile = null; try { File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); // 保存到公共共享空间内,可以在资源管理器中找到,其他应用也可以直接访问 // File storageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES); 将图片放到应用专属空间内,其他的应用无法访问,也无法查看。随app的卸载而删除 String imageFileName = "fileName"; photoFile = File.createTempFile(imageFileName, ".jpg", storageDir); // String filePath = photoFile.getAbsolutePath(); 获取到图片的路径,可以在onActivityResult中根据这个路径去获取图片 } catch (IOException e) { e.printStackTrace(); } if (photoFile != null) { photoUri = FileProvider.getUriForFile(this,getPackageName() + ".fileprovider", photoFile); SharePrefUtil.saveString(this, "photoUri", photoUri + ""); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".fileprovider", photoFile)); startActivityForResult(intent, SELECT_PIC_BY_TACK_PHOTO); } } /** * 拍照获取图片 */ private void takePhoto() { String fileName = null; // 执行拍照前,应该先判断SD卡是否存在 String SDState = Environment.getExternalStorageState(); if (SDState.equals(Environment.MEDIA_MOUNTED)) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);// "android.media.action.IMAGE_CAPTURE"调用系统的相机 fileName = String.valueOf(System.currentTimeMillis()) + ".jpg"; photoUri = getUriForFile(InfomationActivity.this,new File(Environment.getExternalStorageDirectory(), fileName)); // photoUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), fileName)); // 指定照片保存路径(SD卡),image.jpg为一个临时文件,每次拍照后这个图片都会被替换 intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); SharePrefUtil.saveString(InfomationActivity.this, "photoUri", photoUri + ""); startActivityForResult(intent, SELECT_PIC_BY_TACK_PHOTO); } else { Toast.makeText(this, "内存卡不存在", Toast.LENGTH_LONG).show(); } } public static Uri getUriForFile(Context context, File file) { if (context == null || file == null) { throw new NullPointerException(); } Uri uri; if (Build.VERSION.SDK_INT >= 24) { uri = FileProvider.getUriForFile(context.getApplicationContext(), "cn.shangyu.gdxzExpert.fileprovider", file); } else { uri = Uri.fromFile(file); } return uri; } public void PagerSetAdapter(int p) { layout_top.setVisibility(View.GONE); mPager.setPageMargin((int) (getResources().getDisplayMetrics().density * 15)); mPager.setAdapter(new PagerAdapter() { @Override public int getCount() { for (int i = 0; i < mBitmaps.size(); i++) { if (mBitmaps.get(i).isAdd()) { return mBitmaps.size() - 1; } } return mBitmaps.size(); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public Object instantiateItem(ViewGroup container, int position) { PhotoView view = new PhotoView(InfomationActivity.this); view.enable(); view.setScaleType(ImageView.ScaleType.FIT_CENTER); if (!mBitmaps.get(position).isAdd()) { if(!StringUtil.isEmpty(mBitmaps.get(position).getPath())) { Glide.with(InfomationActivity.this).asBitmap().load(mBitmaps.get(position).getPath()) .apply(new RequestOptions().error(R.drawable.home_scroll_default)) .into(view); } else { view.setImageBitmap(mBitmaps.get(position).getBitmap()); } } view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub rl_addcase_bigphoto.setVisibility(View.GONE); layout_top.setVisibility(View.VISIBLE); } }); container.addView(view); return view; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); } }); mPager.setCurrentItem(p); } private ArrayList paths; @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); if (mPopupWindowDialog != null && mPopupWindowDialog.isShowing()) { mPopupWindowDialog.dismiss(); } LogUtil.i("requestCode = "+requestCode); switch (requestCode) { case SELECT_PIC_BY_PICK_PHOTO: if (data == null) { break; } paths = (ArrayList) data.getSerializableExtra("photos"); mBitmaps.remove(mAddBitmaps); showProgressDialog(""); new Thread() { public void run() { for (int i = 0; i < paths.size(); i++) { InputStream is; try { is = new FileInputStream(paths.get(i).getPath()); BitmapFactory.Options opts = new BitmapFactory.Options(); // opts.inJustDecodeBounds = true; opts.inTempStorage = new byte[100 * 1024]; opts.inPreferredConfig = Bitmap.Config.RGB_565; opts.inPurgeable = true; BitmapFactory.decodeFile(paths.get(i).getPath(), opts); opts.inSampleSize = calculateInSampleSize(opts, 720, 1280); opts.inInputShareable = true; Bitmap bitmap = BitmapFactory.decodeStream(is, null, opts); mBitmaps.add(new AddBitmaps(false, bitmap, null)); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } handler.sendEmptyMessage(HANDLER_PHOTOS); }; }.start(); break; case SELECT_PIC_BY_TACK_PHOTO: photoUri = Uri.parse(SharePrefUtil.getString( InfomationActivity.this, "photoUri", "")); if (photoUri == null) { Toast.makeText(this, "选择图片文件出错", Toast.LENGTH_LONG).show(); return; } cropImage(photoUri); break; case PHOTO_RESOULT: Bundle d = data.getExtras(); if (d != null) { Bitmap bm = d.getParcelable("data"); SimpleDateFormat sdf = new SimpleDateFormat("MMddhhmmss"); Date dt = new Date(); String picN = "cy" + sdf.format(dt) + ".jpg"; temp = new File(this.getCacheDir(), picN);// 放到 if (temp.exists()) temp.delete(); try { temp.createNewFile(); } catch (IOException e) { e.printStackTrace(); } try { bm.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream( temp)); } catch (FileNotFoundException e) { e.printStackTrace(); } if (!bm.isRecycled()) { bm.recycle(); bm = null; } } break; default: break; } } public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > reqHeight || width > reqWidth) { final int heightRatio = Math.round((float) height / (float) reqHeight); final int widthRatio = Math.round((float) width / (float) reqWidth); inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; } return inSampleSize; } private void cropImage(Uri uri) { ImageLoader.getInstance().loadImage(photoUri + "", new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { // TODO Auto-generated method stub super.onLoadingComplete(imageUri, view, loadedImage); // 拍照图片压缩 ByteArrayOutputStream stream = new ByteArrayOutputStream(); loadedImage.compress(Bitmap.CompressFormat.JPEG, 100, stream); try { int options = 100; while (stream.toByteArray().length / 1024 > 500) {// 判断如果图片大于500kb,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出 if (options > 0) { options -= 10; } stream.reset();// 重置baos即清空baos loadedImage.compress( Bitmap.CompressFormat.JPEG, options, stream);// 这里压缩50%,把压缩后的数据存放到baos中 if (stream.toByteArray().length / 1024 < 500) { break; } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } mBitmaps.remove(mAddBitmaps); mBitmaps.add(new AddBitmaps(false, loadedImage, null)); if (mBitmaps.size() < 9) { mBitmaps.add(mAddBitmaps); } gv_adapter.notifyDataSetChanged(); } }); } private static final int HANDLER_PHOTOS = 3; private Handler handler = new Handler() { public void handleMessage(android.os.Message msg) { switch (msg.what) { case HANDLER_PHOTOS: if (mBitmaps.size() < 9) { mBitmaps.add(mAddBitmaps); } closeProgressDialog(); gv_adapter.notifyDataSetChanged(); break; default: break; } }; }; BaseInfoBean baseInfoBean; private void getBaseInfo() { showProgressDialog("加载中"); Map headers=new HashMap<>(); headers.put("x-access-token",token); headers.put("User-Agent", WebSettings.getDefaultUserAgent(UIUtils.getContext())+" "+ UpdateVersionUtils.getVersionName()); String url1 = Url.getBaseInfo+patientcaseId; OkHttpUtils .get() .url(url1) .headers(headers) .build() .execute(new StringCallback() { @Override public void onError(Call call, Exception e, int id) { Log.d("okhttp",e.toString()); } @Override public void onResponse(String response, int id) { Log.d("okhttp",response+"response"); closeProgressDialog(); if(hasrealtoken(response)>0) { baseInfoBean= GsonTools.fromGsonToBean(response,BaseInfoBean.class); if(baseInfoBean.getData()!=null) { hindledata(); } } else if(hasrealtoken(response)==0) { gettokens(Url.getBaseInfo); } else if (hasrealtoken(response)==-1) { statract(); } else { BaseBeanNew baseBeanNew=GsonTools.fromGsonToBean(response,BaseBeanNew.class); ToastUtil.showToast(baseBeanNew.getMsg()); } } }); } public List imgs= new ArrayList<>();; private void hindledata() { // baseinfoDataStatus=baseInfoBean.getData().getDataStatus(); if("1".equals(baseInfoBean.getData().getSex())) { tab_rbn_1.setChecked(true); } else if("2".equals(baseInfoBean.getData().getSex())) { tab_rbn_2.setChecked(true); } if(!StringUtil.isEmpty(baseInfoBean.getData().getBirthday())) { birthdayPost=baseInfoBean.getData().getBirthday(); inittime=DateUtil.str2Date(birthdayPost, "yyyy-MM-dd"); pwTime.setTime(inittime); tv_bir.setText(birthdayPost.substring(0,4) +"("+DateUtil.getAgeByBirthdays(birthdayPost)+"岁"+")"); tv_birs.setText(DateUtil.getAgeByBirthdays(birthdayPost)+""); } // tv_bir.setText(baseInfoBean.getData().getBirthday()); phone.setText(baseInfoBean.getData().getMobile()); year1.setText(baseInfoBean.getData().getHbvYear()); month1.setText(baseInfoBean.getData().getHbvMonth()); if("0".equals(baseInfoBean.getData().getAlcoholFlag())) { tab_rbn_4.setChecked(true); } else if("1".equals(baseInfoBean.getData().getAlcoholFlag())) { tab_rbn_3.setChecked(true); } if("0".equals(baseInfoBean.getData().getNonAlcoholFlag())) { tab_rbn_6.setChecked(true); } else if("1".equals(baseInfoBean.getData().getNonAlcoholFlag())) { tab_rbn_5.setChecked(true); } // if("0".equals(baseInfoBean.getData().getDrinkFlag())) // { // tab_rbn_32.setChecked(true); // } // else if("1".equals(baseInfoBean.getData().getDrinkFlag())) // { // tab_rbn_31.setChecked(true); // } if("0".equals(baseInfoBean.getData().getDiagnosisAlcoholFlag())) { tab_rbn_42.setChecked(true); } else if("1".equals(baseInfoBean.getData().getDiagnosisAlcoholFlag())) { tab_rbn_41.setChecked(true); } if("0".equals(baseInfoBean.getData().getDrinkStopFlag())) { tab_rbn_52.setChecked(true); } else if("1".equals(baseInfoBean.getData().getDrinkStopFlag())) { tab_rbn_51.setChecked(true); } year2.setText(baseInfoBean.getData().getDrinkStopYear()); month2.setText(baseInfoBean.getData().getDrinkStopMonth()); if("0".equals(baseInfoBean.getData().getHbvFamilyFlag())) { tab_rbn_62.setChecked(true); } else if("1".equals(baseInfoBean.getData().getHbvFamilyFlag())) { tab_rbn_61.setChecked(true); } if("0".equals(baseInfoBean.getData().getHccFamilyFlag())) { tab_rbn_72.setChecked(true); } else if("1".equals(baseInfoBean.getData().getHccFamilyFlag())) { tab_rbn_71.setChecked(true); } if("0".equals(baseInfoBean.getData().getHtnMixFlag())) { tab_rbn_82.setChecked(true); } else if("1".equals(baseInfoBean.getData().getHtnMixFlag())) { tab_rbn_81.setChecked(true); } if("0".equals(baseInfoBean.getData().getDmMixFlag())) { tab_rbn_92.setChecked(true); } else if("1".equals(baseInfoBean.getData().getDmMixFlag())) { tab_rbn_91.setChecked(true); } if("0".equals(baseInfoBean.getData().getChdMixFlag())) { tab_rbn_102.setChecked(true); } else if("1".equals(baseInfoBean.getData().getChdMixFlag())) { tab_rbn_101.setChecked(true); } if("0".equals(baseInfoBean.getData().getCiMixFlag())) { tab_rbn_112.setChecked(true); } else if("1".equals(baseInfoBean.getData().getCiMixFlag())) { tab_rbn_111.setChecked(true); } if("0".equals(baseInfoBean.getData().getIchMixFlag())) { tab_rbn_122.setChecked(true); } else if("1".equals(baseInfoBean.getData().getIchMixFlag())) { tab_rbn_121.setChecked(true); } ed_other.setText(baseInfoBean.getData().getOtherMix()); if(baseInfoBean.getData().getImgPath()!=null&&baseInfoBean.getData().getImgPath().size()>0) { imgs.addAll(baseInfoBean.getData().getImgPath()); } if(baseInfoBean.getData().getImgPath()!=null) { for(imBean urlBean:baseInfoBean.getData().getImgPath()) { mBitmaps.add(new AddBitmaps(false, null, urlBean.getFileUrl())); } } if (mBitmaps.size() < 9) { mBitmaps.add(mAddBitmaps); } gv_adapter.notifyDataSetChanged(); } String token= SharePrefUtil.getString(getContext(),"x_access_token","");; private void gettokens(String url) { // showProgressDialog("加载中"); token= SharePrefUtil.getString(getContext(),"x_access_token",""); if(!StringUtil.isEmpty(token)) { handletoken(url); return; } sendJsonPostParamTokenMD5(InfomationActivity.this,new OnCallBackFromNet() { @Override public void onCallbackFromThread(String resultJson) { Log.d("okhttp",resultJson); SimpleBean simpleBean = GsonTools.fromGsonToBean(resultJson,SimpleBean.class); token=simpleBean.getData(); if(token==null) { ToastUtil.showMessage("Token异常"); return; } SharePrefUtil.saveString(getContext(),"x_access_token",token); handletoken(url); } @Override public void onCallBackFromThread(String resultJson, int resultCode) { } }); } private void handletoken(String url) { if(url.contains(Url.getBaseInfo)) { getBaseInfo(); } else if(url.contains(Url.youanupdate)) { updatedata(); } else { sendimg(url); } } private void sendpre() { if(tab_rbn_1.isChecked()||tab_rbn_2.isChecked()) { } else { ToastUtil.showToast("性别为必填项"); return; } if(StringUtil.isEmpty(tv_bir.getText().toString())||tv_bir.getText().toString().contains("出生")) { ToastUtil.showToast("患者入组时年龄范围为18~50岁,该患者年龄不合格"); return; } if (phone.getText()!=null&&!StringUtil.isEmpty(phone.getText().toString())&& !ValidateUtils.isPhoneAndMobile(phone.getText().toString())) {// 手机号码格式不正确 ToastUtil.showToast("请输入正确的手机号码"); return; } if(StringUtil.isEmpty(year1.getText().toString())||StringUtil.isEmpty(month1.getText().toString())) { ToastUtil.showToast("乙肝病史为必填项"); return; } if(tab_rbn_3.isChecked()||tab_rbn_4.isChecked()) { } else { ToastUtil.showToast("是否是酒精性脂肪肝为必填项"); return; } if(tab_rbn_5.isChecked()||tab_rbn_6.isChecked()) { } else { ToastUtil.showToast("是否是非酒精性脂肪肝为必填项"); return; } if(tab_rbn_61.isChecked()||tab_rbn_62.isChecked()) { } else { ToastUtil.showToast("家族中有无其他HBV感染者为必填项"); return; } if(tab_rbn_71.isChecked()||tab_rbn_72.isChecked()) { } else { ToastUtil.showToast("家族中有无肝细胞癌患者为必填项"); return; } if(tab_rbn_91.isChecked()||tab_rbn_92.isChecked()) { } else { ToastUtil.showToast("是否是糖尿病为必填项"); return; } if (mBitmaps.contains(mAddBitmaps)) { mBitmaps.remove(mAddBitmaps); } Log.d("okhttp",""+imgs.size()+" "+mBitmaps.size()); if(imgs.size()==mBitmaps.size()||mBitmaps.size()==0) { updatedata(); } else { new Thread(new Runnable() { @Override public void run() { for(AddBitmaps bitmaps:mBitmaps) { if (!StringUtil.isEmpty(bitmaps.getPath())) { continue; } String path="android"+System.currentTimeMillis(); Base64Util.saveBitmapAsJpg(bitmaps.getBitmap(),path); sendimg(path+".jpg"); } } }).start(); }}; private void sendimg(String fileKey) { // showProgressDialog("提交中"); Map paras=new HashMap<>(); paras.put("fileKey",fileKey); Map headers=new HashMap<>(); headers.put("x-access-token",token); headers.put("User-Agent", WebSettings.getDefaultUserAgent(UIUtils.getContext())+" "+ UpdateVersionUtils.getVersionName()); String url1 = Url.generatePresignedUrl; OkHttpUtils .get() .url(url1) .params(paras) .headers(headers) .build() .execute(new StringCallback() { @Override public void onError(Call call, Exception e, int id) { Log.d("okhttp",e.toString()); } @Override public void onResponse(String response, int id) { Log.d("okhttp",response+"sendimg"); // closeProgressDialog(); if(hasrealtoken(response)>0) { SimpleBean bean=GsonTools.fromGsonToBean(response,SimpleBean.class); if(bean.getData()!=null) { new Thread( new Runnable() { @Override public void run() { postfile(bean.getData(),fileKey); } } ).start(); } } else if(hasrealtoken(response)==0) { gettokens(fileKey); } else if (hasrealtoken(response)==-1) { statract(); } else { BaseBeanNew baseBeanNew=GsonTools.fromGsonToBean(response,BaseBeanNew.class); ToastUtil.showToast(baseBeanNew.getMsg()); } } }); } public void statract() { Intent intent=new Intent(InfomationActivity.this,ResearchActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("typename","myproject"); startActivity(intent); return; } public void postfile( String url, String localFile) { File file1 = BaseApplication.getInstance() .getApplicationContext().getExternalFilesDir(""); // 上传文件的URL File file = new File(file1,localFile); String contentType = "application/gdxz-stream"; // 通过签名URL上传文件。 OkHttpClient client = new OkHttpClient(); Request putRequest = new Request.Builder() .url(url) .put(RequestBody.create(MediaType.parse(contentType), file)) .build(); client.newCall(putRequest).enqueue(new okhttp3.Callback() { @Override public void onFailure(Call call, IOException e) { e.printStackTrace(); Log.d("okhttp ","IOException "+ e.toString()); String str=url.split("\\?")[0]; Log.d("okhttp ","str "+ str); imBean tag=new imBean(); tag.setFileUrl(str); // tag.setFileKey("/public处截取"); tag.setFileKey(str.replace("http://realyworld.oss-cn-beijing.aliyuncs.com/","")); imgs.add(tag); if(imgs.size()==mBitmaps.size()) { updatedata(); } } @Override public void onResponse(Call call, Response response) throws IOException { Log.d("okhttp ","response "+ response); String str=url.split("\\?")[0]; Log.d("okhttp ","str "+ str); imBean tag=new imBean(); tag.setFileUrl(str); // tag.setFileKey("/public处截取"); tag.setFileKey(str.replace("http://realyworld.oss-cn-beijing.aliyuncs.com/","")); imgs.add(tag); Log.d("okhttp ","imgs "+ imgs.size()+" "+mBitmaps.size()); if(imgs.size()==mBitmaps.size()) { updatedata(); } } }); } private void updatedata() { // showProgressDialog("提交中"); projectQueryForm4 pro=new projectQueryForm4(); pro.setPatientNo(patientNo); pro.setName(name); if(tab_rbn_1.isChecked()) { pro.setSex("1"); } else if(tab_rbn_2.isChecked()) { pro.setSex("2"); } if(!StringUtil.isEmpty(birthdayPost)) { pro.setBirthday(birthdayPost); } // if(!StringUtil.isEmpty(phone.getText().toString())) // { pro.setMobile(phone.getText().toString()); // } // if(!StringUtil.isEmpty(year1.getText().toString())) // { pro.setHbvYear(year1.getText().toString()); // } // if(!StringUtil.isEmpty(month1.getText().toString())) // { pro.setHbvMonth(month1.getText().toString()); // } if(tab_rbn_4.isChecked()) { pro.setAlcoholFlag("0"); } else if(tab_rbn_3.isChecked()) { pro.setAlcoholFlag("1"); } if(tab_rbn_5.isChecked()) { pro.setNonAlcoholFlag("1"); } else if(tab_rbn_6.isChecked()) { pro.setNonAlcoholFlag("0"); } // if(tab_rbn_32.isChecked()) // { // pro.setDrinkFlag("0"); // tab_rbn_32.setChecked(true); // } // else if(tab_rbn_31.isChecked()) // { // pro.setDrinkFlag("1"); // } if(tab_rbn_42.isChecked()) { pro.setDiagnosisAlcoholFlag("0"); } else if(tab_rbn_41.isChecked()) { pro.setDiagnosisAlcoholFlag("1"); } if(tab_rbn_52.isChecked()) { pro.setDrinkStopFlag("0"); } else if(tab_rbn_51.isChecked()) { pro.setDrinkStopFlag("1"); } // if(!StringUtil.isEmpty(year2.getText().toString())) // { pro.setDrinkStopYear(year2.getText().toString()); // } // if(!StringUtil.isEmpty(month2.getText().toString())) // { pro.setDrinkStopMonth(month2.getText().toString()); // } if(tab_rbn_62.isChecked()) { pro.setHbvFamilyFlag("0"); } else if(tab_rbn_61.isChecked()) { pro.setHbvFamilyFlag("1"); } if(tab_rbn_72.isChecked()) { pro.setHccFamilyFlag("0"); } else if(tab_rbn_71.isChecked()) { pro.setHccFamilyFlag("1"); } if(tab_rbn_82.isChecked()) { pro.setHtnMixFlag("0"); } else if(tab_rbn_81.isChecked()) { pro.setHtnMixFlag("1"); } if(tab_rbn_92.isChecked()) { pro.setDmMixFlag("0"); } else if(tab_rbn_91.isChecked()) { pro.setDmMixFlag("1"); } if(tab_rbn_102.isChecked()) { pro.setChdMixFlag("0"); } else if(tab_rbn_101.isChecked()) { pro.setChdMixFlag("1"); } if(tab_rbn_112.isChecked()) { pro.setCiMixFlag("0"); } else if(tab_rbn_111.isChecked()) { pro.setCiMixFlag("1"); } if(tab_rbn_122.isChecked()) { pro.setIchMixFlag("0"); } else if(tab_rbn_121.isChecked()) { pro.setIchMixFlag("1"); } // if(!StringUtil.isEmpty(ed_other.getText().toString())) // { pro.setOtherMix(ed_other.getText().toString()); // } if(baseinfoDataStatus!=null) { pro.setBaseinfoDataStatus(baseinfoDataStatus); } pro.setImgPath(imgs); pro.setPatientcaseId(patientcaseId); Map headers=new HashMap<>(); headers.put("x-access-token",token); headers.put("User-Agent", WebSettings.getDefaultUserAgent(UIUtils.getContext())+" "+ UpdateVersionUtils.getVersionName()); Log.d("okhttp",""+new Gson().toJson(pro)); OkHttpUtils .postString() .url(Url.youanupdate) .headers(headers) .content(new Gson().toJson(pro)) .mediaType(MediaType.parse("application/json; charset=utf-8")) .build() .execute(new StringCallback() { @Override public void onError(Call call, Exception e, int id) { Log.d("okhttp",e.toString()); } @Override public void onResponse(String response, int id) { Log.d("okhttp",response+"response"); // closeProgressDialog(); if(hasrealtoken(response)>0) { finish(); } else if(hasrealtoken(response)==0) { gettokens(Url.youanupdate); } else if (hasrealtoken(response)==-1) { statract(); } else { BaseBeanNew baseBeanNew=GsonTools.fromGsonToBean(response,BaseBeanNew.class); ToastUtil.showToast(baseBeanNew.getMsg()); } } }); } }