Android 开源项目android-open-project工具库解析之(一) 依赖注入,图片缓存,网络相关,数据库orm工具包,Android公共库...
一、依賴注入DI?
通過依賴注入降低View、服務(wù)、資源簡化初始化。事件綁定等反復(fù)繁瑣工作
AndroidAnnotations(Code Diet)
android高速開發(fā)框架
項(xiàng)目地址:https://github.com/excilys/androidannotations
文檔介紹:https://github.com/excilys/androidannotations/wiki
官網(wǎng)網(wǎng)址:http://androidannotations.org/
特點(diǎn):(1) 依賴注入:包含view,extras,系統(tǒng)服務(wù),資源等等
(2) 簡單的線程模型。通過annotation表示方法執(zhí)行在ui線程還是后臺線程
(3) 事件綁定:通過annotation表示view的響應(yīng)事件,不用在寫內(nèi)部類
(4) RESTclient:定義client接口,自己主動(dòng)生成REST請求的實(shí)現(xiàn)
(5) 沒有你想象的復(fù)雜:AndroidAnnotations僅僅是在在編譯時(shí)生成對應(yīng)子類
(6) 不影響應(yīng)用性能:僅50kb。在編譯時(shí)完畢,不會(huì)對執(zhí)行時(shí)有性能影響。
PS:與roboguice的比較:roboguice通過執(zhí)行時(shí)讀取annotations進(jìn)行反射,所以可能影響應(yīng)用性能。而AndroidAnnotations在編譯時(shí)生成子類。所以對性能沒有影響
roboguice
幫你處理了非常多代碼異常,利用annotation使得更少的代碼完畢項(xiàng)目
項(xiàng)目地址:https://github.com/roboguice/roboguice
文檔介紹:https://github.com/roboguice/roboguice/wiki
butterknife
利用annotation幫你高速完畢View的初始化,降低代碼
項(xiàng)目地址:https://github.com/JakeWharton/butterknife
文檔介紹:http://jakewharton.github.io/butterknife/
Dagger
依賴注入,適用于Android和Java
項(xiàng)目地址:https://github.com/square/dagger
文檔介紹:http://square.github.io/dagger/
二、圖片緩存
Android-Universal-Image-Loader
圖片緩存。眼下使用最廣泛的圖片緩存,支持主流圖片緩存的絕大多數(shù)特性。
項(xiàng)目地址:https://github.com/nostra13/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
picasso
square開源的圖片緩存
項(xiàng)目地址:https://github.com/square/picasso
文檔介紹:http://square.github.io/picasso/
特點(diǎn):(1)能夠自己主動(dòng)檢測adapter的重用并取消之前的下載
(2)圖片變換
(3)能夠載入本地資源
(4)能夠設(shè)置占位資源
(5)支持debug模式
ImageCache
圖片緩存。包括內(nèi)存和Sdcard緩存
項(xiàng)目地址:https://github.com/Trinea/AndroidCommon
Demo地址:https://play.google.com/store/apps/details?id=cn.trinea.android.demo
文檔介紹:http://www.trinea.cn/android/android-imagecache/
特點(diǎn):(1)支持預(yù)取新圖片,支持等待隊(duì)列
(2)包括二級緩存。可自己定義文件名稱保存規(guī)則
(3)可選擇多種緩存算法(FIFO、LIFO、LRU、MRU、LFU、MFU等13種)或自己定義緩存算法
(4)可方便的保存及初始化恢復(fù)數(shù)據(jù)
(5)支持不同類型網(wǎng)絡(luò)處理
(6)可依據(jù)系統(tǒng)配置初始化緩存等
Cube ImageLoader
阿里巴巴一淘使用的圖片載入,綜合了Android-Universal-Image-Loader 和 square 等組件長處。簡單易用,良好的中文文檔支持
項(xiàng)目地址:https://github.com/etao-open-source/cube-sdk
Demo地址:https://github.com/liaohuqiu/cube-sdk/raw/master/cube-sdk-sample.apk
效果圖:文檔介紹:http://cube-sdk.liaohuqiu.net/
fresco
一款強(qiáng)大的圖片緩存工具,由 Facebook開發(fā)
項(xiàng)目地址:https://github.com/facebook/fresco
文檔介紹:http://frescolib.org/
特點(diǎn):(1) 兩個(gè)內(nèi)存緩存加上磁盤緩存構(gòu)成了三級緩存
(2) 支持流式,能夠類似網(wǎng)頁上模糊漸進(jìn)式顯示圖片
(3) 對多幀動(dòng)繪圖片支持更好,如 Gif、WebP
(4) 很多其它樣的顯示,如圓角、進(jìn)度條、點(diǎn)擊重試、自己定義對焦點(diǎn)
(5) 很多其它樣的載入,如支持 EXIF、全面支持 WebP
(6) 支持 Android 2.3+
三、網(wǎng)絡(luò)相關(guān)
Asynchronous Http Client for Android
Android異步Http請求
項(xiàng)目地址:https://github.com/loopj/android-async-http
文檔介紹:http://loopj.com/android-async-http/
特點(diǎn):(1) 在匿名回調(diào)中處理請求結(jié)果
(2) 在UI線程外進(jìn)行http請求
(3) 文件斷點(diǎn)上傳
(4) 智能重試
(5) 默認(rèn)gzip壓縮
(6) 支持解析成Json格式
(7) 可將Cookies持久化到SharedPreferences
android-query
異步載入,更少代碼完畢Android載入
項(xiàng)目地址:https://github.com/androidquery/androidquery 或 https://code.google.com/p/android-query/
Demo地址:https://play.google.com/store/apps/details?
id=com.androidquery
文檔介紹:https://code.google.com/p/android-query/#Why_AQuery?
特點(diǎn):https://code.google.com/p/android-query/#Why_AQuery?
Async Http Client
Java異步Http請求
項(xiàng)目地址:https://github.com/AsyncHttpClient/async-http-client
文檔介紹:http://sonatype.github.io/async-http-client/
Ion
支持圖片、json、http post等異步請求
項(xiàng)目地址:https://github.com/koush/ion
文檔介紹:https://github.com/koush/ion#more-examples
HttpCache
Http緩存
項(xiàng)目地址:https://github.com/Trinea/AndroidCommon
Demo地址:https://play.google.com/store/apps/details?
id=cn.trinea.android.demo
文檔介紹:http://www.trinea.cn/android/android-http-cache
特點(diǎn)是:(1) 依據(jù)cache-control、expires緩存http請求
(2) 支持同步、異步Http請求
(3) 在匿名回調(diào)中處理請求結(jié)果
(4) 在UI線程外進(jìn)行http請求
(5) 默認(rèn)gzip壓縮
Http Request
項(xiàng)目地址:https://github.com/kevinsawicki/http-request
文檔介紹:https://github.com/kevinsawicki/http-request#examples
okhttp
square開源的http工具類
項(xiàng)目地址:https://github.com/square/okhttp
文檔介紹:http://square.github.io/okhttp/
特點(diǎn):(1) 支持SPDY( http://zh.wikipedia.org/wiki/SPDY )協(xié)議。SPDY協(xié)議是Google開發(fā)的基于傳輸控制協(xié)議的應(yīng)用層協(xié)議,通過壓縮,多路復(fù)用(一個(gè)TCP鏈接傳送網(wǎng)頁和圖片等資源)和優(yōu)先級來縮短載入時(shí)間。
(2) 假設(shè)SPDY不可用,利用連接池降低請求延遲
(3) Gzip壓縮
(4) Response緩存降低不必要的請求
Retrofit
RESTFUL API設(shè)計(jì)
項(xiàng)目地址:https://github.com/square/retrofit
文檔介紹:http://square.github.io/retrofit/
RoboSpice
Android異步網(wǎng)絡(luò)請求工具。支持緩存、REST等等
項(xiàng)目地址:https://github.com/stephanenicolas/robospice
Demo地址:https://github.com/stephanenicolas/RoboDemo/downloads
Droppy
支持多種樣式的下拉菜單
項(xiàng)目地址:https://github.com/shehabic/Droppy
四、數(shù)據(jù)庫 orm工具包
orm的db工具類。簡化建表、查詢、更新、插入、事務(wù)、索引的操作
greenDAO
Android Sqlite orm的db工具類
項(xiàng)目地址:https://github.com/greenrobot/greenDAO
文檔介紹:http://greendao-orm.com/documentation/
官網(wǎng)網(wǎng)址:http://greendao-orm.com/
特點(diǎn):(1) 性能佳
(2) 簡單易用的API
(3) 內(nèi)存小好小
(4) 庫大小小
ActiveAndroid
Android Sqlite orm的db工具類
項(xiàng)目地址:https://github.com/pardom/ActiveAndroid
文檔介紹:https://github.com/pardom/ActiveAndroid/wiki/_pages
Sprinkles
Android Sqlite orm的db工具類,比較顯著的特點(diǎn)就是配合 https://github.com/square/retrofit 能保存從server獲取的數(shù)據(jù)
項(xiàng)目地址:https://github.com/emilsjolander/sprinkles
文檔介紹:http://emilsjolander.github.io/blog/2013/12/18/android-with-sprinkles/
Realm
移動(dòng)端的數(shù)據(jù)庫,適用于 Phone、Tablet、Wearable。支持 ORM,線程安全、支持連表及數(shù)據(jù)庫加密,比 SQLite 性能更好
項(xiàng)目地址:https://github.com/realm/realm-java
文檔介紹:http://realm.io/docs/java/0.72.0/
ormlite-android
項(xiàng)目地址:https://github.com/j256/ormlite-android
文檔介紹:http://ormlite.com/sqlite_java_android_orm.shtml
Schematic
依據(jù)SQLite生成ContentProvider
項(xiàng)目地址:https://github.com/SimonVT/schematic
DBFlow
Android SQLite ORM工具庫。
綜合了 Active Android, Schematic, Ollie,Sprinkles等庫的長處;通過注解實(shí)現(xiàn),性能好;能生成ContentProvider。
項(xiàng)目地址:https://github.com/Raizlabs/DBFlow
文檔介紹:https://github.com/Raizlabs/DBFlow#usage-docs
五、Android公共庫
Guava
Google的基于java1.6的類庫集合的擴(kuò)展項(xiàng)目,包含collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O等等. 這些高質(zhì)量的API能夠使你的JAVa代碼更加優(yōu)雅,更加簡潔
項(xiàng)目地址:https://code.google.com/p/guava-libraries/
文檔介紹:https://code.google.com/p/guava-libraries/wiki/GuavaExplained
Volley
Google提供的網(wǎng)絡(luò)通信庫,使得網(wǎng)絡(luò)請求更簡單、更高速
項(xiàng)目地址:https://android.googlesource.com/platform/frameworks/volley
文檔介紹:http://commondatastorage.googleapis.com/io-2013/presentations/110%20-%20Volley-%20Easy,%20Fast%20Networking%20for%20Android.pdf
AndroidCommon
Android公共庫
項(xiàng)目地址:https://github.com/Trinea/AndroidCommon
Demo地址:https://play.google.com/store/apps/details?id=cn.trinea.android.demo
文檔介紹:http://www.trinea.cn/android/android-common-lib/
包含:(1)緩存(圖片緩存、預(yù)取緩存、網(wǎng)絡(luò)緩存)
(2) 公共View(下拉及底部載入很多其它ListView、底部載入很多其它ScrollView、滑動(dòng)一頁Gallery)
(3) Android經(jīng)常使用工具類(網(wǎng)絡(luò)、下載、Android資源操作、shell、文件、Json、隨機(jī)數(shù)、Collection等等)
shipfaster
整合了Dagger Otto Retrofit Robolectric Picasso OkHttp,方便高速開發(fā)
項(xiàng)目地址:https://github.com/pyricau/shipfaster
CleanAndroidCode
整合了Dagger Otto AndroidAnnotations,方便高速開發(fā)
項(xiàng)目地址:https://github.com/pyricau/CleanAndroidCode
xUtils
基于Afinal。包括DbUtils、ViewUtils、HttpUtils、BitmapUtils四大模塊,可用于高速開發(fā)
項(xiàng)目地址:https://github.com/wyouflf/xUtils
Afinal
Afinal是一個(gè)android的ioc,orm框架,內(nèi)置了四大模塊功能:FinalAcitivity,FinalBitmap,FinalDb,FinalHttp。通過finalActivity,我們能夠通過注解的方式進(jìn)行綁定ui和事件。通過finalBitmap,我們能夠方便的載入bitmap圖片,而無需考慮oom等問題。
通過finalDB模塊,我們一行代碼就能夠?qū)ndroid的sqlite數(shù)據(jù)庫進(jìn)行增刪改查。
通過FinalHttp模塊,我們能夠以ajax形式請求http數(shù)據(jù)
項(xiàng)目地址:https://github.com/yangfuhai/afinal
官網(wǎng)網(wǎng)址:http://www.afinal.org
UltimateAndroid
UltimateAndroid是一個(gè)高速開發(fā)Android應(yīng)用的框架。框架眼下主要包括的功能有View Injection,ORM,異步網(wǎng)絡(luò)請求和圖片載入,自己主動(dòng)化腳本測試,磁盤LRU等功能.同一時(shí)候提供了類似于TripleDes、Webview高速設(shè)置、Md5處理、String處理,Https處理等經(jīng)常使用工具類,還有超過100多種UI控件效果。
項(xiàng)目地址:https://github.com/cymcsg/UltimateAndroid
官網(wǎng)網(wǎng)址:http://blog.marshalchen.com/UltimateAndroid/
SAF
SAF(Simple Android Framework)是一個(gè)簡單的android框架。它為開發(fā)Android app提供了基礎(chǔ)性組件。
項(xiàng)目地址:https://github.com/fengzhizi715/SAF
官網(wǎng)網(wǎng)址:http://www.salesuite.cn/
包含:(1)Event Bus(事件總線)
(2) Rest Client(http的框架)
(3) Image Cache(圖片緩存)
(4) Dependency Injection(依賴注入)
(5) Sqlite ORM(sqlite的orm)
(6) Router(Activity、Fragment的Router)
(7) Utils(各種經(jīng)常使用的工具類)
Barber
Custom View 神器。通過簡單的注解幫助你大大降低 Custom View 中的代碼量。
因?yàn)楹?ButterKnife 一樣使用了 Annotation Proccessor ,所以對程序性能沒有影響。
項(xiàng)目地址:https://github.com/hzsweers/barber
device-year-class
A library that analyzes an Android device's specifications and calculates which year the device would be considered "high end”.(facebook開發(fā)的檢測手機(jī)主流配置工具)
項(xiàng)目地址:https://github.com/facebook/device-year-class
轉(zhuǎn)載于:https://www.cnblogs.com/zfyouxi/p/5112314.html
總結(jié)
以上是生活随笔為你收集整理的Android 开源项目android-open-project工具库解析之(一) 依赖注入,图片缓存,网络相关,数据库orm工具包,Android公共库...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Unity3D Editor 扩展
- 下一篇: 类的继承私有成员问题