本文整理汇总了Java中com.koushikdutta.ion.ProgressCallback类的典型用法代码示例。如果您正苦于以下问题:Java ProgressCallback类的具体用法?Java ProgressCallback怎么用?Java ProgressCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProgressCallback类属于com.koushikdutta.ion包,在下文中一共展示了ProgressCallback类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: uploadTest
import com.koushikdutta.ion.ProgressCallback; //导入依赖的package包/类
private void uploadTest(File file) {
Ion.with(mContext)
.load("http://115.47.55.60/Upload.aspx")
.uploadProgressBar(pb)
.uploadProgressHandler(new ProgressCallback() {
@Override
public void onProgress(long downloaded, long total) {
upload.setText("" + downloaded + " / " + total);
}
})
.setMultipartFile("image", file)
.asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String arg1) {
if (e == null) {
upload.setText("上传完成");
}
}
});
}
开发者ID:vihuela,项目名称:Lulu,代码行数:23,代码来源:MyFragment.java
示例2: downloadFile
import com.koushikdutta.ion.ProgressCallback; //导入依赖的package包/类
public static void downloadFile(final Context context,String url,String title,int type){
File f;
if(type == 0){
f = new File(getPath(), title+"."+ MimeTypeMap.getFileExtensionFromUrl(url));
}else{
f = new File(getPath(), title);
}
final NotificationHelper mNotificationHelper = new NotificationHelper(context);
Ion mIon = Ion.getDefault(context);
mIon.getHttpClient()
.getSSLSocketMiddleware()
.setSpdyEnabled(false);
mIon.with(context)
.load(url)
.progress(new ProgressCallback() {
@Override public void onProgress(long downloaded, long total) {
mNotificationHelper.onProgress((int) (100 * downloaded / total));
}
})
.write(f)
.setCallback(new FutureCallback<File>() {
@Override public void onCompleted(Exception e, File file) {
if (e != null) {
Timber.e(e.getMessage());
mNotificationHelper.onError();
return;
} else {
mNotificationHelper.onComplete(file);
writeFiletoAndroidMediaDB(context, file);
}
}
});
}
开发者ID:adnbsr,项目名称:android-ytdl,代码行数:40,代码来源:Common.java
示例3: downloadFile
import com.koushikdutta.ion.ProgressCallback; //导入依赖的package包/类
public Future<Response<File>> downloadFile(Context context, String url, final DownloadedCallback callback) {
File file = get(url);
if (file.exists()) {
file.setLastModified(Time.get());
callback.onProgress(0, 0, true);
callback.onSuccess(file);
return null;
} else {
return ion.build(context)
.load(url)
.progress(new ProgressCallback() {
@Override
public void onProgress(final long downloaded, final long total) {
Util.runOnUiThread(new Runnable() {
@Override
public void run() {
callback.onProgress(downloaded, total, false);
}
});
}
})
.write(file)
.withResponse()
.setCallback(new FutureCallback<Response<File>>() {
@Override
public void onCompleted(Exception e, Response<File> result) {
callback.onProgress(0, 0, true);
if (result != null && result.getHeaders() != null && result.getHeaders().code() / 100 != 2) {
if (result.getResult() != null) {
delete(result.getResult());
}
callback.onFail(true);
return;
}
if (e != null && !(e instanceof CancellationException)) {
e.printStackTrace();
if (result != null && result.getResult() != null) {
delete(result.getResult());
}
callback.onFail(false);
return;
}
if (result != null && result.getResult() != null) {
put(result.getResult());
callback.onSuccess(result.getResult());
}
}
});
}
}
开发者ID:eugenkiss,项目名称:chanobol,代码行数:54,代码来源:FileCache.java
示例4: startDownload
import com.koushikdutta.ion.ProgressCallback; //导入依赖的package包/类
public void startDownload()
{
if(mLessonID!=null)
{
BE_PUB_LESSON lessonData = new FlyingContentDAO().selectWithLessonID(mLessonID);
mContentURL=lessonData.getBECONTENTURL();
//删除以前同样内容
String path= new FlyingContentDAO().selectWithLessonID(mLessonID).getLocalURLOfContent();
if(path!=null)
{
File contenFile = new File(path);
if (contenFile.exists())
{
FlyingFileManager.deleteFile(path);
}
/*
FlyingOkHttp.downloadFile(mContentURL,path,new FlyingOkHttp.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
long process = 100 * bytesRead / contentLength;
Intent updateIntent = new Intent(mLessonID);
updateIntent.putExtra(ShareDefine.KIntenCorParameter, process);
MyApplication.getInstance().sendBroadcast(updateIntent);
}
},null);
*/
Ion.with(MyApplication.getInstance())
.load(mContentURL)
.progress(new ProgressCallback() {
@Override
public void onProgress(long downloaded, long total) {
long process = 100 * downloaded / total;
Intent updateIntent = new Intent(mLessonID);
updateIntent.putExtra(ShareDefine.KIntenCorParameter, process);
MyApplication.getInstance().sendBroadcast(updateIntent);
}
})
.write(FlyingFileManager.getFile(path))
.setCallback(new FutureCallback<File>() {
@Override
public void onCompleted(Exception e, File result) {
//finishDownloadTask();
}
});
}
}
}
开发者ID:birdcopy,项目名称:Android-Birdcopy-Application,代码行数:59,代码来源:FlyngDirectDownloader.java
注:本文中的com.koushikdutta.ion.ProgressCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论