Advertisement
Guest User

Untitled

a guest
May 25th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. public Observable<Boolean> tryToLogin(final String api, final String secret) {
  2. AtomicInteger nonce = new AtomicInteger();
  3. return login(api, secret, String.valueOf(nonce.get()))
  4. .map(infoTradeResponse -> {
  5. if (infoTradeResponse.getResponseStatus() == BaseTradeResponse.ERROR_STATUS && infoTradeResponse.getResponseError().equals(Constants.NONCE_ERROR)) {
  6. Log.d(TAG, "KeysNonceError");
  7. throw new KeysNonceError();
  8. }
  9. else {
  10. if (infoTradeResponse.getResponseStatus() == BaseTradeResponse.SUCCESS_STATUS)
  11. return true;
  12. else return false;
  13. }
  14. })
  15. .retryUntil(new BooleanSupplier() {
  16. int retry = 0;
  17. @Override
  18. public boolean getAsBoolean() throws Exception {
  19.  
  20. return retry++ > Constants.MAX_RETRY;
  21. }
  22. });
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement