com.octo.android.robospice.request
Class SpiceRequest<RESULT>

java.lang.Object
  extended by com.octo.android.robospice.request.SpiceRequest<RESULT>
Type Parameters:
RESULT -
All Implemented Interfaces:
Comparable<SpiceRequest<RESULT>>
Direct Known Subclasses:
BinaryRequest, BitmapRequest, CachedSpiceRequest, GoogleHttpClientSpiceRequest, RetrofitSpiceRequest, SimpleTextRequest, SpringAndroidSpiceRequest

public abstract class SpiceRequest<RESULT>
extends Object
implements Comparable<SpiceRequest<RESULT>>

Base class for writing requests in RoboSpice. Simply override loadDataFromNetwork() to define the network operation of a request. REST Requests are easier using the Request class proposed by the spring-android module of RoboSpice.

Author:
sni

Field Summary
static int PRIORITY_HIGH
           
static int PRIORITY_LOW
           
static int PRIORITY_NORMAL
           
 
Constructor Summary
SpiceRequest(Class<RESULT> clazz)
           
 
Method Summary
 void cancel()
           
 int compareTo(SpiceRequest<RESULT> other)
           
 int getPriority()
           
 Class<RESULT> getResultType()
           
 RetryPolicy getRetryPolicy()
           
 boolean isAggregatable()
           
 boolean isCancelled()
           
abstract  RESULT loadDataFromNetwork()
           
protected  void publishProgress()
           
protected  void publishProgress(float progress)
           
 void setAggregatable(boolean isAggregatable)
           
protected  void setFuture(Future<?> future)
           
 void setPriority(int priority)
          Sets the priority of the request.
 void setRequestCancellationListener(RequestCancellationListener requestCancellationListener)
           
protected  void setRequestProgressListener(RequestProgressListener requestProgressListener)
           
 void setRetryPolicy(RetryPolicy retryPolicy)
          Set a RetryPolicy that will be responsible to coordinate retry attempts by the RequestProcessor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIORITY_HIGH

public static final int PRIORITY_HIGH
See Also:
Constant Field Values

PRIORITY_NORMAL

public static final int PRIORITY_NORMAL
See Also:
Constant Field Values

PRIORITY_LOW

public static final int PRIORITY_LOW
See Also:
Constant Field Values
Constructor Detail

SpiceRequest

public SpiceRequest(Class<RESULT> clazz)
Method Detail

getRetryPolicy

public RetryPolicy getRetryPolicy()

setRetryPolicy

public void setRetryPolicy(RetryPolicy retryPolicy)
Set a RetryPolicy that will be responsible to coordinate retry attempts by the RequestProcessor. Can be null (no retry). Retry policy only applies when network is on. If network is down, requests are "tried" only once.

Parameters:
retryPolicy - the new retry policy
See Also:
com.octo.android.robospice.networkstate.NetworkStateChecker.NetworkStateChecker}

setPriority

public void setPriority(int priority)
Sets the priority of the request. Use priority constants or a positive integer. Will have no effect on a request after it starts being executed.

Parameters:
priority - the priority of request. Defaults to PRIORITY_NORMAL.
See Also:
PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_HIGH

getPriority

public int getPriority()

loadDataFromNetwork

public abstract RESULT loadDataFromNetwork()
                                    throws Exception
Throws:
Exception

getResultType

public Class<RESULT> getResultType()

cancel

public void cancel()

isCancelled

public boolean isCancelled()

isAggregatable

public boolean isAggregatable()

setAggregatable

public void setAggregatable(boolean isAggregatable)

setFuture

protected void setFuture(Future<?> future)

setRequestProgressListener

protected void setRequestProgressListener(RequestProgressListener requestProgressListener)

publishProgress

protected void publishProgress()

publishProgress

protected void publishProgress(float progress)

setRequestCancellationListener

public void setRequestCancellationListener(RequestCancellationListener requestCancellationListener)

compareTo

public int compareTo(SpiceRequest<RESULT> other)
Specified by:
compareTo in interface Comparable<SpiceRequest<RESULT>>


Copyright © 2012-2014. All Rights Reserved.