Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- return Observable.defer(() -> {
- int nonce = calculateFreshNonce();
- return login(api, secret, String.valueOf(nonce));
- })
- .map(infoTradeResponse -> {
- if (infoTradeResponse.getResponseStatus() == BaseTradeResponse.ERROR_STATUS && infoTradeResponse.getResponseError().equals(Constants.NONCE_ERROR)) {
- Log.d(TAG, "KeysNonceError");
- throw new KeysNonceError();
- }
- else {
- if (infoTradeResponse.getResponseStatus() == BaseTradeResponse.SUCCESS_STATUS)
- return true;
- else return false;
- }
- })
- .retryWhen(error -> {
- int[] count = { 0 };
- return error
- .takeWhile(v -> count[0]++ <= Constants.MAX_RETRY)
- .delay(count[0] * 100, TimeUnit.MILLISECONDS);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement