AsyncTask的队列和它的整个进度 [英] AsyncTask queue and its entire progress

查看:177
本文介绍了AsyncTask的队列和它的整个进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没有开始编码呢。我试图找出哪些库,就在那里,什么API可以先提供。

I haven't started coding yet. I'm trying to figure out which libraries that is out there and what the API can offer first.

我要开始我的应用程序之前下载了大量的资源。基本上我将有一个SplashSreen,而显示正在下载该文件中的进度和进度条的的全部的下载资源的x数的过程。

I need to download a lot of resources before starting my app. Basically I'm going to have a "SplashSreen" and a progressbar that shows which file being downloaded and the progressbar for the entire progress of downloading the x-number of resources.

通过关于这个问题的一些讨论和教程看后,我认为会的AsyncTask做的工作。但它只是可以显示当前对象目前进度下载,而不是针对整个队列。

After looking through some discussions and tutorials on the subject, it seems to me that AsyncTask will do the job. But it's only possible to show the current progress for the current "object" being downloaded, and not for the entire queue.

任何人都可以帮助我在这里,给我一些教程或东西钻进去?

Could anyone help me out here, give me some tutorials or something to dig into?

TBH;我甚至不知道如果AsyncTask的就是我正在寻找在此方案中。基本上,我需要的东西,可以下载的资源,放在一个队列中,让我知道了整个队列的进度,以及资源(它的名字)是在下载一定的时间。

TBH; I'm not even sure if AsyncTask is what I'm looking for in this scenario. Basically I need something that can download resources, put in a queue, and let me know the progress of the entire queue, and which resource (name of it) being download at a certain time.

谢谢!

推荐答案

当然是一个的AsyncTask 可以做的工作。只要把所有的文件,其中显示的进展AsyncTask的。

Of course an AsyncTask can do the job. Just put all your files in a asyncTask which display the progress.

class InitTask extends AsyncTask<Void, Integer, Boolean> {
    private List<String> mNbFiles;

    public InitTask(List<String> filesURL)
    {
        super();
        mFilesURL = filesURL;
    }

    @Override
    protected void onPreExecute() {
        //show and init your progress bar here...
        super.onPreExecute();
    }

    @Override
    protected Boolean doInBackground(Void... params) {

        for(int i = 0 ; i < mNbFiles.size() ; ++i){
            //download one file ...
            publishProgress(i);
        }
    }
}

我希望这会帮助你。如果您有任何问题发表评论。

I hope this will help you. Comment if you have any question.

这篇关于AsyncTask的队列和它的整个进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆