@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 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; } }
@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); }
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); }