/** * (non-Javadoc) * * @see android.os.Handler#handleMessage(android.os.Message) */ @Override public void handleMessage(Message msg) { Logger.i(LoginActivity.class, "[登录页面-登录handler]:msg.what:", msg.what); LoginActivity ac = activity.get(); if (ac != null) { ac.loadingoverlay.setVisibility(View.INVISIBLE); switch (msg.what) { case ThreadCommStateCode.LOGIN_SUCCESS: userInfoBean = (UserInfoBean) msg.obj; if (userInfoBean == null) { Toast.makeText(ac.getApplicationContext(), "登录失败!", Toast.LENGTH_SHORT).show(); break; } // 上传手机环境信息 (new MobileEnvUploadBiz(ac, null)).execute(); // 注册推送服务 YtApplication.getInstance().registerPushReceiver(); YtApplication.getInstance().registerNetworkReceiver(); Intent intent1 = null; // zyong test // userInfoBean.setPhone_bind(UserInfoBean.PHONEBIND); // userInfoBean.setPhone_bind(UserInfoBean.PHONENOTBIND); if (userInfoBean.getPhone_bind() == null || userInfoBean.getPhone_bind().equals(UserInfoBean.PHONENOTBIND)) { intent1 = new Intent(ac.getApplication(), MainNotBindActivity.class); } else { intent1 = new Intent(ac.getApplication(), MainActivity.class); } YtApplication.getInstance().setUserInfoCache(userInfoBean); intent1.putExtra(ActivityCommConstant.USER_INFO, userInfoBean); ac.startActivity(intent1); ac.finish(); break; case ThreadCommStateCode.TOKEN_INVALID: Toast.makeText(ac.getApplicationContext(), (String) msg.obj, Toast.LENGTH_SHORT).show(); ProxyBiz.startCleanData(); ac.passwordET.setText(GlobleConstants.EMPTY_STR); break; case ThreadCommStateCode.LOGIN_FAILED: case ThreadCommStateCode.COMMON_FAILED: default: Toast.makeText(ac.getApplicationContext(), (String) msg.obj, Toast.LENGTH_SHORT).show(); break; } } }
/** * (非 Javadoc) * * @see com.yutong.axxc.parents.connect.http.packet.AbstractRes#parseCorrectMsg(java.lang.String) */ @Override boolean parseCorrectMsg(String jsonString) { JSONObject loginRes; try { loginRes = new JSONObject(jsonString); accessToken = loginRes.optString("access_token"); expiresIn = loginRes.optInt("expires_in"); refreshToken = loginRes.optString("refresh_token"); JSONObject userInfoObject = loginRes.optJSONObject("usr_info"); if (userInfoObject != null) { userInfoBean = new UserInfoBean(); userInfoBean.setUsr_id(userInfoObject.optString("usr_id")); userInfoBean.setUsr_no(userInfoObject.optString("usr_no")); userInfoBean.setUsr_name(userInfoObject.optString("usr_name")); userInfoBean.setUsr_pwd(userInfoObject.optString("usr_pwd")); userInfoBean.setUsr_login_name(userInfoObject.optString("usr_login_name")); userInfoBean.setUsr_sex(userInfoObject.optString("usr_sex")); userInfoBean.setUsr_phone(userInfoObject.optString("usr_phone")); userInfoBean.setUsr_photo(userInfoObject.optString("usr_photo")); userInfoBean.setUsr_addr(userInfoObject.optString("usr_addr")); userInfoBean.setUsr_email(userInfoObject.optString("usr_email")); userInfoBean.seteTag(userInfoObject.optString("ETag")); userInfoBean.setPhone_bind(userInfoObject.optString("phone_bind")); JSONObject certigierUserInfoObject = userInfoObject.optJSONObject("certigier _usr_info"); if (certigierUserInfoObject != null) { certigierUserInfoBean = new UserInfoBean(); certigierUserInfoBean.setUsr_no(userInfoObject.optString("usr_no")); certigierUserInfoBean.setUsr_login_name(userInfoObject.optString("usr_login_name")); } } return true; } catch (JSONException e) { Logger.e(this.getClass(), "[登录响应类]:解析 响应消息出错,详细信息:", e); return false; } }