예제 #1
0
  public void attemptLogin() {
    String loginName = mNameView.getText().toString();
    String mPassword = mPasswordView.getText().toString();
    boolean cancel = false;
    View focusView = null;

    if (TextUtils.isEmpty(mPassword)) {
      Toast.makeText(this, getString(R.string.error_pwd_required), Toast.LENGTH_SHORT).show();
      focusView = mPasswordView;
      cancel = true;
    }

    if (TextUtils.isEmpty(loginName)) {
      Toast.makeText(this, getString(R.string.error_name_required), Toast.LENGTH_SHORT).show();
      focusView = mNameView;
      cancel = true;
    }

    if (cancel) {
      focusView.requestFocus();
    } else {
      showProgress(true);
      if (imService != null) {
        //				boolean userNameChanged = true;
        //				boolean pwdChanged = true;
        loginName = loginName.trim();
        mPassword = mPassword.trim();
        imService.getLoginManager().login(loginName, mPassword);
      }
    }
  }
예제 #2
0
        @Override
        public void onIMServiceConnected() {
          logger.d("login#onIMServiceConnected");
          imService = imServiceConnector.getIMService();
          try {
            do {
              if (imService == null) {
                // 后台服务启动链接失败
                break;
              }
              IMLoginManager loginManager = imService.getLoginManager();
              LoginSp loginSp = imService.getLoginSp();
              if (loginManager == null || loginSp == null) {
                // 无法获取登陆控制器
                break;
              }

              LoginSp.SpLoginIdentity loginIdentity = loginSp.getLoginIdentity();
              if (loginIdentity == null) {
                // 之前没有保存任何登陆相关的,跳转到登陆页面
                break;
              }

              mNameView.setText(loginIdentity.getLoginName());
              if (TextUtils.isEmpty(loginIdentity.getPwd())) {
                // 密码为空,可能是loginOut
                break;
              }
              mPasswordView.setText(loginIdentity.getPwd());

              if (autoLogin == false) {
                break;
              }

              handleGotLoginIdentity(loginIdentity);
              return;
            } while (false);

            // 异常分支都会执行这个
            handleNoLoginIdentity();
          } catch (Exception e) {
            // 任何未知的异常
            logger.w("loadIdentity failed");
            handleNoLoginIdentity();
          }
        }