public final class APICloudHttpClient
extends java.lang.Object
HttpUrlConnection
进行的标准Get,Post,Put,Delete等Http请求的封装,是一个标准化的网络框架,
具有使用简单,高效稳定,所见即得,占用资源低等特点。APICloudHttpClient自动处理Cookie和缓存,同时包含Android加载图片所需三级缓存机制。APICloudHttpClient所管理的缓存及Cookie与api.ajax共享。APICloudHttpClient.createInstance(Context);
限定符和类型 | 类和说明 |
---|---|
static interface |
APICloudHttpClient.BitmapListener
获取图片回调
|
static class |
APICloudHttpClient.ImageEntity
APICloud终端引擎私有图片缓存实体
|
static class |
APICloudHttpClient.ImageOption
请求图片条件实体
|
限定符和类型 | 方法和说明 |
---|---|
static APICloudHttpClient.ImageOption |
builder(java.lang.String url)
根据url创建一个默认的ImageOption
|
void |
cancelDownload(java.lang.Object tag)
取消一个下载请求
|
void |
cancelRequests(java.lang.Object tag)
根据请求标识取消或终止某个请求
|
void |
clearDiskImageCache(long timeThreshold)
清除APICloud终端引擎私有图片缓存机制中的cache
|
static APICloudHttpClient |
createInstance(Context context)
初始化APICloudHttpClient,在使用APICloudHttpClient所有接口之前,必须调用该函数进行初始化
|
void |
disPlayImage(APICloudHttpClient.ImageOption option,
ImageView view)
根据条件获取图片并将其展示在ImageView上
|
HttpResult |
doRequest(Request req)
同步请求,切勿在UI线程发起
|
void |
download(HttpDownload request)
插入一个下载请求
|
java.lang.String |
getCacheRootDir()
获取APICloudHttpClient外部缓存的根路径
|
Bitmap |
getImage(APICloudHttpClient.ImageOption option,
APICloudHttpClient.BitmapListener callback)
获取图片,如果缓存中有,则从缓存中获取并直接返回,否则发起远程获取请求
|
APICloudHttpClient.ImageEntity |
hasDiskImageCache(java.lang.String url)
APICloud终端引擎私有图片缓存机制中的cache判断
|
static APICloudHttpClient |
instance()
获取APICloudHttpClient的实例
|
void |
request(Request req)
插入一个请求
|
void |
request(Request req,
java.lang.String tag)
插入一个请求
|
public static APICloudHttpClient instance()
public static APICloudHttpClient createInstance(Context context)
context
- public void request(Request req)
req
- 见HttpGet|HttpPost等public void request(Request req, java.lang.String tag)
req
- 见HttpGet|HttpPost等tag
- req对应请求的标识,可用于根据该标识取消或终止请求public HttpResult doRequest(Request req)
req
- 见HttpGet|HttpPost等public void cancelRequests(java.lang.Object tag)
tag
- 请求标识public Bitmap getImage(APICloudHttpClient.ImageOption option, APICloudHttpClient.BitmapListener callback)
option
- 对返回图片的要求callback
- 远程获取图片请求回调public void disPlayImage(APICloudHttpClient.ImageOption option, ImageView view)
option
- 对返回图片的要求view
- ImageViewpublic void download(HttpDownload request)
request
- 见HttpDownloadpublic void cancelDownload(java.lang.Object tag)
tag
- 请求标识public final APICloudHttpClient.ImageEntity hasDiskImageCache(java.lang.String url)
public void clearDiskImageCache(long timeThreshold)
public java.lang.String getCacheRootDir()
public static APICloudHttpClient.ImageOption builder(java.lang.String url)