private void initLayout() {
    ((PullToRefreshLayout)
            consultationListAllFragment.findViewById(R.id.consulation_list_all_refresh_view))
        .setOnRefreshListener(
            new OnRefreshListener() {

              @Override
              public void onRefresh(final PullToRefreshLayout pullToRefreshLayout) {
                Map<String, String> parmas = new HashMap<String, String>();
                parmas.put("page", "1");
                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");
                                patientList.clear();
                                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) {
                                  patientListView.setHasMoreData(true);
                                } else {
                                  patientListView.setHasMoreData(false);
                                }
                                Message msg = handler.obtainMessage();
                                msg.what = 0;
                                msg.obj = pullToRefreshLayout;
                                handler.sendMessage(msg);
                              } else if (responses.getInt("rtnCode") == 10004) {
                                Message msg = handler.obtainMessage();
                                msg.what = 2;
                                msg.obj = pullToRefreshLayout;
                                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 {
                                Message msg = handler.obtainMessage();
                                msg.what = 2;
                                msg.obj = pullToRefreshLayout;
                                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) {
                            Message msg = handler.obtainMessage();
                            msg.what = 2;
                            msg.obj = pullToRefreshLayout;
                            handler.sendMessage(msg);
                            Toast.makeText(
                                    consultationListAllFragment.getContext(),
                                    "网络连接失败,请稍后重试",
                                    Toast.LENGTH_SHORT)
                                .show();
                          }
                        });
              }
            });
    patientListView =
        (PullableListView)
            consultationListAllFragment.findViewById(R.id.consulation_list_all_listView);
    patientListView.setAdapter(myAdapter);
    patientListView.setOnLoadListener(this);
    patientListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent =
                new Intent(consultationListAllFragment.getContext(), CaseInfoNewActivity.class);
            intent.putExtra("caseId", patientList.get(position).getId());
            startActivityForResult(intent, 0);
          }
        });
    MyBroadcastReceiver.setHander(
        new ConsultationCallbackHandler() {

          @Override
          public void onSuccess(String rspContent, int statusCode) {
            patientList.clear();
            initData();
            myAdapter.notifyDataSetChanged();
          }

          @Override
          public void onFailure(ConsultationCallbackException exp) {}
        });
  }
  private void initView() {
    title_text = (TextView) findViewById(R.id.header_text);
    title_text.setText("消费记录");
    title_text.setTextSize(20);

    back_layout = (LinearLayout) findViewById(R.id.header_layout_lift);
    back_layout.setVisibility(View.VISIBLE);
    back_text = (TextView) findViewById(R.id.header_text_lift);
    back_text.setTextSize(18);
    back_layout.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            InputMethodManager imm =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            if (imm.isActive()) {
              imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
            }
            finish();
          }
        });

    titleAmount = (TextView) findViewById(R.id.my_acount_pay_title_amount_text);
    titleAmount.setTextSize(18);
    titleStatus = (TextView) findViewById(R.id.my_acount_pay_title_status_text);
    titleStatus.setTextSize(18);
    titleStatus.setText("状态");
    titleTime = (TextView) findViewById(R.id.my_acount_pay_title_time_text);
    titleTime.setTextSize(18);

    ((PullToRefreshLayout) findViewById(R.id.my_acount_pay_list_refresh_view))
        .setOnRefreshListener(
            new OnRefreshListener() {

              @Override
              public void onRefresh(final PullToRefreshLayout pullToRefreshLayout) {
                Map<String, String> parmas = new HashMap<String, String>();
                parmas.put("uid", editor.get("uid", ""));
                parmas.put("accessToken", ClientUtil.getToken());
                parmas.put("page", "1");
                parmas.put("rows", "10");
                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) {
                                payRecordTos.clear();
                                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) {
                                  listView.setHasMoreData(true);
                                } else {
                                  listView.setHasMoreData(false);
                                }
                                Message msg = handler.obtainMessage();
                                msg.what = 0;
                                msg.obj = pullToRefreshLayout;
                                handler.sendMessage(msg);
                              } else if (responses.getInt("rtnCode") == 10004) {
                                Message msg = handler.obtainMessage();
                                msg.what = 2;
                                msg.obj = pullToRefreshLayout;
                                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 {
                                Message msg = handler.obtainMessage();
                                msg.what = 2;
                                msg.obj = pullToRefreshLayout;
                                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) {
                            Message msg = handler.obtainMessage();
                            msg.what = 2;
                            msg.obj = pullToRefreshLayout;
                            handler.sendMessage(msg);
                            Toast.makeText(
                                    PayRecordActivity.this, "网络连接失败,请稍后重试", Toast.LENGTH_SHORT)
                                .show();
                          }
                        });
              }
            });
    listView = (PullableListView) findViewById(R.id.my_acount_pay_title_list_listView);
    listView.setAdapter(myAdapter);
    listView.setOnLoadListener(this);
    listView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ViewHolder viewHolder = (ViewHolder) view.getTag();
            if (viewHolder.caseLayout.isShown()) {
              viewHolder.caseLayout.setVisibility(View.GONE);
              viewHolder.icon.setImageResource(R.drawable.pay_close);
            } else {
              viewHolder.caseLayout.setVisibility(View.VISIBLE);
              viewHolder.icon.setImageResource(R.drawable.pay_open);
            }
          }
        });
  }