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

Add More Callbacks to DownloadListener #18

Open
ebitogu opened this issue Feb 17, 2020 · 1 comment
Open

Add More Callbacks to DownloadListener #18

ebitogu opened this issue Feb 17, 2020 · 1 comment

Comments

@ebitogu
Copy link

ebitogu commented Feb 17, 2020

Thanks so much for this library. I was using Fetch but it has alot of bugs, I just bumped into this library few mins ago. Can you add more callbacks into the DownloadListener like onResumed,onPaused,onStarted,onCancelled like below

private static DownloadListener downloadListener = new DownloadListener() {

        @Override
        public void onProgress(int progress) {
            DownloadInfo downloadInfo = getDownloadInfo();
            handleDownloadProgress(downloadInfo);
        }

        @Override
        public void onFailed() {
            DownloadInfo downloadInfo = getDownloadInfo();
            DownloadInfo.Status downloadStatus = downloadInfo.getStatus();

           //Like, I am confused here how would I know if the fail was as a result of failed or paused

            if (downloadStatus == DownloadInfo.Status.PAUSED) {
                handlePausedDownload(downloadInfo);
            } else if (downloadStatus == DownloadInfo.Status.FAILED) {
                handleDownloadError(downloadInfo);
            }
        }

        @Override
        public void onSuccess() {
            DownloadInfo downloadInfo = getDownloadInfo();
            handleCompletedDownload(downloadInfo);
        }

      //Please add the following
       @Override
        public void onResumed(){
     
         }
 
       @Override
       public void onPaused(){
       }
 
       @Override
       public void onCancelled(){
       }
  
  };

By the way how can I cancel a download and also how do I know if a download was paused. Very important. Thanks.

@huxq17
Copy link
Owner

huxq17 commented Feb 17, 2020

Did you refer to this classDownloadListActivity,bindData and onClick method show you how to handle download status.

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