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(); } }
/** JS调用的方法 */ @JavascriptInterface public void goToReport(String studyid) { userModel = new Gson().fromJson(SharedPrefsUtil.getValue(Constants.USERMODEL, null), UserModel.class); Log.i(TAG, "goToReport()"); Intent intent = new Intent(); if (!DBUtilsHelper.getInstance().isOnline()) { requestDoctor(studyid); } else { ToastUtil.showMessage("您当前正在进行在线咨询,结束后才能进行报告解读哦"); SharedPrefsUtil.putValue(Constants.CHECKEDID_RADIOBT, 1); Intent intent2 = new Intent(WebViewActivity.this, MainActivity.class); intent2.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent2.putExtra("news", "news"); startActivity(intent2); finish(); return; } startActivity(intent); }