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

java.lang.Object
  extended by com.octo.android.robospice.request.SpiceRequest<RESULT>
      extended by com.octo.android.robospice.request.CachedSpiceRequest<RESULT>
Type Parameters:
RESULT -
All Implemented Interfaces:
Comparable<SpiceRequest<RESULT>>

public class CachedSpiceRequest<RESULT>
extends SpiceRequest<RESULT>

Decorates SpiceRequest and provides additional information used by RoboSpice. There are very few chances that you should use this class directly, though you can. But generally speaking, SpiceManager.execute(SpiceRequest, Object, long, com.octo.android.robospice.request.listener.RequestListener) is considered to be more clear.

Author:
SNI

Field Summary
 
Fields inherited from class com.octo.android.robospice.request.SpiceRequest
PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL
 
Constructor Summary
CachedSpiceRequest(SpiceRequest<RESULT> spiceRequest, Object requestCacheKey, long cacheDuration)
           
 
Method Summary
 void cancel()
           
 int compareTo(SpiceRequest<RESULT> other)
           
 boolean equals(Object obj)
           
 long getCacheDuration()
           
 int getPriority()
           
 Object getRequestCacheKey()
           
 Class<RESULT> getResultType()
           
 RetryPolicy getRetryPolicy()
           
 SpiceRequest<RESULT> getSpiceRequest()
           
 int hashCode()
           
 boolean isAcceptingDirtyCache()
           
 boolean isAggregatable()
           
 boolean isCancelled()
           
 boolean isOffline()
           
 boolean isProcessable()
           
 RESULT loadDataFromNetwork()
           
protected  void publishProgress(float progress)
           
 void setAcceptingDirtyCache(boolean isAcceptingDirtyCache)
           
 void setAggregatable(boolean isAggregatable)
           
protected  void setFuture(Future<?> future)
          Sets the future of this request, used to cancel it.
 void setOffline(boolean isOffline)
           
 void setPriority(int priority)
          Sets the priority of the request.
 void setProcessable(boolean isProcessable)
           
 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.
 String toString()
           
 
Methods inherited from class com.octo.android.robospice.request.SpiceRequest
publishProgress
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CachedSpiceRequest

public CachedSpiceRequest(SpiceRequest<RESULT> spiceRequest,
                          Object requestCacheKey,
                          long cacheDuration)
Method Detail

getRetryPolicy

public RetryPolicy getRetryPolicy()
Overrides:
getRetryPolicy in class SpiceRequest<RESULT>

setRetryPolicy

public void setRetryPolicy(RetryPolicy retryPolicy)
Description copied from class: SpiceRequest
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.

Overrides:
setRetryPolicy in class SpiceRequest<RESULT>
Parameters:
retryPolicy - the new retry policy
See Also:
com.octo.android.robospice.networkstate.NetworkStateChecker.NetworkStateChecker}

loadDataFromNetwork

public RESULT loadDataFromNetwork()
                           throws Exception
Specified by:
loadDataFromNetwork in class SpiceRequest<RESULT>
Throws:
Exception

getResultType

public Class<RESULT> getResultType()
Overrides:
getResultType in class SpiceRequest<RESULT>

isAggregatable

public boolean isAggregatable()
Overrides:
isAggregatable in class SpiceRequest<RESULT>

setAggregatable

public void setAggregatable(boolean isAggregatable)
Overrides:
setAggregatable in class SpiceRequest<RESULT>

isProcessable

public boolean isProcessable()

setProcessable

public void setProcessable(boolean isProcessable)

setFuture

protected void setFuture(Future<?> future)
Sets the future of this request, used to cancel it.

Overrides:
setFuture in class SpiceRequest<RESULT>
Parameters:
future - the future result of this request.

cancel

public void cancel()
Overrides:
cancel in class SpiceRequest<RESULT>

isCancelled

public boolean isCancelled()
Overrides:
isCancelled in class SpiceRequest<RESULT>

setRequestProgressListener

protected void setRequestProgressListener(RequestProgressListener requestProgressListener)
Overrides:
setRequestProgressListener in class SpiceRequest<RESULT>

setRequestCancellationListener

public void setRequestCancellationListener(RequestCancellationListener requestCancellationListener)
Overrides:
setRequestCancellationListener in class SpiceRequest<RESULT>

publishProgress

protected void publishProgress(float progress)
Overrides:
publishProgress in class SpiceRequest<RESULT>

getRequestCacheKey

public Object getRequestCacheKey()

getCacheDuration

public long getCacheDuration()

getSpiceRequest

public SpiceRequest<RESULT> getSpiceRequest()

setPriority

public void setPriority(int priority)
Description copied from class: SpiceRequest
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.

Overrides:
setPriority in class SpiceRequest<RESULT>
Parameters:
priority - the priority of request. Defaults to SpiceRequest.PRIORITY_NORMAL.
See Also:
SpiceRequest.PRIORITY_LOW, SpiceRequest.PRIORITY_NORMAL, SpiceRequest.PRIORITY_HIGH

getPriority

public int getPriority()
Overrides:
getPriority in class SpiceRequest<RESULT>

isAcceptingDirtyCache

public boolean isAcceptingDirtyCache()

setAcceptingDirtyCache

public void setAcceptingDirtyCache(boolean isAcceptingDirtyCache)

isOffline

public boolean isOffline()

setOffline

public void setOffline(boolean isOffline)

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

compareTo

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


Copyright © 2012-2014. All Rights Reserved.