Beispiel #1
0
    @Override
    protected void onSuccess(TokenInfo tokenInfo) {
      super.onSuccess(tokenInfo);

      if (tokenInfo != null
          && account.getUser().getIdstr().equalsIgnoreCase(AppContext.getUser().getIdstr())) {
        long validSecond =
            Long.parseLong(tokenInfo.getCreate_at()) + Long.parseLong(tokenInfo.getExpire_in());
        if (System.currentTimeMillis() > validSecond * 1000) {
          new AlertDialogWrapper.Builder(MainActivity.this)
              .setTitle(R.string.remind)
              .setMessage(R.string.account_expired)
              .setNegativeButton(R.string.no, null)
              .setPositiveButton(
                  R.string.yes,
                  new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      LoginFragment.launch(
                          MainActivity.this, account.getAccount(), account.getPassword(), 2000);
                    }
                  })
              .show();
        }
      }
    }
Beispiel #2
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == REQUEST_CODE_AUTH) {
      if (resultCode == Activity.RESULT_OK) {
        AccountBean accountBean = (AccountBean) data.getSerializableExtra("account");

        AppContext.getAccount().setAccessToken(accountBean.getAccessToken());
        if (accountBean.getUser() != null) {
          AppContext.getAccount().setUser(accountBean.getUser());
        }
        if (accountBean.getGroups() != null) {
          AppContext.getAccount().setGroups(accountBean.getGroups());
        }

        AccountUtils.newAccount(AppContext.getAccount());
        AccountUtils.setLogedinAccount(AppContext.getAccount());

        login();
      }
    }
  }