一行代码即可监听 App 中所有网络链接的上传以及下载进度,包括 Glide 的图片加载进度

ProgressManager

项目地址:JessYanCoding/ProgressManager 

简介:一行代码即可监听 App 中所有网络链接的上传以及下载进度,包括 Glide 的图片加载进度

Jcenter Build Status API License Author QQ-Group

Listen the progress of downloading and uploading in Okhttp (compatible Retrofit and Glide).

中文说明

Overview

gif

Introduction

ProgressManager a line of code to listen App all the links and upload the progress of the network, including Glide picture loading progress, to achieve the principle of similar EventBus, you can be in anywhere in App, the number of listeners to Url address as an identifier, registered to the framework, when this Url address haves to download or upload the action, the framework will take the initiative to call All listeners registered with this Url address are synchronized to multiple modules.

Feature

  • Easy to use, just a line of code to listen progress.
  • Multi-platform support, support Okhttp , Retrofit , Glide ,Use Okhttp native Api , there is no compatibility problem.
  • Low coupling, the actual request and the progress of the receiver does not exist directly or indirectly, that can be anywhere in App to receive progress information.
  • Low intrusion, use this framework you do not need to change the code before uploading or downloading, ie using or not using this framework does not affect the original code.
  • Multi-end synchronization, the same data source upload or download progress can specify a number of different receivers, less to use EventBus achieve multiple port synchronization update progress.
  • Support multi-file upload.
  • Support URL redirection.
  • Automatic management of the listener, less to manually cancel the trouble of the listener.
  • The default run in the main line layer, less to switch the thread of trouble.
  • Lightweight framework, does not contain any three-party library, very small size.

Download

 implementation 'me.jessyan:progressmanager:1.5.0'

Usage

Step 1

 // When building OkHttpClient, the OkHttpClient.Builder() is passed to the with() method to initialize the configuration
 OkHttpClient = ProgressManager.getInstance().with(new OkHttpClient.Builder())
                .build();

Step 2

 // Glide load
 ProgressManager.getInstance().addResponseListener(IMAGE_URL, getGlideListener());


 // Okhttp/Retofit download
 ProgressManager.getInstance().addResponseListener(DOWNLOAD_URL, getDownloadListener());


 // Okhttp/Retofit upload
 ProgressManager.getInstance().addRequestListener(UPLOAD_URL, getUploadListener());

ProGuard

 -keep class me.jessyan.progressmanager.** { *; }
 -keep interface me.jessyan.progressmanager.** { *; }

猜你喜欢

转载自blog.csdn.net/u014608640/article/details/82145402