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

Bug #9

Closed
e4basil opened this issue Jan 12, 2016 · 4 comments
Closed

Bug #9

e4basil opened this issue Jan 12, 2016 · 4 comments
Assignees

Comments

@e4basil
Copy link

e4basil commented Jan 12, 2016

   protected void FileDownloadManager() {
         if (isNetworkAvailable()) {


        String[] URLS = {
                "http://www.test............mp3",
                "http://www.test2..........mp3"};
        downloadListener = createLis();
        int i = 0;
        for (String url : URLS) {


            FileDownloader.getImpl().create(url)

                    .setPath(locationCreation() + File.separator + url.substring(url.lastIndexOf("/") + 1))
                    .setListener(downloadListener)
                    .setAutoRetryTimes(1)
                    .setTag(i + 1)
                    .setCallbackProgressTimes(1)
                    .ready();

            i++;
        }



        FileDownloader.getImpl().start(downloadListener, true);


    }
}

private FileDownloadListener createLis() {

    return new FileDownloadListener() {
        @Override
        protected void pending(BaseDownloadTask task, int soFarBytes, int totalBytes) {
            if (task.getListener() != downloadListener) {
                return;
            }
            Log.d(TAG, "pending() :" + task.getTag());
        }

        @Override
        protected void connected(BaseDownloadTask task, String etag, boolean isContinue, int soFarBytes, int totalBytes) {
            super.connected(task, etag, isContinue, soFarBytes, totalBytes);
            if (task.getListener() != downloadListener) {
                return;
            }
            Log.d(TAG,"connected() :"+task.getTag());
        }


        @Override
        protected void progress(BaseDownloadTask task, int soFarBytes, int totalBytes) {
            if (task.getListener() != downloadListener) {
                return;
            }
            Log.d(TAG,"progress() :"+task.getTag());
        }

        @Override
        protected void blockComplete(BaseDownloadTask task) {
            if (task.getListener() != downloadListener) {
                return;
            }
            Log.d(TAG,"blockComplete() :"+task.getTag());
        }

        @Override
        protected void retry(BaseDownloadTask task, Throwable ex, int retryingTimes, int soFarBytes) {
            super.retry(task, ex, retryingTimes, soFarBytes);
            if (task.getListener() != downloadListener) {
                return;
            }
            Log.d(TAG,"retry() :"+task.getTag());
        }

        @Override
        protected void completed(BaseDownloadTask task) {
            if (task.getListener() != downloadListener) {
                return;
            }

            if (task.isReusedOldFile()) {

            } else {

            }
            Log.d(TAG,"completed() :"+task.getTag());
        }

        @Override
        protected void paused(BaseDownloadTask task, int soFarBytes, int totalBytes) {
            if (task.getListener() != downloadListener) {
                return;
            }
            Log.d(TAG,"paused() :"+task.getTag());
        }

        @Override
        protected void error(BaseDownloadTask task, Throwable e) {
            if (task.getListener() != downloadListener) {
                return;
            }
            Log.d(TAG,"error() :"+task.getTag());
            Log.d(TAG, "error() : "+e.getMessage());
        }

        @Override
        protected void warn(BaseDownloadTask task) {
            if (task.getListener() != downloadListener) {
                return;
            }
            Log.d(TAG,"warn() :"+task.getTag());
        }
    };
}

it shows error() : sofar[377462] not equal total[-1]
but it downloads file

@Jacksgong
Copy link
Collaborator

Could you give me your download link, i will try and give you solution.


That means had read all bytes from remote but downloaded file's length not equal contentLength( we get the Content-Length from the header in the response object)

@Jacksgong Jacksgong self-assigned this Jan 12, 2016
@Jacksgong
Copy link
Collaborator

Thanks for your feedback very much.

These are Chunked transfer encoding datas (which gives Transfer-Encoding: chunked instead of Content-Length (don't know)) I will consider support this in next version.

@Jacksgong
Copy link
Collaborator

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

2 participants