FileDocCategorySizeDatePackage
DefaultRetryPolicy.javaAPI DocAndroid 5.1 API2978Thu Mar 12 22:22:56 GMT 2015com.android.volley

DefaultRetryPolicy

public class DefaultRetryPolicy extends Object implements RetryPolicy
Default retry policy for requests.

Fields Summary
private int
mCurrentTimeoutMs
The current timeout in milliseconds.
private int
mCurrentRetryCount
The current retry count.
private final int
mMaxNumRetries
The maximum number of attempts.
private final float
mBackoffMultiplier
The backoff multiplier for for the policy.
public static final int
DEFAULT_TIMEOUT_MS
The default socket timeout in milliseconds
public static final int
DEFAULT_MAX_RETRIES
The default number of retries
public static final float
DEFAULT_BACKOFF_MULT
The default backoff multiplier
Constructors Summary
public DefaultRetryPolicy()
Constructs a new retry policy using the default timeouts.


                  
      
        this(DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES, DEFAULT_BACKOFF_MULT);
    
public DefaultRetryPolicy(int initialTimeoutMs, int maxNumRetries, float backoffMultiplier)
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.

        mCurrentTimeoutMs = initialTimeoutMs;
        mMaxNumRetries = maxNumRetries;
        mBackoffMultiplier = backoffMultiplier;
    
Methods Summary
public intgetCurrentRetryCount()
Returns the current retry count.

        return mCurrentRetryCount;
    
public intgetCurrentTimeout()
Returns the current timeout.

        return mCurrentTimeoutMs;
    
protected booleanhasAttemptRemaining()
Returns true if this policy has attempts remaining, false otherwise.

        return mCurrentRetryCount <= mMaxNumRetries;
    
public voidretry(VolleyError error)
Prepares for the next retry by applying a backoff to the timeout.

param
error The error code of the last attempt.

        mCurrentRetryCount++;
        mCurrentTimeoutMs += (mCurrentTimeoutMs * mBackoffMultiplier);
        if (!hasAttemptRemaining()) {
            throw error;
        }