Ejemplo n.º 1
0
  /* 进行验证码验证,或者进行快速登录的回调,这两个是进行快速登录可能遇到的情况 */
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    String userAccount = "";
    ErrMsg errMsg = null;
    WUserSigInfo userSigInfo = null;
    switch (requestCode) {
      case WtloginUtil.REQ_VCODE:
        {
          if (data == null) break;
          Bundle bundle = data.getExtras();
          if (bundle == null) break;
          userAccount = bundle.getString("ACCOUNT");
          errMsg = (ErrMsg) bundle.getParcelable("ERRMSG");
          userSigInfo = (WUserSigInfo) bundle.getParcelable("USERSIG");

          if (resultCode == util.S_SUCCESS) {
            // 转菊花,等待产品列表获取结果
            showProDialog(
                getString(R.string.pi_octopus_pull_products),
                getString(R.string.pi_octopus_pull_products_content));
            loginSuccess(userAccount);
          } else if (resultCode == util.S_LH_EXPIRED || resultCode == util.S_BABYLH_EXPIRED) {
            Ticket ticket = WtloginHelper.GetUserSigInfoTicket(userSigInfo, SigType.WLOGIN_LHSIG);
            finish();
            ToastUtil.ShowLongToast(
                GTApp.getContext(),
                "lhsig=" + util.buf_to_string(ticket._sig) + " errMsg=" + errMsg);
          } else {
            finish();
            ToastUtil.ShowLongToast(GTApp.getContext(), "errMsg=" + errMsg);
          }
        }
        break;
      case WtloginUtil.REQ_QLOGIN: // 快速登录返回
        try {
          if (data == null) { // 这种情况下用户多半是直接按了返回按钮,没有进行快速登录;快速登录失败可提醒用户输入密码登录
            break;
          }

          WUserSigInfo sigInfo = WtloginUtil.getSigInfo(data);
          if (sigInfo == null) {
            ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_octopus_login_user_quickerror);
            break;
          }

          WtloginUtil.setUin(sigInfo.uin);

          // 转菊花,等待产品列表获取结果
          showProDialog(
              getString(R.string.pi_octopus_pull_products),
              getString(R.string.pi_octopus_pull_products_content));

          // 快速登录只是从手Q换取了A1票据,A1则相当于用户密码,在此仍需要再发起一次A1换票的流程,才能拿到目标票据
          WtloginUtil.getStWithPasswd(sigInfo);
          // 换票据成功后会触发wtloginListener的监听
        } catch (Exception e) {
          util.printException(e);
        }
        break;
      default:
        break;
    }
  }