com.duowan.mobile.netroid
Class ExecutorDelivery

java.lang.Object
  extended by com.duowan.mobile.netroid.ExecutorDelivery
All Implemented Interfaces:
Delivery

public class ExecutorDelivery
extends java.lang.Object
implements Delivery

Delivers responses and errors.


Constructor Summary
ExecutorDelivery(java.util.concurrent.Executor executor)
          Creates a new response delivery interface, mockable version for testing.
ExecutorDelivery(android.os.Handler handler)
          Creates a new response delivery interface.
 
Method Summary
 void postCancel(Request<?> request)
          Posts a cancel callback for the given request.
 void postDownloadProgress(Request<?> request, long fileSize, long downloadedSize)
          Posts file download progress stat.
 void postError(Request<?> request, NetroidError error)
          Posts an error for the given request.
 void postFinish(Request<?> request)
          Posts request finished callback for the given request.
 void postNetworking(Request<?> request)
          Posts networking callback for the given request.
 void postPreExecute(Request<?> request)
          Posts starting execute callback for the given request.
 void postResponse(Request<?> request, Response<?> response)
          Parses a response from the network or cache and delivers it.
 void postResponse(Request<?> request, Response<?> response, java.lang.Runnable runnable)
          Parses a response from the network or cache and delivers it.
 void postRetry(Request<?> request)
          Posts request retry callback for the given request.
 void postUsedCache(Request<?> request)
          Posts cache used callback for the given request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutorDelivery

public ExecutorDelivery(android.os.Handler handler)
Creates a new response delivery interface.

Parameters:
handler - Handler to post responses on

ExecutorDelivery

public ExecutorDelivery(java.util.concurrent.Executor executor)
Creates a new response delivery interface, mockable version for testing.

Parameters:
executor - For running delivery tasks
Method Detail

postFinish

public void postFinish(Request<?> request)
Description copied from interface: Delivery
Posts request finished callback for the given request.

Specified by:
postFinish in interface Delivery

postResponse

public void postResponse(Request<?> request,
                         Response<?> response)
Description copied from interface: Delivery
Parses a response from the network or cache and delivers it.

Specified by:
postResponse in interface Delivery

postResponse

public void postResponse(Request<?> request,
                         Response<?> response,
                         java.lang.Runnable runnable)
Description copied from interface: Delivery
Parses a response from the network or cache and delivers it. The provided Runnable will be executed after delivery.

Specified by:
postResponse in interface Delivery

postError

public void postError(Request<?> request,
                      NetroidError error)
Description copied from interface: Delivery
Posts an error for the given request.

Specified by:
postError in interface Delivery

postCancel

public void postCancel(Request<?> request)
Description copied from interface: Delivery
Posts a cancel callback for the given request.

Specified by:
postCancel in interface Delivery

postPreExecute

public void postPreExecute(Request<?> request)
Description copied from interface: Delivery
Posts starting execute callback for the given request.

Specified by:
postPreExecute in interface Delivery

postUsedCache

public void postUsedCache(Request<?> request)
Description copied from interface: Delivery
Posts cache used callback for the given request.

Specified by:
postUsedCache in interface Delivery

postNetworking

public void postNetworking(Request<?> request)
Description copied from interface: Delivery
Posts networking callback for the given request.

Specified by:
postNetworking in interface Delivery

postRetry

public void postRetry(Request<?> request)
Description copied from interface: Delivery
Posts request retry callback for the given request.

Specified by:
postRetry in interface Delivery

postDownloadProgress

public void postDownloadProgress(Request<?> request,
                                 long fileSize,
                                 long downloadedSize)
Description copied from interface: Delivery
Posts file download progress stat.

Specified by:
postDownloadProgress in interface Delivery