本文整理汇总了Java中com.lidroid.xutils.http.HttpHandler类的典型用法代码示例。如果您正苦于以下问题:Java HttpHandler类的具体用法?Java HttpHandler怎么用?Java HttpHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpHandler类属于com.lidroid.xutils.http包,在下文中一共展示了HttpHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: download
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
public static void download(String url, String path,
final IOAuthCallBack iOAuthCallBack) {
HttpUtils http = new HttpUtils();
HttpHandler<File> handler = http.download(url, path, false, // 如果目标文件存在,接着未完成的部分继续下载。服务器不支持RANGE时将从新下载。
false, // 如果从请求返回信息中获取到文件名,下载完成后自动重命名。
new RequestCallBack<File>() {
@Override
public void onSuccess(ResponseInfo<File> arg0) {
if (d)
Log.d("-----downfile-----", "success");
iOAuthCallBack.getIOAuthCallBack(arg0.result.getName(),
0);
}
@Override
public void onFailure(com.lidroid.xutils.exception.HttpException e, String s) {
if (d)
Log.d("-----downfile-----", "fail");
iOAuthCallBack.getIOAuthCallBack(e.toString(), 1);
}
});
}
示例2: showWait
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
/**
* 显示等待对话框, 等待对应网络连接任务<br />
* 当等待对话框被用户手动关闭后,网络连接任务终止
*
* @param waitMsg
* 等待提示信息
*/
protected <T> void showWait(Context context, String waitMsg, boolean cancelable, final HttpHandler<T> handler) {
dismissDialog();
progressDialog = new ProgressDialog(context);
progressDialog.setCancelable(cancelable);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setMessage(waitMsg);
progressDialog.show();
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if (handler != null) {
handler.cancel();
}
}
});
}
示例3: onLoading
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
@Override
public void onLoading(long total, long current, boolean isUploading) {
HttpHandler<File> handler = BookDownloadInfo.getHandler();
if (handler != null) {
BookDownloadInfo.setState(handler.getState());
}
BookDownloadInfo.setFileLength(total);
BookDownloadInfo.setProgress(current);
try {
db.saveOrUpdate(BookDownloadInfo);
} catch (DbException e) {
LogUtils.e(e.getMessage(), e);
}
if (baseCallBack != null) {
baseCallBack.onLoading(total, current, isUploading);
}
}
示例4: addNewDownload
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
public void addNewDownload(String url, String fileName, String target,
boolean autoResume, boolean autoRename,
final RequestCallBack<File> callback) throws DbException {
final DownloadInfo downloadInfo = new DownloadInfo();
downloadInfo.setDownloadUrl(url);
downloadInfo.setAutoRename(autoRename);
downloadInfo.setAutoResume(autoResume);
downloadInfo.setFileName(fileName);
downloadInfo.setFileSavePath(target);
HttpUtils http = new HttpUtils();
http.configRequestThreadPoolSize(maxDownloadThread);
HttpHandler<File> handler = http.download(url, target, autoResume, autoRename, new ManagerCallBack(downloadInfo, callback));
downloadInfo.setHandler(handler);
downloadInfo.setState(handler.getState());
downloadInfoList.add(downloadInfo);
db.saveBindingId(downloadInfo);
}
示例5: onLoading
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
@Override
public void onLoading(long total, long current, boolean isUploading) {
HttpHandler<File> handler = downloadInfo.getHandler();
if (handler != null) {
downloadInfo.setState(handler.getState());
}
downloadInfo.setFileLength(total);
downloadInfo.setProgress(current);
try {
db.saveOrUpdate(downloadInfo);
} catch (DbException e) {
LogUtils.e(e.getMessage(), e);
}
if (baseCallBack != null) {
baseCallBack.onLoading(total, current, isUploading);
}
}
示例6: download
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
/**
* <p>Method :download
* <p>Description : 方法功能描述
*
* @param ctx 上下文
* @param url 文件地址
* @param localPath 本地存储路径
* @param postCBIA 回调接口
*/
public void download(final Context ctx, final String url, final String localPath, final PostCallbackIA postCBIA) {
HttpHandler handler = getSingleInstance().download(url,
localPath,
true, // 如果目标文件存在,接着未完成的部分继续下载。服务器不支持RANGE时将从新下载。
true, // 如果从请求返回信息中获取到文件名,下载完成后自动重命名。
new RequestCallBack<File>() {
@Override
public void onStart() {
Toast.makeText(ctx, "下载中,请稍后...", Toast.LENGTH_SHORT);
}
@Override
public void onLoading(long total, long current, boolean isUploading) {
}
@Override
public void onSuccess(ResponseInfo<File> responseInfo) {
postCBIA.onSuccess(responseInfo);
}
@Override
public void onFailure(HttpException error, String msg) {
postCBIA.onFailure(error, msg);
}
});
}
示例7: resumeDownload
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
/**
* 恢复下载
*
* @param BookDownloadInfo
* @param callback
* @throws DbException
*/
public void resumeDownload(BookDownloadInfo BookDownloadInfo,
final RequestCallBack<File> callback) throws DbException {
HttpUtils http = new HttpUtils();
http.configRequestThreadPoolSize(maxDownloadThread);
HttpHandler<File> handler = http.download(BookDownloadInfo
.getDownloadUrl(), BookDownloadInfo.getFileSavePath(),
BookDownloadInfo.isAutoResume(), BookDownloadInfo
.isAutoRename(), new ManagerCallBack(BookDownloadInfo,
callback));
BookDownloadInfo.setHandler(handler);
BookDownloadInfo.setState(handler.getState());
db.saveOrUpdate(BookDownloadInfo);
}
示例8: removeDownload
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
/**
* 取消下载
*
* @param BookDownloadInfo
* @throws DbException
*/
public void removeDownload(BookDownloadInfo BookDownloadInfo)
throws DbException {
HttpHandler<File> handler = BookDownloadInfo.getHandler();
if (handler != null && !handler.isCancelled()) {
handler.cancel();
}
downloadInfoList.remove(BookDownloadInfo);
db.delete(BookDownloadInfo);
}
示例9: stopDownload
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
/**
* 暂停下载
*
* @param BookDownloadInfo
* @throws DbException
*/
public void stopDownload(BookDownloadInfo BookDownloadInfo)
throws DbException {
HttpHandler<File> handler = BookDownloadInfo.getHandler();
if (handler != null && !handler.isCancelled()) {
handler.cancel();
} else {
BookDownloadInfo.setState(HttpHandler.State.CANCELLED);
}
db.saveOrUpdate(BookDownloadInfo);
}
示例10: stopAllDownload
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
/**
* 暂停所有的下载
*
* @throws DbException
*/
public void stopAllDownload() throws DbException {
for (BookDownloadInfo BookDownloadInfo : downloadInfoList) {
HttpHandler<File> handler = BookDownloadInfo.getHandler();
if (handler != null && !handler.isCancelled()) {
handler.cancel();
} else {
BookDownloadInfo.setState(HttpHandler.State.CANCELLED);
}
}
db.saveOrUpdateAll(downloadInfoList);
}
示例11: backupDownloadInfoList
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
/**
* 在Activity被销毁的时候备份下载的信息
*
* @throws DbException
*/
public void backupDownloadInfoList() throws DbException {
for (BookDownloadInfo BookDownloadInfo : downloadInfoList) {
HttpHandler<File> handler = BookDownloadInfo.getHandler();
if (handler != null) {
BookDownloadInfo.setState(handler.getState());
}
}
db.saveOrUpdateAll(downloadInfoList);
}
示例12: onStart
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
@Override
public void onStart() {
HttpHandler<File> handler = BookDownloadInfo.getHandler();
if (handler != null) {
BookDownloadInfo.setState(handler.getState());
}
try {
db.saveOrUpdate(BookDownloadInfo);
} catch (DbException e) {
LogUtils.e(e.getMessage(), e);
}
if (baseCallBack != null) {
baseCallBack.onStart();
}
}
示例13: onCancelled
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
@Override
public void onCancelled() {
HttpHandler<File> handler = BookDownloadInfo.getHandler();
if (handler != null) {
BookDownloadInfo.setState(handler.getState());
}
try {
db.saveOrUpdate(BookDownloadInfo);
} catch (DbException e) {
LogUtils.e(e.getMessage(), e);
}
if (baseCallBack != null) {
baseCallBack.onCancelled();
}
}
示例14: onSuccess
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
@Override
public void onSuccess(ResponseInfo<File> responseInfo) {
HttpHandler<File> handler = BookDownloadInfo.getHandler();
if (handler != null) {
BookDownloadInfo.setState(handler.getState());
}
try {
db.saveOrUpdate(BookDownloadInfo);
} catch (DbException e) {
LogUtils.e(e.getMessage(), e);
}
if (baseCallBack != null) {
baseCallBack.onSuccess(responseInfo);
}
}
示例15: onFailure
import com.lidroid.xutils.http.HttpHandler; //导入依赖的package包/类
@Override
public void onFailure(HttpException error, String msg) {
HttpHandler<File> handler = BookDownloadInfo.getHandler();
if (handler != null) {
BookDownloadInfo.setState(handler.getState());
}
try {
db.saveOrUpdate(BookDownloadInfo);
} catch (DbException e) {
LogUtils.e(e.getMessage(), e);
}
if (baseCallBack != null) {
baseCallBack.onFailure(error, msg);
}
}