Fast-android-networking: Downloading file progress bug

Created on 17 Mar 2017  ·  10Comments  ·  Source: amitshekhariitbhu/Fast-Android-Networking

Hi creator of this useful library. I try download large file 80mb. So, exactly downloading of file are complete without bug. But onProgress method, stop call sometime are magically principe, and never called while file will be downloaded completely. What I'm do wrong ? Please help me.

final File temp = Tool.createTempFile();

        AndroidNetworking.download(url, temp.getParentFile().getPath(), temp.getName())
                .setTag("downloadFile")
                .setPriority(Priority.HIGH)
                .build()
                .setDownloadProgressListener(new DownloadProgressListener() {

                    private int prevProgress;

                    @Override
                    public void onProgress(final long bytesDownloaded, final long totalBytes) {
                        final int progress = (int) (bytesDownloaded * 100 / totalBytes);

                        if (progress != prevProgress) {
                                    progressBar.setProgress(progress);
                                    percent.setText(progress + " %");
                                    prevProgress = progress;

                                    Log.e("progress", "total = " + totalBytes +
                                            " loaded = " + bytesDownloaded + " percentage = " + progress + "%");
                       }
                    }
                })
                .startDownload(new DownloadListener() {
                    @Override
                    public void onDownloadComplete() {
                        progressBar.setProgress(100);
                        cancel.setEnabled(false);
                        IntentFilter filter = new IntentFilter();
                        filter.addAction(DataImportService.SERVICE_FILTER);
                        activity.registerReceiver(broadcastReceiver, filter);
                    }

                    @Override
                    public void onError(ANError error) {
                        progressBar.setVisibility(View.GONE);
                        progressBar.setProgress(0);
                        percent.setText(getContext().getResources().getString());
                        dismiss();
                    }
                });

        progressBar.setProgress(0);
        progressBar.setVisibility(View.VISIBLE);
question

All 10 comments

By seeing the code it seems perfect.

When I'm use debug all works perfect. I mean, wait on each call on breakpoint of onProgress method.

Because method call more than 1 run while percent are will be incremented. So, there I'm save UI updates execution time. No matter for this issue.

Any ideas how I can solve this issue ?

provide me the download Url, I will try it.

Fixed and uploaded the new version, but the final version will be released with more features and fixes. You can use the below:

compile 'com.amitshekhar.android:android-networking:0.5.0-RC1'

@smail2133 : Try it and give me feedback

It's works. Thank you. Good job.

Best regards,
Evgeny

18 марта 2017 г., в 09:13, AMIT SHEKHAR notifications@github.com написал(а):

Fixed and uploaded the new version, but the final version will be released with more features and fixes. You can use the below:

compile 'com.amitshekhar.android:android-networking:0.5.0-RC1'


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/amitshekhariitbhu/Fast-Android-Networking/issues/96#issuecomment-287522090, or mute the thread https://github.com/notifications/unsubscribe-auth/AFNhsa3wLg20Pyzz00SX6Ohgw4YMOvwrks5rm4QdgaJpZM4MgwTM.

Total bytes always provide me -1, when i download the file from server.

total = -1 always provide me.

Resolve this issue please.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ali-Khazaee picture Ali-Khazaee  ·  5Comments

anderscheow picture anderscheow  ·  5Comments

ExploiTR picture ExploiTR  ·  7Comments

rezasadeghi93 picture rezasadeghi93  ·  8Comments

amervelic picture amervelic  ·  4Comments