Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Can we use this lib on a method that has param? #169

@leohan1992

Description

@leohan1992

I've tried this

@AfterPermissionGranted(1001)
   private void download(String url) {
       String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
       if (EasyPermissions.hasPermissions((Context) mView, perms)) {
           ProgressDialog progressDialog = new ProgressDialog((Context) mView);
           progressDialog.setMax(100);
           progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
           progressDialog.setCancelable(false);
           String apkPath = AppConstants.FILE_DOWNLOAD_PATH + "/" + System.currentTimeMillis() + ".apk";
           DownloadUtil downloadUtil = new DownloadUtil(url, apkPath, new ProgressListener() {
               @Override
               public void update(long bytesRead, long contentLength, boolean done) {
                   if (done) {
                       if (progressDialog.isShowing()) {
                           progressDialog.dismiss();
                       }
                       ApkUtil.installApk((Context) mView, apkPath);
                   }
                   progressDialog.setProgress((int) ((bytesRead * 100) / contentLength));
               }

               @Override
               public void onFailed() {
                   if (progressDialog.isShowing()) {
                       progressDialog.dismiss();
                   }
                   ToastUtil.makeShort((Context) mView, ((Context) mView).getString(R.string.network_error_tips));
               }

               @Override
               public void onStart() {
                   if (!progressDialog.isShowing()) {
                       progressDialog.show();
                   }
               }
           });
           downloadUtil.start();
       } else {
           EasyPermissions.requestPermissions((MainActivity) mView, "我们需要外部存储用于下载更新", 1001, perms);
       }

it will request permission,but didn't excute this method again when permission granted.Can I use @AfterPermissionGranter on a method that with param?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions