@Override public void onSuccess(String errMsg, Message msg) { LoginResp resp = null; if (null != msg.obj && msg.obj instanceof LoginResp) { resp = (LoginResp) msg.obj; UserItem item = new UserItem(); item.phone = phone; item.password = password; item.parentSex = resp.parentSex; item.userId = resp.userId; item.children = resp.children; LoginUtil.saveLoginInfo(mContext, item); Gson gson = new GsonBuilder().disableHtmlEscaping().create(); String cookieStr = gson.toJson(WXApplication.getInstance().cookieList); SharedPreferencesUtil.saveSharedPreferences( mContext, SharedPreferencesUtil.SP_KEY_LOGIN_COOKIE, cookieStr); if (ListUtil.isEmpty(item.children)) { showToast("无法连接值服务器,请稍后再试"); finish(); } else { String childrenId = SharedPreferencesUtil.getSharedPreferences( mContext, GlobalConstant.UserInfoPreference.CHILDREN, ""); if (TextUtils.isEmpty(childrenId)) { startActivity(new Intent(mContext, LoginActivity.class)); finish(); } else { boolean login = false; for (ChildrenItem children : item.children) { if (null != children && childrenId.equals(children.studentId)) { login = true; childrenItem = children; } } if (login) { Map<String, String> param = HttpRequestUtil.getCommonParams(""); param.put("studentId", childrenItem.studentId); HttpRequestUtil.sendHttpPostCommonRequest( mContext, HttpAddressProperties.CHOOSE_CHILDREN, param, ChooseChildrenResp.class, handler); } else { startActivity(new Intent(mContext, LoginActivity.class)); finish(); } } } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 解决程序在安装完成后点击打开按钮后 程序按home键后再次进入程序一直重启无法后台运行的bug if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { finish(); return; } setContentView(R.layout.wx_loading); GlobalVariable.currentActivity = this; Util.getStatusBarHeight(this); if (SharedPreferencesUtil.getSharedPreferences(this, GlobalConstant.REMEMBER_PASSWORD, false)) { phone = SharedPreferencesUtil.getSharedPreferences( LoadActivity.this, GlobalConstant.UserInfoPreference.TELPHONE, ""); password = SharedPreferencesUtil.getSharedPreferences( LoadActivity.this, GlobalConstant.UserInfoPreference.PASSWORD, ""); if (!TextUtils.isEmpty(phone) && !TextUtils.isEmpty(password)) { new Handler() .postDelayed( new Runnable() { @Override public void run() { Map<String, String> reqMap = HttpRequestUtil.getCommonParams(""); reqMap.put("phone", phone); reqMap.put("password", SecurityUtil.MD5(password)); HttpRequestUtil.sendHttpPostCommonRequest( LoadActivity.this, HttpAddressProperties.LOGIN_URL, reqMap, LoginResp.class, loginHandler); } }, 2000); } else { toLoginActivity(); } } else { toLoginActivity(); } }
@Override public void onSuccess(String errMsg, Message msg) { ChooseChildrenResp resp = null; if (null != msg.obj && msg.obj instanceof ChooseChildrenResp) { resp = (ChooseChildrenResp) msg.obj; if (null != childrenItem) { if (null != WXApplication.getInstance().loginUserItem) { childrenItem.classinfoId = resp.classinfoId; childrenItem.classinfoName = resp.classinfoName; WXApplication.getInstance().groupId = resp.groupId; WXApplication.getInstance().selectedItem = childrenItem; } SharedPreferencesUtil.saveSharedPreferences( mContext, GlobalConstant.UserInfoPreference.CHILDREN, childrenItem.studentId); WXApplication.getInstance().selectStudentId = childrenItem.studentId; SharedPreferencesUtil.saveSharedPreferences( mContext, GlobalConstant.UserInfoPreference.CLASSINFOID, childrenItem.classinfoId); } } startActivity(new Intent(mContext, WXMainFragmentActivity.class)); finish(); }