Exemplo n.º 1
0
  private void analyzeJson(String json) {
    // TODO Auto-generated method stub
    try {
      JSONObject jsonObject = new JSONObject(json);
      JSONObject data = jsonObject.getJSONObject("Data");
      SubjectID = data.getString("SubjectID");
      // SharedPrefsUtil.putValue(Constants.SUBJECTID, SubjectID);
      String responser = data.getString("responser");
      if (null == responser || responser.equals("") || responser.equals("null")) {
        ToastUtil.showMessage("当前没有医生在线...");
        return;
      }
      TimerService.count = 0;
      docInfoBean = new Gson().fromJson(responser, DocInfoBean.class);
      saveDoc(docInfoBean);
      final ChatInfoBean chatInfoBean = new ChatInfoBean();
      chatInfoBean.setSubjectID(SubjectID);
      chatInfoBean.setDocInfoBeanId(docInfoBean.getVoipAccount());
      // SharedPrefsUtil.putValue(Constants.CHATINFO,
      // chatInfoBean.toString());
      if (CCPHelper.getInstance().getDevice() == null) {
        myProgressDialog = new MyProgressDialog(context);
        myProgressDialog.setMessage("正在连接对话....");
        myProgressDialog.show();
        CCPHelper.getInstance()
            .registerCCP(
                new CCPHelper.RegistCallBack() {
                  @Override
                  public void onRegistResult(int reason, String msg) {
                    // Log.i("XXX", String.format("%d, %s",
                    // reason, msg));
                    if (reason == 8192) {
                      LogUtil.i(TAG, "通讯云登录成功");
                      myProgressDialog.dismiss();
                      goIntent(chatInfoBean);
                    } else {
                      LogUtil.i(TAG, "通讯云登录失败");
                      myProgressDialog.dismiss();
                      ToastUtil.showMessage("对话连接失败....");
                    }
                  }
                });
      } else {

        goIntent(chatInfoBean);
      }
    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }