@Override public void onLoad(final PullableListView pullableListView) { Map<String, String> parmas = new HashMap<String, String>(); page++; parmas.put("page", String.valueOf(page)); parmas.put("rows", "10"); parmas.put("accessToken", ClientUtil.getToken()); parmas.put("uid", editor.get("uid", "")); parmas.put("userTp", editor.get("userType", "")); parmas.put("status", "bbs"); OpenApiService.getInstance(consultationListAllFragment.getContext()) .getPatientCaseList( mQueue, parmas, new Response.Listener<String>() { @Override public void onResponse(String arg0) { try { JSONObject responses = new JSONObject(arg0); if (responses.getInt("rtnCode") == 1) { JSONArray infos = responses.getJSONArray("pcases"); for (int i = 0; i < infos.length(); i++) { JSONObject info = infos.getJSONObject(i); CasesTo pcasesTo = new CasesTo(); pcasesTo.setId(info.getString("id")); pcasesTo.setStatus(info.getString("status")); pcasesTo.setStatus_des(info.getString("status_desc")); pcasesTo.setDestination(info.getString("destination")); String createTime = info.getString("create_time"); if (createTime.equals("null")) { pcasesTo.setCreate_time(0); } else { pcasesTo.setCreate_time(Long.parseLong(createTime)); } pcasesTo.setTitle(info.getString("title")); pcasesTo.setDepart_id(info.getString("depart_id")); pcasesTo.setDoctor_userid(info.getString("doctor_userid")); String consult_fee = info.getString("consult_fee"); if (consult_fee.equals("null")) { pcasesTo.setConsult_fee("0"); } else { pcasesTo.setConsult_fee(consult_fee); } pcasesTo.setPatient_name(info.getString("patient_name")); pcasesTo.setDoctor_name(info.getString("doctor_name")); pcasesTo.setExpert_userid(info.getString("expert_userid")); pcasesTo.setExpert_name(info.getString("expert_name")); pcasesTo.setProblem(info.getString("problem")); pcasesTo.setConsult_tp(info.getString("consult_tp")); pcasesTo.setOpinion(info.getString("opinion")); PatientTo patientTo = new PatientTo(); JSONObject pObject = info.getJSONObject("user"); patientTo.setAddress(pObject.getString("address")); patientTo.setId(pObject.getInt("id") + ""); patientTo.setState(pObject.getString("state")); patientTo.setTp(pObject.getString("tp")); patientTo.setUserBalance(pObject.getString("userBalance")); patientTo.setMobile_ph(pObject.getString("mobile_ph")); patientTo.setPwd(pObject.getString("pwd")); patientTo.setReal_name(pObject.getString("real_name")); patientTo.setSex(pObject.getString("sex")); patientTo.setBirth_year(pObject.getString("birth_year")); patientTo.setBirth_month(pObject.getString("birth_month")); patientTo.setBirth_day(pObject.getString("birth_day")); patientTo.setIdentity_id(pObject.getString("identity_id")); patientTo.setArea_province(pObject.getString("area_province")); patientTo.setArea_city(pObject.getString("area_city")); patientTo.setArea_county(pObject.getString("area_county")); patientTo.setIcon_url(pObject.getString("icon_url")); patientTo.setModify_time(pObject.getString("modify_time")); pcasesTo.setPatient(patientTo); patientList.add(pcasesTo); } if (infos.length() == 10) { hasMore = true; } else { hasMore = false; } Message msg = handler.obtainMessage(); msg.what = 1; msg.obj = pullableListView; handler.sendMessage(msg); } else if (responses.getInt("rtnCode") == 10004) { hasMore = true; Message msg = handler.obtainMessage(); msg.what = 1; msg.obj = pullableListView; handler.sendMessage(msg); Toast.makeText( consultationListAllFragment.getContext(), responses.getString("rtnMsg"), Toast.LENGTH_SHORT) .show(); LoginActivity.setHandler( new ConsultationCallbackHandler() { @Override public void onSuccess(String rspContent, int statusCode) { initData(); } @Override public void onFailure(ConsultationCallbackException exp) {} }); startActivity( new Intent(consultationListAllFragment.getContext(), LoginActivity.class)); } else { hasMore = true; Message msg = handler.obtainMessage(); msg.what = 1; msg.obj = pullableListView; handler.sendMessage(msg); Toast.makeText( consultationListAllFragment.getContext(), responses.getString("rtnMsg"), Toast.LENGTH_SHORT) .show(); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError arg0) { hasMore = true; Message msg = handler.obtainMessage(); msg.what = 1; msg.obj = pullableListView; handler.sendMessage(msg); Toast.makeText( consultationListAllFragment.getContext(), "网络连接失败,请稍后重试", Toast.LENGTH_SHORT) .show(); } }); }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case 0: if (data != null) { Bundle extras = data.getExtras(); if (extras != null) { final Bitmap photo = extras.getParcelable("data"); File file = new File( Environment.getExternalStorageDirectory() + File.separator + "photo.jpg"); // 将要保存图片的路径 try { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file)); photo.compress(Bitmap.CompressFormat.JPEG, 100, bos); bos.flush(); bos.close(); File[] files = new File[1]; files[0] = file; Map<String, String> params = new HashMap<String, String>(); params.put("accessToken", ClientUtil.getToken()); params.put("uid", editor.get("uid", "")); CommonUtil.showLoadingDialog(mineLayout.getContext()); OpenApiService.getInstance(mineLayout.getContext()) .getUploadFiles( ClientUtil.GET_USER_ICON_URL, mineLayout.getContext(), new ConsultationCallbackHandler() { @Override public void onSuccess(String rspContent, int statusCode) { CommonUtil.closeLodingDialog(); photos.setImageBitmap(photo); JSONObject jsonObject; try { jsonObject = new JSONObject(rspContent); editor.put("icon_url", jsonObject.getString("filePath")); } catch (JSONException e) { e.printStackTrace(); } Toast.makeText(mineLayout.getContext(), "图片上传成功", Toast.LENGTH_LONG) .show(); } @Override public void onFailure(ConsultationCallbackException exp) { Toast.makeText(mineLayout.getContext(), "图片上传失败,请重新上传", Toast.LENGTH_LONG) .show(); CommonUtil.closeLodingDialog(); } }, files, params); } catch (IOException e) { e.printStackTrace(); } } } break; case 1: if (resultCode == Activity.RESULT_OK) { initDate(); } break; default: break; } super.onActivityResult(requestCode, resultCode, data); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.mine_my_info_icon_layout: Intent intent = new Intent(mineLayout.getContext(), MyInfoActivity.class); startActivity(intent); break; case R.id.mine_info_imageView: startActivityForResult(new Intent(mineLayout.getContext(), SelectHeadPicActivity.class), 0); break; case R.id.mine_my_pay_layout: Intent intent4 = new Intent(mineLayout.getContext(), MyAccountActivity.class); // intent4.putExtra("headerTitle", "我的资料"); startActivityForResult(intent4, 1); break; case R.id.mine_my_share_layout: break; case R.id.mine_my_jion_layout: Intent intent3 = new Intent(mineLayout.getContext(), UpdateMyInfoActivity.class); intent3.putExtra("headerTitle", "我的资料"); intent3.putExtra("infos", ""); startActivityForResult(intent3, 1); break; case R.id.mine_my_invitation_layout: startActivity(new Intent(mineLayout.getContext(), InvitationActivity.class)); break; case R.id.mine_my_feedback_layout: startActivity(new Intent(mineLayout.getContext(), FeedBackActivity.class)); break; case R.id.mine_my_help_layout: break; case R.id.mine_my_doctor_info_layout: // 进入修改医生信息的界面 Intent intent2 = new Intent(mineLayout.getContext(), UpdateMyInfoActivity.class); intent2.putExtra("headerTitle", "修改我的资料"); intent2.putExtra("infos", doctorInfo); startActivityForResult(intent2, 1); break; case R.id.mine_info_logout_btn: ClientUtil.setToken(""); editor.put("refreshToken", ""); LoginActivity.setHandler( new ConsultationCallbackHandler() { @Override public void onSuccess(String rspContent, int statusCode) { Intent intent = new Intent(mineLayout.getContext(), HomeActivity.class); intent.putExtra("selectId", 3); startActivity(intent); ((Activity) mineLayout.getContext()).finish(); } @Override public void onFailure(ConsultationCallbackException exp) {} }); startActivity(new Intent(mineLayout.getContext(), LoginActivity.class)); break; default: break; } }
private void initLayout() { header_text = (TextView) mineLayout.findViewById(R.id.header_text); header_text.setText("我的"); header_text.setTextSize(20); header_right = (TextView) mineLayout.findViewById(R.id.header_right); header_right.setText("设置"); header_right.setVisibility(View.VISIBLE); header_right.setTextSize(18); header_right.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(mineLayout.getContext(), MyInfoSetActivity.class); startActivity(intent); } }); doctor_layout = (LinearLayout) mineLayout.findViewById(R.id.mine_my_doctor_info_layout); doctor_layout.setOnClickListener(this); photos = (ImageView) mineLayout.findViewById(R.id.mine_info_imageView); photos.setOnClickListener(this); myInfo_text = (TextView) mineLayout.findViewById(R.id.mine_info_my_text); myInfo_text.setTextSize(18); userName = (TextView) mineLayout.findViewById(R.id.mine_info_my_name_text); userName.setTextSize(18); phone = (TextView) mineLayout.findViewById(R.id.mine_info_my_phone_text); phone.setTextSize(16); pay_text = (TextView) mineLayout.findViewById(R.id.mine_info_pay_text); pay_text.setTextSize(18); blance_text = (TextView) mineLayout.findViewById(R.id.mine_info_blance_text); blance_text.setTextSize(18); jion_text = (TextView) mineLayout.findViewById(R.id.mine_info_jion_text); jion_text.setTextSize(18); share_text = (TextView) mineLayout.findViewById(R.id.mine_info_share_text); share_text.setTextSize(18); invitation_text = (TextView) mineLayout.findViewById(R.id.mine_info_invitation_text); invitation_text.setTextSize(18); feedback_text = (TextView) mineLayout.findViewById(R.id.mine_info_feedback_text); feedback_text.setTextSize(18); help_text = (TextView) mineLayout.findViewById(R.id.mine_info_help_text); help_text.setTextSize(18); title = (TextView) mineLayout.findViewById(R.id.mine_info_doctor_info_title_text); title.setTextSize(16); hospital = (TextView) mineLayout.findViewById(R.id.mine_info_doctor_info_hospital_text); hospital.setTextSize(16); grade = (TextView) mineLayout.findViewById(R.id.mine_info_doctor_info_grede_text); grade.setTextSize(16); status = (TextView) mineLayout.findViewById(R.id.mine_info_doctor_info_status_text); status.setTextSize(16); description = (TextView) mineLayout.findViewById(R.id.mine_info_doctor_info_desc_text); description.setTextSize(16); info_layout = (LinearLayout) mineLayout.findViewById(R.id.mine_my_info_icon_layout); info_layout.setOnClickListener(this); pay_layout = (LinearLayout) mineLayout.findViewById(R.id.mine_my_pay_layout); pay_layout.setOnClickListener(this); jion_layout = (LinearLayout) mineLayout.findViewById(R.id.mine_my_jion_layout); jion_layout.setOnClickListener(this); line = (LinearLayout) mineLayout.findViewById(R.id.mine_my_jion_layout_line); if (!editor.get("userType", "").equals("0")) { line.setVisibility(View.GONE); jion_layout.setVisibility(View.GONE); } share_layout = (LinearLayout) mineLayout.findViewById(R.id.mine_my_share_layout); share_layout.setOnClickListener(this); invitation_layout = (LinearLayout) mineLayout.findViewById(R.id.mine_my_invitation_layout); invitation_layout.setOnClickListener(this); if (editor.get("userType", "").equals("0")) { invitation_layout.setVisibility(View.GONE); } feedback_layout = (LinearLayout) mineLayout.findViewById(R.id.mine_my_feedback_layout); feedback_layout.setOnClickListener(this); help_layout = (LinearLayout) mineLayout.findViewById(R.id.mine_my_help_layout); help_layout.setOnClickListener(this); logoutBtn = (Button) mineLayout.findViewById(R.id.mine_info_logout_btn); logoutBtn.setTextSize(18); logoutBtn.setOnClickListener(this); logoutBtn.setOnTouchListener( new ButtonListener() .setImage( getResources().getDrawable(R.drawable.mine_logout_btn_shape), getResources().getDrawable(R.drawable.mine_logout_press_btn_shape)) .getBtnTouchListener()); }
@Override public void handleMessage(Message msg) { super.handleMessage(msg); String icon_url = (String) msg.obj; int photoId = 0; if (editor.get("userType", "").equals("1")) { photos.setBackgroundResource(R.drawable.photo_primary); photoId = R.drawable.photo_primary; } else if (editor.get("userType", "").equals("2")) { photos.setBackgroundResource(R.drawable.photo_expert); photoId = R.drawable.photo_expert; } else if (editor.get("userType", "").equals("0")) { photos.setBackgroundResource(R.drawable.photo_patient); photoId = R.drawable.photo_patient; } if (!"null".equals(icon_url) && !"".equals(icon_url) && null != icon_url) { ImageListener listener = ImageLoader.getImageListener(photos, photoId, photoId); mImageLoader.get(icon_url, listener); } if (!"null".equals(userTo.getUser_name()) && !"".equals(userTo.getUser_name()) && userTo.getUser_name() != null) { userName.setVisibility(View.VISIBLE); phone.setVisibility(View.VISIBLE); userName.setText(userTo.getUser_name()); phone.setText(editor.get("phone", "")); } else { userName.setVisibility(View.GONE); phone.setVisibility(View.GONE); myInfo_text.setText("请填写个人信息"); } if (!editor.get("userType", "").equals("0")) { line.setVisibility(View.GONE); jion_layout.setVisibility(View.GONE); } else { line.setVisibility(View.VISIBLE); jion_layout.setVisibility(View.VISIBLE); } if (editor.get("userType", "").equals("0")) { invitation_layout.setVisibility(View.GONE); } else { invitation_layout.setVisibility(View.VISIBLE); } blance_text.setText("余额" + (float) blance / 100 + "元"); if (null != doctorInfo && !"null".equals(doctorInfo) && !"".equals(doctorInfo)) { doctor_layout.setVisibility(View.VISIBLE); line.setVisibility(View.GONE); jion_layout.setVisibility(View.GONE); try { JSONObject jsonObject = new JSONObject(doctorInfo); title.setText( jsonObject.getString("depart_name") + "|" + jsonObject.getString("title")); hospital.setText(jsonObject.getString("hospital_name")); if (jsonObject.getString("grade").equals("1")) { status.setVisibility(View.INVISIBLE); if (jsonObject.getString("approve_status").equals("0")) { grade.setText("待认证"); grade.setTextColor(Color.parseColor("#990000")); description.setVisibility(View.GONE); } else if (jsonObject.getString("approve_status").equals("1")) { grade.setText("已认证"); grade.setTextColor(Color.parseColor("#006633")); description.setVisibility(View.GONE); } else if (jsonObject.getString("approve_status").equals("2")) { grade.setText("未认证通过"); grade.setTextColor(Color.parseColor("#990000")); description.setText(jsonObject.getString("approve_desc")); } } else { grade.setText(jsonObject.getString("expert_grade")); if (jsonObject.getString("approve_status").equals("0")) { status.setText("待认证"); description.setVisibility(View.GONE); } else if (jsonObject.getString("approve_status").equals("1")) { status.setText("已认证"); status.setTextColor(Color.parseColor("#006633")); description.setVisibility(View.GONE); } else if (jsonObject.getString("approve_status").equals("2")) { status.setText("未认证通过"); description.setText(jsonObject.getString("approve_desc")); } } } catch (JSONException e) { e.printStackTrace(); } } else { doctor_layout.setVisibility(View.GONE); line.setVisibility(View.VISIBLE); jion_layout.setVisibility(View.VISIBLE); } }
private void initDate() { Map<String, String> parmas = new HashMap<String, String>(); parmas.put("uid", editor.get("uid", "")); parmas.put("accessToken", ClientUtil.getToken()); CommonUtil.showLoadingDialog(mineLayout.getContext()); OpenApiService.getInstance(mineLayout.getContext()) .getUserInfo( mQueue, parmas, new Response.Listener<String>() { @Override public void onResponse(String arg0) { CommonUtil.closeLodingDialog(); try { JSONObject responses = new JSONObject(arg0); if (responses.getInt("rtnCode") == 1) { userTo = new UserTo(); JSONObject jsonObject = new JSONObject(arg0); JSONObject object = jsonObject.getJSONObject("user"); userTo.setIcon_url(object.getString("icon_url")); userTo.setUser_name(object.getString("real_name")); Message msg = new Message(); msg.obj = object.getString("icon_url"); if (object .getJSONObject("userBalance") .getString("current_balance") .equals("null")) { blance = 0; } else { blance = object.getJSONObject("userBalance").getLong("current_balance"); } doctorInfo = jsonObject.getString("doctor"); handler.dispatchMessage(msg); } else if (responses.getInt("rtnCode") == 10004) { Toast.makeText( mineLayout.getContext(), responses.getString("rtnMsg"), Toast.LENGTH_SHORT) .show(); LoginActivity.setHandler( new ConsultationCallbackHandler() { @Override public void onSuccess(String rspContent, int statusCode) { initDate(); } @Override public void onFailure(ConsultationCallbackException exp) {} }); startActivity(new Intent(mineLayout.getContext(), LoginActivity.class)); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError arg0) { CommonUtil.closeLodingDialog(); Toast.makeText(mineLayout.getContext(), "网络连接失败,请稍后重试", Toast.LENGTH_SHORT).show(); } }); }
@Override public void onLoad(final PullableListView pullableListView) { Map<String, String> parmas = new HashMap<String, String>(); page++; parmas.put("page", String.valueOf(page)); parmas.put("rows", "10"); parmas.put("accessToken", ClientUtil.getToken()); parmas.put("uid", editor.get("uid", "")); OpenApiService.getInstance(PayRecordActivity.this) .getMyAcountPayRecord( mQueue, parmas, new Response.Listener<String>() { @Override public void onResponse(String arg0) { try { JSONObject responses = new JSONObject(arg0); if (responses.getInt("rtnCode") == 1) { JSONArray infos = responses.getJSONArray("payments"); for (int i = 0; i < infos.length(); i++) { JSONObject info = infos.getJSONObject(i); PayRecordTo payRecordTo = new PayRecordTo(); payRecordTo.setAmount(info.getString("amount")); payRecordTo.setCreate_time(info.getString("create_time")); payRecordTo.setType(info.getString("status")); JSONObject caseJsonObject = info.getJSONObject("patientCase"); CasesTo casesTo = new CasesTo(); casesTo.setTitle(caseJsonObject.getString("title")); casesTo.setDoctor_name(caseJsonObject.getString("doctor_name")); casesTo.setExpert_name(caseJsonObject.getString("expert_name")); if (!"".equals(caseJsonObject.getString("create_time")) && !"null".equals(caseJsonObject.getString("create_time"))) { casesTo.setCreate_time( Long.parseLong(caseJsonObject.getString("create_time"))); } else { casesTo.setCreate_time(0); } payRecordTo.setCasesTo(casesTo); payRecordTos.add(payRecordTo); } if (infos.length() == 10) { hasMore = true; } else { hasMore = false; } Message msg = handler.obtainMessage(); msg.what = 1; msg.obj = pullableListView; handler.sendMessage(msg); } else if (responses.getInt("rtnCode") == 10004) { hasMore = true; Message msg = handler.obtainMessage(); msg.what = 1; msg.obj = pullableListView; handler.sendMessage(msg); Toast.makeText( PayRecordActivity.this, responses.getString("rtnMsg"), Toast.LENGTH_SHORT) .show(); LoginActivity.setHandler( new ConsultationCallbackHandler() { @Override public void onSuccess(String rspContent, int statusCode) { initDate(); } @Override public void onFailure(ConsultationCallbackException exp) {} }); startActivity(new Intent(PayRecordActivity.this, LoginActivity.class)); } else { hasMore = true; Message msg = handler.obtainMessage(); msg.what = 1; msg.obj = pullableListView; handler.sendMessage(msg); Toast.makeText( PayRecordActivity.this, responses.getString("rtnMsg"), Toast.LENGTH_SHORT) .show(); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError arg0) { hasMore = true; Message msg = handler.obtainMessage(); msg.what = 1; msg.obj = pullableListView; handler.sendMessage(msg); Toast.makeText(PayRecordActivity.this, "网络连接失败,请稍后重试", Toast.LENGTH_SHORT).show(); } }); }
@Override protected void onActivityResult(int requestCode, int resultCode, final Intent data) { switch (requestCode) { case 0: if (data != null) { String photoPath = data.getStringExtra("bitmap"); List<String> paths = pathMap.get(currentPosition); List<String> bigPaths = bigPathMap.get(currentPosition); if (null == paths) { paths = new ArrayList<String>(); paths.add(photoPath); pathMap.put(currentPosition, paths); } else { if (!paths.contains(photoPath)) { paths.add(photoPath); } } if (null == bigPaths) { bigPaths = new ArrayList<String>(); bigPaths.add(photoPath); bigPathMap.put(currentPosition, bigPaths); } else { if (!bigPaths.contains(photoPath)) { bigPaths.add(photoPath); } } showRightLayout(currentPosition); } break; case 1: if (resultCode == Activity.RESULT_OK) { Map<String, String> parmas = new HashMap<String, String>(); parmas.put("id", idMap.get(currentPosition).get(data.getIntExtra("index", 0))); parmas.put("accessToken", ClientUtil.getToken()); parmas.put("uid", editor.get("uid", "")); CommonUtil.showLoadingDialog(CaseTestActivity.this); OpenApiService.getInstance(CaseTestActivity.this) .getDeleteCaseImage( mQueue, parmas, new Response.Listener<String>() { @Override public void onResponse(String arg0) { CommonUtil.closeLodingDialog(); try { JSONObject responses = new JSONObject(arg0); if (responses.getInt("rtnCode") == 1) { pathMap.get(currentPosition).remove(data.getIntExtra("index", 0)); idMap.get(currentPosition).remove(data.getIntExtra("index", 0)); showRightLayout(currentPosition); } else if (responses.getInt("rtnCode") == 10004) { Toast.makeText( CaseTestActivity.this, responses.getString("rtnMsg"), Toast.LENGTH_SHORT) .show(); LoginActivity.setHandler( new ConsultationCallbackHandler() { @Override public void onSuccess(String rspContent, int statusCode) {} @Override public void onFailure(ConsultationCallbackException exp) {} }); startActivity(new Intent(CaseTestActivity.this, LoginActivity.class)); } else { Toast.makeText( CaseTestActivity.this, responses.getString("rtnMsg"), Toast.LENGTH_SHORT) .show(); } } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError arg0) { CommonUtil.closeLodingDialog(); Toast.makeText(CaseTestActivity.this, "网络连接失败,请稍后重试", Toast.LENGTH_SHORT) .show(); } }); } break; default: break; } super.onActivityResult(requestCode, resultCode, data); }