コード例 #1
0
  private void loginApiSuccess(Object obj) {

    if (obj instanceof User) {

      final User user = (User) obj;

      if (user.getCode() == 200) {
        if (DemoContext.getInstance() != null && user.getResult() != null) {
          SharedPreferences.Editor edit = DemoContext.getInstance().getSharedPreferences().edit();
          edit.putString("DEMO_USER_ID", user.getResult().getId());
          edit.putString("DEMO_USER_NAME", user.getResult().getUsername());
          edit.putString("DEMO_USER_PORTRAIT", user.getResult().getPortrait());
          edit.apply();
          Log.e(TAG, "-------login success------");

          httpLoginSuccess(user);
        }
      } else if (user.getCode() == 103) {

        if (mDialog != null) mDialog.dismiss();

        WinToast.toast(LoginActivity.this, "密码错误");
      } else if (user.getCode() == 104) {

        if (mDialog != null) mDialog.dismiss();

        WinToast.toast(LoginActivity.this, "账号错误");
      }
    }
  }
コード例 #2
0
  private void httpLoginSuccess(User user) {

    if (user.getCode() == 200) {

      getTokenHttpRequest = DemoContext.getInstance().getDemoApi().getToken(this);
    }
  }
コード例 #3
0
  private void getTokenApiSuccess(Object obj) {

    if (obj instanceof User) {
      final User user = (User) obj;
      if (user.getCode() == 200) {

        httpGetTokenSuccess(user.getResult().getToken());

        SharedPreferences.Editor edit = DemoContext.getInstance().getSharedPreferences().edit();
        edit.putString("DEMO_TOKEN", user.getResult().getToken());
        edit.putBoolean("DEMO_ISFIRST", false);
        edit.apply();
        Log.e(TAG, "------getTokenHttpRequest -success--" + user.getResult().getToken());
      } else if (user.getCode() == 110) {
        WinToast.toast(LoginActivity.this, "请先登陆");
      } else if (user.getCode() == 111) {
        WinToast.toast(LoginActivity.this, "cookie 为空");
      }
    }
  }