工具库

来源:互联网 发布:贵州软件评测机构 编辑:程序博客网 时间:2024/06/06 03:08
        ----[摘自](https://github.com/Trinea/android-open-project)

一、依赖注入
减少View、服务、资源简化初始化、事件绑定等重复繁琐工作。
1、AndroidAnnotations(Code Diet)
文档介绍:https://github.com/excilys/androidannotations/wiki
特点:(1) 依赖注入:包括 view,extras,系统服务,资源等等
(2) 简单的线程模型,通过 annotation 表示方法运行在 ui 线程还是后台线程
(3) 事件绑定:通过 annotation 表示 view 的响应事件,不用在写内部类
(4) REST 客户端:定义客户端接口,自动生成 REST 请求的实现
(5) 没有你想象的复杂:AndroidAnnotations 只是在在编译时生成相应子类
(6) 不影响应用性能:仅 50kb,在编译时完成,不会对运行时有性能影响。
其他:与 roboguice 的比较:roboguice 通过运行时读取 annotations 进行反射,所以可能影响应用性能,而 AndroidAnnotations 在编译时生成子类,所以对性能没有影响
2、roboguice
处理很多代码异常,利用 annotation 使得更少的代码完成项目
文档介绍:https://github.com/roboguice/roboguice/wiki
3、 butterknife
利用 annotation 帮你快速完成 View 的初始化,减少代码
文档介绍:http://jakewharton.github.io/butterknife/
4、Dagger
依赖注入,适用于 Android 和 Java
原理剖析文档:[Dagger](http://a.codekk.com/detail/Android/扔物线/Dagger 源码解析)
文档介绍:http://square.github.io/dagger/
5、AutoParcel
注解自动生成Parcelable实现代码的库,可以简化构造函数,方便IDE代码自动完成,方便测试,前向兼容,生成不可变的对象。
这篇文章详细介绍了它的使用方法:https://passy.svbtle.com/simpler-android-apis-with-autoparcel
文档介绍:https://github.com/frankiesardo/auto-parcel

二、图片缓存
1、Android-Universal-Image-Loader
目前使用最广泛的图片缓存,支持主流图片缓存的绝大多数特性。
原理剖析文档:[Android-Universal-Image-Loader](http://a.codekk.com/detail/Android/huxian99/Android Universal Image Loader 源码分析)
Demo 地址:https://github.com/Trinea/TrineaDownload/blob/master/universal-imageloader-demo.apk?raw=true
文档介绍:http://www.intexsoft.com/blog/item/74-universal-image-loader-part-3.html
2、picasso
square 开源的图片缓存
文档介绍:http://square.github.io/picasso/
特点:(1)可以自动检测 adapter 的重用并取消之前的下载
(2)图片变换
(3)可以加载本地资源
(4)可以设置占位资源
(5)支持 debug 模式
3、Cube ImageLoader
阿里巴巴一淘使用的图片加载,综合了 Android-Universal-Image-Loader 和 square 等组件优点,简单易用,良好的中文文档支持
文档介绍:http://cube-sdk.liaohuqiu.net/
4、fresco
一款强大的图片缓存工具,由 Facebook 开发
文档介绍:http://frescolib.org/
特点:(1) 两个内存缓存加上磁盘缓存构成了三级缓存
(2) 支持流式,可以类似网页上模糊渐进式显示图片
(3) 对多帧动画图片支持更好,如 Gif、WebP
(4) 更多样的显示,如圆角、进度条、点击重试、自定义对焦点
(5) 更多样的加载,如支持 EXIF、全面支持 WebP
(6) 支持 Android 2.3+
5、Glide
Glide 是一个 android 平台上的快速和高效的开源的多媒体资源管理库,提供 多媒体文件的压缩,内存和磁盘缓存, 资源池的接口。
它可以最大性能地在 Android 设备上读取、解码、显示图片和视频。Glide 可以将远程的图片、视频、动画图片等缓存在设备本地便于提高用户浏览图片的流畅体验。
项目地址:https://github.com/bumptech/glide
特点:
(1) GIF 动画的解码
(2) 本地视频剧照的解码
(3) 支持缩略图
(4) Activity 生命周期的集成
(5) 转码的支持
(6) 动画的支持
(7) OkHttp 和 Volley 的支持

三、网络请求
1、Volley
Google 提供的网络通信库,使得网络请求更简单、更快速。数据不大但通信频繁。
JSON,图像等的异步下载;
网络请求的排序(scheduling)
网络请求的优先级处理
缓存
多级别取消请求
和Activity和生命周期的联动(Activity结束时同时取消所有网络请求)
文档介绍:http://commondatastorage.googleapis.com/io-2013/presentations/110%20-%20Volley-%20Easy,%20Fast%20Networking%20for%20Android.pdf
2、Asynchronous Http Client for Android
Android 异步 Http 请求
文档介绍:http://loopj.com/android-async-http/
特点:(1) 在匿名回调中处理请求结果
(2) 在 UI 线程外进行 http 请求
(3) 文件断点上传
(4) 智能重试
(5) 默认 gzip 压缩
(6) 支持解析成 Json 格式
(7) 可将 Cookies 持久化到 SharedPreferences
3、android-query
异步加载,更少代码完成 Android 加载
文档介绍:https://code.google.com/p/android-query/#Why_AQuery?
特点:https://code.google.com/p/android-query/#Why_AQuery?
4、Async Http Client
Java 异步 Http 请求
文档介绍:http://sonatype.github.io/async-http-client/
5、Ion
支持图片、json、http post 等异步请求
文档介绍:https://github.com/koush/ion#more-examples
6、Http Request
文档介绍:https://github.com/kevinsawicki/http-request#examples
7、okhttp
square 开源的 http 工具类
文档介绍:http://square.github.io/okhttp/
特点:(1) 支持 SPDY( http://zh.wikipedia.org/wiki/SPDY )协议。SPDY 协议是 Google 开发的基于传输控制协议的应用层协议,通过压缩,多路复用(一个 TCP 链接传送网页和图片等资源)和优先级来缩短加载时间。
(2) 如果 SPDY 不可用,利用连接池减少请求延迟
(3) Gzip 压缩
(4) Response 缓存减少不必要的请求
8、Retrofit
RESTFUL API 设计
文档介绍:http://square.github.io/retrofit/
9、RoboSpice
Android 异步网络请求工具,支持缓存、REST 等等 址:https://github.com/stephanenicolas/RoboDemo/downloads
10、TwistVolley
TwistVolley 是对 Volley 的一个封装库。提供类似 Picasso 一样的串联式 API。使得使用 Volley 更加方便。
项目地址:https://github.com/TwistedEquations/TwistVolley
11、OkHttpFinal
一个对OkHttp封装的简单易用型HTTP请求和文件下载管理框架
Demo 地址:https://github.com/pengjianbo/OkHttpFinal

四、数据库 orm 工具包
orm 的 db 工具类,简化建表、查询、更新、插入、事务、索引的操作
1、greenDAO
Android Sqlite orm 的 db 工具类
文档介绍:http://greendao-orm.com/documentation/
官网网址:http://greendao-orm.com/
特点:(1) 性能佳
(2) 简单易用的 API
(3) 内存小好小
(4) 库大小小
2、GreenDaoUpgradeHelper
greenDAO的数据库升级帮助类,只需一行代码解决数据库升级
项目地址:https://github.com/yuweiguocn/GreenDaoUpgradeHelper
3、ActiveAndroid
Android Sqlite orm 的 db 工具类
文档介绍:https://github.com/pardom/ActiveAndroid/wiki/_pages
4、Sprinkles
Android Sqlite orm 的 db 工具类,比较显著的特点就是配合 https://github.com/square/retrofit 能保存从服务器获取的数据
文档介绍:http://emilsjolander.github.io/blog/2013/12/18/android-with-sprinkles/
5、Realm
移动端的数据库,适用于 Phone、Tablet、Wearable,支持 ORM,线程安全、支持连表及数据库加密,比 SQLite 性能更好
文档介绍:http://realm.io/docs/java/0.72.0/
6、ormlite-android
文档介绍:http://ormlite.com/sqlite_java_android_orm.shtml
7、Schematic
根据 SQLite 生成 ContentProvider
项目地址:https://github.com/SimonVT/schematic
8、DBFlow
Android SQLite ORM 工具库。综合了 Active Android, Schematic, Ollie,Sprinkles 等库的优点;通过注解实现,性能好;能生成 ContentProvider。
文档介绍:https://github.com/Raizlabs/DBFlow#usage-docs
9、SnappyDB
是一个key-value数据库,非常流行的NoSQL数据库。

0 0