当前位置: 首页>>代码示例>>Java>>正文


Java HttpHandler类代码示例

本文整理汇总了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);
                   }
               });
}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:24,代码来源:Tools.java

示例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();
			}
		}
	});
}
 
开发者ID:imknown,项目名称:IMKBaseFrameworkLibrary,代码行数:26,代码来源:BaseActivity.java

示例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);
	}
}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:18,代码来源:BookDownloadManager.java

示例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);
}
 
开发者ID:Frank-Zhu,项目名称:AndroidAppCodeFramework,代码行数:18,代码来源:DownloadManager.java

示例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);
    }
}
 
开发者ID:Frank-Zhu,项目名称:AndroidAppCodeFramework,代码行数:18,代码来源:DownloadManager.java

示例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);
	        }
	});

}
 
开发者ID:zhaoyangzhou,项目名称:NPush,代码行数:40,代码来源:XUtil.java

示例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);
}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:21,代码来源:BookDownloadManager.java

示例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);
}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:16,代码来源:BookDownloadManager.java

示例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);
}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:17,代码来源:BookDownloadManager.java

示例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);
}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:17,代码来源:BookDownloadManager.java

示例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);
}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:15,代码来源:BookDownloadManager.java

示例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();
	}
}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:16,代码来源:BookDownloadManager.java

示例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();
	}
}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:16,代码来源:BookDownloadManager.java

示例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);
	}
}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:16,代码来源:BookDownloadManager.java

示例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);
	}
}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:16,代码来源:BookDownloadManager.java


注:本文中的com.lidroid.xutils.http.HttpHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。