• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ProgressManager: Listen the progress of downloading and uploading in Okhttp (com ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ProgressManager

开源软件地址:

https://gitee.com/JessYanCoding/ProgressManager

开源软件介绍:

ProgressManager

Jcenter Build Status Android Arsenal API License Author QQ-Group

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

Overview

gif

Introduction

ProgressManager 一行代码即可监听 App 中所有网络链接的上传以及下载进度,包括 Glide 的图片加载进度,实现原理类似 EventBus,你可在 App 中的任何地方,将多个监听器,以 Url 地址作为标识符,注册到本框架,当此 Url 地址存在下载或者上传的动作时,框架会主动调用所有使用此 Url 地址注册过的监听器,达到多个模块的同步更新.

框架的构思和实现可以看这篇文章

Feature

  • 使用简单,只需一行代码即可实现进度监听.
  • 多平台支持,支持 Okhttp , Retrofit , Glide ,使用 Okhttp 原生 Api ,不存在兼容问题.
  • 低耦合,实际请求端和进度接收端并不存在直接或间接的关联关系,即可以在 App 任何地方接收进度信息.
  • 侵入性低,使用本框架你并不需要更改之前进行上传或下载的代码,即使用或不使用本框架并不会影响到原有的代码.
  • 多端同步,同一个数据源的上传或下载进度可以指定多个不同的接收端,少去了使用 EventBus 实现多个端口同步更新进度.
  • 支持多文件上传.
  • 支持 URL 重定向.
  • 自动管理监听器,少去了手动注销监听器的烦恼.
  • 默认运行在主线层,少去了切换线程的烦恼.
  • 轻量级框架,不包含任何三方库,体积极小.

Download

 implementation 'me.jessyan:progressmanager:1.5.0'

Usage

Step 1

 // 构建 OkHttpClient 时,将 OkHttpClient.Builder() 传入 with() 方法,进行初始化配置 OkHttpClient = ProgressManager.getInstance().with(new OkHttpClient.Builder())                .build();

Step 2

 // Glide 下载监听 ProgressManager.getInstance().addResponseListener(IMAGE_URL, getGlideListener()); // Okhttp/Retofit 下载监听 ProgressManager.getInstance().addResponseListener(DOWNLOAD_URL, getDownloadListener()); // Okhttp/Retofit 上传监听 ProgressManager.getInstance().addRequestListener(UPLOAD_URL, getUploadListener());

ProGuard

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

About Me

License

 Copyright 2017, jessyan   Licensed under the Apache License, Version 2.0 (the "License");   you may not use this file except in compliance with the License.   You may obtain a copy of the License at       http://www.apache.org/licenses/LICENSE-2.0   Unless required by applicable law or agreed to in writing, software   distributed under the License is distributed on an "AS IS" BASIS,   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the License for the specific language governing permissions and   limitations under the License.

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap