Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在一个按钮上连续点击触发下载及停止下载时会出各种问题 #82

Open
feer921 opened this issue Nov 24, 2014 · 0 comments

Comments

@feer921
Copy link

feer921 commented Nov 24, 2014

使用FinalHttp下载文件:

支持断点续传,随时停止下载任务 或者 开始任务
FinalHttp fh = new FinalHttp();
//调用download方法开始下载
HttpHandler handler = fh.download("http://www.xxx.com/下载路径/xxx.apk", //这里是下载的路径
true,//true:断点续传 false:不断点续传(全新下载)
"/mnt/sdcard/testapk.apk", //这是保存到本地的路径
new AjaxCallBack() {
@OverRide
public void onLoading(long count, long current) {
textView.setText("下载进度:"+current+"/"+count);
}

            @Override  
            public void onSuccess(File t) {  
                textView.setText(t==null?"null":t.getAbsoluteFile().toString());  
            }  

        });  

//调用stop()方法停止下载
handler.stop();

详细描述:比如一个按钮为启动下载(传入了true为可断点续传)及停止下载,但不知道是不是因为每次点击一次下载HttpHandler 会重新new出对象的原因,会造成多线程在下载同一个文件,造成onLoading()回调出的进度混乱,且有可以造成启动不了下载功能,且有可能造成下载完成后的文件有错误。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant