| | |
| | | |
| | | import static com.blankj.utilcode.util.StringUtils.getString; |
| | | |
| | | import android.animation.Animator; |
| | | import android.animation.ValueAnimator; |
| | | import android.annotation.SuppressLint; |
| | | import android.app.DownloadManager; |
| | | import android.content.Context; |
| | |
| | | public void run() { |
| | | // TODO Auto-generated method stub |
| | | progressBar.setProgress(dl_progress); |
| | | tv_pro.setText((downloadBytes * 100 / totalBytes) + "%"); |
| | | tv_pro_percent.setText((downloadBytes * 100 / totalBytes) + "/100"); |
| | | ValueAnimator animator = ValueAnimator.ofInt(progressBar.getProgress(), dl_progress); |
| | | animator.setDuration(100); |
| | | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| | | @Override |
| | | public void onAnimationUpdate(ValueAnimator animation) { |
| | | int currentValue = (int) animation.getAnimatedValue(); |
| | | progressBar.setProgress(currentValue); |
| | | tv_pro.setText(currentValue + "%"); |
| | | tv_pro_percent.setText(currentValue + "/100"); |
| | | } |
| | | }); |
| | | animator.start(); |
| | | // tv_pro.setText((downloadBytes * 100 / totalBytes) + "%"); |
| | | // tv_pro_percent.setText((downloadBytes * 100 / totalBytes) + "/100"); |
| | | } |
| | | }; |
| | | |
| | |
| | | DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); |
| | | request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);//下载进行中和下载完成的通知栏是否显示 |
| | | //用于设置下载时时候在状态栏显示通知信息 |
| | | request.setNotificationVisibility(request.VISIBILITY_VISIBLE); |
| | | request.allowScanningByMediaScanner();//设置允许被扫描到 |
| | | request.setVisibleInDownloadsUi(true);//下载的文件可以被系统的Downloads应用扫描到并管理 |
| | | |