|
| 1 | +# ProgressManager |
| 2 | +[  ](https://bintray.com/jessyancoding/maven/progressmanager/1.1/link) |
| 3 | +[  ](https://travis-ci.org/JessYanCoding/ProgressManager) |
| 4 | +[  ](https://developer.android.com/about/versions/android-4.0.html) |
| 5 | +[  ](http://www.apache.org/licenses/LICENSE-2.0) |
| 6 | + |
| 7 | + |
| 8 | +## Listen the progress of downloading and uploading in Okhttp (compatible Retrofit and Glide). |
| 9 | + |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +## Introduction |
| 16 | +**ProgressManager** 一行代码即可监听 **App** 中所有网络链接的上传以及下载进度,包括 **Glide** 的图片加载进度,实现原理类似 **EventBus**,你可在 **App** 中的任何地方,将多个监听器,以 **Url** 地址作为标识符,注册到本框架,当此 **Url** 地址存在下载或者上传的动作时,框架会主动调用所有使用此 **Url** 地址注册过的监听器,达到多个模块的同步更新 |
| 17 | + |
| 18 | +## Feature |
| 19 | +* 使用简单,只需一行代码即可实现进度监听 |
| 20 | + |
| 21 | +* 低耦合,实际请求端和进度接收端并不存在直接或间接的关联关系,即可以在 **App** 任何地方接收进度信息 |
| 22 | +* 侵入性低,使用本框架你并不需要更改之前进行上传或下载的代码,即使用或不使用本框架并不会影响到原有的代码 |
| 23 | +* 多端同步,同一个数据源的上传或下载进度可以指定多个不同的接收端,少去了使用 **EventBus** 实现多个端口同步更新进度 |
| 24 | +* 自动管理监听器,少去了手动注销监听器的烦恼 |
| 25 | +* 默认运行在主线层,少去了切换线程的烦恼 |
| 26 | +* 多平台支持,支持 **Okhttp** , **Retrofit** , **Glide** |
| 27 | + |
| 28 | +## Download |
| 29 | +``` gradle |
| 30 | + compile 'me.jessyan:progressmanager:1.1' |
| 31 | +``` |
| 32 | + |
| 33 | +## Usage |
| 34 | +### Step 1 |
| 35 | +``` java |
| 36 | + // 构建 OkHttpClient 时,将 OkHttpClient.Builder() 传入 with() 方法,进行初始化配置 |
| 37 | + OkHttpClient = ProgressManager.getInstance().with(new OkHttpClient.Builder()) |
| 38 | + .build(); |
| 39 | +``` |
| 40 | + |
| 41 | +### Step 2 |
| 42 | +``` java |
| 43 | + // Glide 下载监听 |
| 44 | + ProgressManager.getInstance().addResponseListener(IMAGE_URL, getGlideListener()); |
| 45 | + |
| 46 | + |
| 47 | + // Okhttp/Retofit 下载监听 |
| 48 | + ProgressManager.getInstance().addResponseListener(DOWNLOAD_URL, getDownloadListener()); |
| 49 | + |
| 50 | + |
| 51 | + // Okhttp/Retofit 上传监听 |
| 52 | + ProgressManager.getInstance().addRequestLisenter(UPLOAD_URL, getUploadListener()); |
| 53 | +``` |
| 54 | + |
| 55 | + |
| 56 | +## ProGuard |
| 57 | +``` |
| 58 | + -keep class me.jessyan.progressmanager.** { *; } |
| 59 | + -keep interface me.jessyan.progressmanager.** { *; } |
| 60 | +``` |
| 61 | + |
| 62 | + |
| 63 | +## About Me |
| 64 | +* **Email**: <jess.yan.effort@gmail.com> |
| 65 | +* **Home**: <http://jessyan.me> |
| 66 | +* **掘金**: <https://gold.xitu.io/user/57a9dbd9165abd0061714613> |
| 67 | +* **简书**: <http://www.jianshu.com/u/1d0c0bc634db> |
| 68 | + |
| 69 | +## License |
| 70 | +``` |
| 71 | + Copyright 2017, jessyan |
| 72 | +
|
| 73 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 74 | + you may not use this file except in compliance with the License. |
| 75 | + You may obtain a copy of the License at |
| 76 | +
|
| 77 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 78 | +
|
| 79 | + Unless required by applicable law or agreed to in writing, software |
| 80 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 81 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 82 | + See the License for the specific language governing permissions and |
| 83 | + limitations under the License. |
| 84 | +``` |
0 commit comments