public boolean cancel() { boolean cancelled = cancel(true); // necessary to effectively stop HttpUrlConnections final PeppermintApi peppermintApi = (PeppermintApi) getParameter(Sender.PARAM_PEPPERMINT_API); if (peppermintApi != null) { peppermintApi.cancelPendingRequests(mIdentity.getId().toString()); } final GoogleApi googleApi = (GoogleApi) getParameter(Sender.PARAM_GOOGLE_API); if (googleApi != null) { googleApi.cancelPendingRequests(mIdentity.getId().toString()); } final SparkPostApi sparkPostApi = (SparkPostApi) getParameter(Sender.PARAM_SPARKPOST_API); if (sparkPostApi != null) { sparkPostApi.cancelPendingRequests(mIdentity.getId().toString()); } return cancelled; }
/** * Setups the PeppermintApi.<br> * * <ol> * <li>Checks internet connection * <li>Checks the {@link PeppermintApi} access token * </ol> * * @param invalidateToken true to forcefully invalidate the Peppermint API access token * @throws NoInternetConnectionException * @throws PeppermintApiNoAccountException * @throws PeppermintApiInvalidAccessTokenException * @throws IOException * @throws GoogleApiNoAuthorizationException */ protected AuthenticationData setupPeppermintAuthentication(final boolean invalidateToken) throws Exception { checkInternetConnection(); final PeppermintApi peppermintApi = getPeppermintApi(); String accessToken = peppermintApi.peekAuthenticationToken(); if (invalidateToken || accessToken == null) { accessToken = peppermintApi.renewAuthenticationToken(); if (accessToken == null) { throw new PeppermintApiInvalidAccessTokenException("Token is null!"); } } final AuthenticatorUtils authenticatorUtils = new AuthenticatorUtils(getContext()); final AuthenticationData authenticationData = authenticatorUtils.getAccountData(); setAuthenticationData(authenticationData); return authenticationData; }