diff options
author | Anonymous <no-reply@google.com> | 2018-05-11 11:23:20 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-05-11 11:23:20 -0700 |
commit | b2a5b6d7a27822b0ed8486485d1cd0e16b01df9d (patch) | |
tree | f39fa51c442a9c6922d1f6def2e75d5dca677f20 /src/main/java/com/android/volley/DefaultRetryPolicy.java | |
parent | c3a0e7848f09ade3a05d9d23a52d1cf21373a841 (diff) | |
parent | f6db66b103746d0ff38a29ad492a9a20cd5e24fe (diff) | |
download | volley-b2a5b6d7a27822b0ed8486485d1cd0e16b01df9d.tar.gz |
Import of Volley from GitHub to AOSP. am: 9a12854004 am: 98a64fa3fc
am: f6db66b103
Change-Id: I51e3fd00fa31221a5ad6cdc39abd41245652711c
Diffstat (limited to 'src/main/java/com/android/volley/DefaultRetryPolicy.java')
-rw-r--r-- | src/main/java/com/android/volley/DefaultRetryPolicy.java | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/main/java/com/android/volley/DefaultRetryPolicy.java b/src/main/java/com/android/volley/DefaultRetryPolicy.java index d8abab0..4be6b50 100644 --- a/src/main/java/com/android/volley/DefaultRetryPolicy.java +++ b/src/main/java/com/android/volley/DefaultRetryPolicy.java @@ -16,9 +16,7 @@ package com.android.volley; -/** - * Default retry policy for requests. - */ +/** Default retry policy for requests. */ public class DefaultRetryPolicy implements RetryPolicy { /** The current timeout in milliseconds. */ private int mCurrentTimeoutMs; @@ -41,15 +39,14 @@ public class DefaultRetryPolicy implements RetryPolicy { /** The default backoff multiplier */ public static final float DEFAULT_BACKOFF_MULT = 1f; - /** - * Constructs a new retry policy using the default timeouts. - */ + /** Constructs a new retry policy using the default timeouts. */ public DefaultRetryPolicy() { this(DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES, DEFAULT_BACKOFF_MULT); } /** * Constructs a new retry policy. + * * @param initialTimeoutMs The initial timeout for the policy. * @param maxNumRetries The maximum number of retries. * @param backoffMultiplier Backoff multiplier for the policy. @@ -60,45 +57,38 @@ public class DefaultRetryPolicy implements RetryPolicy { mBackoffMultiplier = backoffMultiplier; } - /** - * Returns the current timeout. - */ + /** Returns the current timeout. */ @Override public int getCurrentTimeout() { return mCurrentTimeoutMs; } - /** - * Returns the current retry count. - */ + /** Returns the current retry count. */ @Override public int getCurrentRetryCount() { return mCurrentRetryCount; } - /** - * Returns the backoff multiplier for the policy. - */ + /** Returns the backoff multiplier for the policy. */ public float getBackoffMultiplier() { return mBackoffMultiplier; } /** * Prepares for the next retry by applying a backoff to the timeout. + * * @param error The error code of the last attempt. */ @Override public void retry(VolleyError error) throws VolleyError { mCurrentRetryCount++; - mCurrentTimeoutMs += (mCurrentTimeoutMs * mBackoffMultiplier); + mCurrentTimeoutMs += (int) (mCurrentTimeoutMs * mBackoffMultiplier); if (!hasAttemptRemaining()) { throw error; } } - /** - * Returns true if this policy has attempts remaining, false otherwise. - */ + /** Returns true if this policy has attempts remaining, false otherwise. */ protected boolean hasAttemptRemaining() { return mCurrentRetryCount <= mMaxNumRetries; } |