Android开源项目第二篇——工具库篇
本文為那些不錯的Android開源項目第二篇——開發工具庫篇,主要介紹經常使用的開發庫,包含依賴注入框架、圖片緩存、網絡相關、數據庫ORM建模、Android公共庫、Android 高版本號向低版本號兼容、多媒體相關及其它。
?
最新內容請訪問AndroidOpenProject@Github。歡迎Star和Fork。
?
Android開源項目系列匯總已完畢。包含:
Android開源項目第一篇——個性化控件(View)篇
Android開源項目第二篇——工具庫篇
Android開源項目第三篇——優秀項目篇
Android開源項目第四篇——開發及測試工具篇
Android開源項目第五篇——優秀個人和團體篇
?
通過這些項目你能夠大幅度降低不必要的開發而將精力放在更重要的地方。
?
一、依賴注入DI
通過依賴注入降低View、服務、資源簡化初始化。事件綁定等反復繁瑣工作
1. AndroidAnnotations(Code Diet) android高速開發框架
項目地址:https://github.com/excilys/androidannotations
文檔介紹:https://github.com/excilys/androidannotations/wiki
官方站點:http://androidannotations.org/
特點:(1)依賴注入:包含view,extras。系統服務,資源等等
(2)簡單的線程模型。通過annotation表示方法執行在ui線程還是后臺線程
(3)事件綁定:通過annotation表示view的響應事件。不用在寫內部類
(4)RESTclient:定義client接口。自己主動生成REST請求的實現
(5)沒有你想象的復雜:AndroidAnnotations僅僅是在在編譯時生成對應子類
(6)不影響應用性能:僅50kb。在編譯時完畢,不會對執行時有性能影響。
PS:與roboguice的比較:roboguice通過執行時讀取annotations進行反射,所以可能影響應用性能,而AndroidAnnotations在編譯時生成子類。所以對性能沒有影響
?
2. roboguice 幫你處理了非常多代碼異常。利用annotation使得更少的代碼完畢項目
項目地址:https://github.com/roboguice/roboguice
文檔介紹:https://github.com/roboguice/roboguice/wiki
?
3. butterknife 利用annotation幫你高速完畢View的初始化,降低代碼
項目地址:https://github.com/JakeWharton/butterknife
文檔介紹:http://jakewharton.github.io/butterknife/
?
4. Dagger 依賴注入,適用于Android和Java
項目地址:https://github.com/square/dagger
文檔介紹:http://square.github.io/dagger/
?
二、圖片緩存
1. Android-Universal-Image-Loader 圖片緩存
眼下使用最廣泛的圖片緩存,支持主流圖片緩存的絕大多數特性。
項目地址: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
?
2. picasso square開源的圖片緩存
項目地址:https://github.com/square/picasso
文檔介紹:http://square.github.io/picasso/
特點:(1)能夠自己主動檢測adapter的重用并取消之前的下載
(2)圖片變換
(3)能夠載入本地資源
(4)能夠設置占位資源
(5)支持debug模式
?
3. ImageCache 圖片緩存。包括內存和Sdcard緩存
項目地址:https://github.com/Trinea/AndroidCommon
Demo地址:https://play.google.com/store/apps/details?id=cn.trinea.android.demo
文檔介紹:http://www.trinea.cn/?p=704
特點:(1)支持預取新圖片,支持等待隊列
(2)包括二級緩存。可自己定義文件名稱保存規則
(3)可選擇多種緩存算法(FIFO、LIFO、LRU、MRU、LFU、MFU等13種)或自己定義緩存算法
(4)可方便的保存及初始化恢復數據
(5)支持不同類型網絡處理
(6)可依據系統配置初始化緩存等
?
三、網絡相關
1. Asynchronous Http Client for Android Android異步Http請求
項目地址:https://github.com/loopj/android-async-http
文檔介紹:http://loopj.com/android-async-http/
特點:(1) 在匿名回調中處理請求結果
(2) 在UI線程外進行http請求
(3) 文件斷點上傳
(4) 智能重試
(5) 默認gzip壓縮
(6) 支持解析成Json格式
(7) 可將Cookies持久化到SharedPreferences
?
2. android-query 異步載入,更少代碼完畢Android載入
項目地址:https://github.com/androidquery/androidquery或https://code.google.com/p/android-query/
文檔介紹:https://code.google.com/p/android-query/#Why_AQuery?
Demo地址:https://play.google.com/store/apps/details?
id=com.androidquery
特點:https://code.google.com/p/android-query/#Why_AQuery?
?
3. Async Http Client Java異步Http請求
項目地址:https://github.com/AsyncHttpClient/async-http-client
文檔介紹:http://sonatype.github.io/async-http-client/
?
4. Ion?支持圖片、json、http post等異步請求
項目地址:https://github.com/koush/ion
文檔介紹:https://github.com/koush/ion#more-examples
?
5. HttpCache Http緩存
項目地址:https://github.com/Trinea/AndroidCommon
Demo地址:https://play.google.com/store/apps/details?
id=cn.trinea.android.demo
Demo代碼:https://github.com/Trinea/AndroidDemo/blob/master/src/cn/trinea/android/demo/HttpCacheDemo.java
特點是:(1) 依據cache-control、expires緩存http請求
(2) 支持同步、異步Http請求
(3) 在匿名回調中處理請求結果
(4) 在UI線程外進行http請求
(5) 默認gzip壓縮
?
6. Http Request
項目地址:https://github.com/kevinsawicki/http-request
文檔介紹:https://github.com/kevinsawicki/http-request#examples
?
7. okhttp square開源的http工具類
項目地址:https://github.com/square/okhttp
文檔介紹: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設計
項目地址:https://github.com/square/retrofit
文檔介紹:http://square.github.io/retrofit/
?
四、數據庫 orm工具包
orm的db工具類,簡化建表、查詢、更新、插入、事務、索引的操作
1. greenDAO Android Sqlite orm的db工具類
項目地址:https://github.com/greenrobot/greenDAO
文檔介紹:http://greendao-orm.com/documentation/
官方站點:http://greendao-orm.com/
特點:(1)性能佳
(2) 簡單易用的API
(3) 內存小好小
(4) 庫大小小
?
2. ActiveAndroid Android Sqlite orm的db工具類
項目地址:https://github.com/pardom/ActiveAndroid
文檔介紹:https://github.com/pardom/ActiveAndroid/wiki/_pages
?
3. Sprinkles Android Sqlite orm的db工具類
項目地址:https://github.com/emilsjolander/sprinkles
文檔介紹:http://emilsjolander.github.io/blog/2013/12/18/android-with-sprinkles/
特點:比較顯著的特點就是配合https://github.com/square/retrofit能保存從server獲取的數據
?
五、Android公共庫
1. Guava Google的基于java1.6的類庫集合的擴展項目
包含collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O等等. 這些高質量的API能夠使你的JAVa代碼更加優雅,更加簡潔
項目地址:https://code.google.com/p/guava-libraries/
文檔介紹:https://code.google.com/p/guava-libraries/wiki/GuavaExplained
?
2. AndroidCommon Android公共庫
項目地址:https://github.com/Trinea/AndroidCommon
Demo地址:https://play.google.com/store/apps/details?id=cn.trinea.android.demo
文檔介紹:http://www.trinea.cn/?p=778
包含:(1)緩存(圖片緩存、預取緩存、網絡緩存)
(2) 公共View(下拉及底部載入很多其它ListView、底部載入很多其它ScrollView、滑動一頁Gallery)
(3) Android經常使用工具類(網絡、下載、Android資源操作、shell、文件、Json、隨機數、Collection等等)
?
六、Android 高版本號向低版本號兼容
1. ActionBarSherlock 為Android全部版本號提供統一的ActionBar,解決4.0下面ActionBar的適配問題
項目地址:https://github.com/JakeWharton/ActionBarSherlock
Demo地址:https://play.google.com/store/apps/details?
id=com.actionbarsherlock.sample.demos
APP演示樣例:太多了。
。
如今連google都在用
?
2. Nine Old Androids 將Android 3.0(Honeycomb)全部動畫API(ObjectAnimator ValueAnimator等)兼容到Android1.0
項目地址:https://github.com/JakeWharton/NineOldAndroids
Demo地址:https://play.google.com/store/apps/details?id=com.jakewharton.nineoldandroids.sample
文檔介紹:http://nineoldandroids.com/
?
3. HoloEverywhere 將Android 3.0的Holo主題兼容到Android2.1++
項目地址:https://github.com/Prototik/HoloEverywhere
Demo地址:https://raw.github.com/Prototik/HoloEverywhere/repo/org/holoeverywhere/demo/2.1.0/demo-2.1.0.apk
文檔介紹:http://android-developers.blogspot.com/2012/01/holo-everywhere.html
?
七、多媒體相關
1. cocos2d-x 跨平臺的2d游戲框架,支持Android、IOS、Linux、Windows等眾多平臺
項目地址:https://github.com/cocos2d/cocos2d-x
文檔介紹:http://www.cocos2d-x.org/wiki
官方站點:http://www.cocos2d-x.org/
?
2. Vitamio 是一款Android與iOS平臺上的全能多媒體開發框架
項目地址:https://github.com/yixia/VitamioBundle
站點介紹:http://www.vitamio.org/docs/
特點:(1) 全面支持硬件解碼與GPU渲染
(2) 可以流暢播放720P甚至1080P高清MKV,FLV,MP4,MOV。TS,RMVB等常見格式的視頻
(3) 在Android與iOS上跨平臺支持 MMS, RTSP, RTMP, HLS(m3u8)等常見的多種視頻流媒體協議,包含點播與直播。
?
3. PhotoProcessing 利用ndk處理圖片庫,支持Instafix、Ansel、Testino、XPro、Retro、BW、Sepia、Cyano、Georgia、Sahara、HDR、Rotate、Flip
項目地址:https://github.com/lightbox/PhotoProcessing
Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/photo-processing.apk?raw=true
?
4. Android StackBlur 圖片模糊效果工具類
項目地址:https://github.com/kikoso/android-stackblur
Demo地址:https://github.com/kikoso/android-stackblur/blob/master/StackBlurDemo/bin/StackBlurDemo.apk?raw=true
文檔介紹:https://github.com/kikoso/android-stackblur#usage
?
八、其它
1. Salvage view 帶View緩存的Viewpager PagerAdapter。非常方便使用
項目地址:https://github.com/JakeWharton/salvage
?
2. Android-PasscodeLock 應用鎖,每次啟動或從不論什么Activity啟動應用都須要輸入四位數字的password方可進入
項目地址:https://github.com/wordpress-mobile/Android-PasscodeLock
Demo地址:https://play.google.com/store/apps/details?
id=com.sothree.umano
APP演示樣例:Wordpress Android。支付寶,挖財
?
3. android-lockpattern Android的圖案password解鎖
項目地址:https://code.google.com/p/android-lockpattern/
Demo地址:https://play.google.com/store/apps/details?id=group.pals.android.lib.ui.lockpattern.demo
使用介紹:https://code.google.com/p/android-lockpattern/wiki/QuickUse
演示樣例APP:Android開機的圖案password解鎖,支付寶的password解鎖
?
4. GlowPadBackport將Android4.2的鎖屏界面解鎖擴展到Android1.6及1.6+
項目地址:https://github.com/rock3r/GlowPadBackport
Demo地址:https://play.google.com/store/apps/details?
id=net.sebastianopoggi.samples.ui.GlowPadSample
效果圖:https://lh6.ggpht.com/U070b6Lh6cVsVwx4jN-5nq0xqiB1PBzrYABPeJIEe2hZQ5UWOxc-FDUG77wADelToHA=h310-rw
?
5. GlowPadView Android4鎖屏界面解鎖
項目地址:https://github.com/nadavfima/GlowPadView
效果圖:https://raw.github.com/nadavfima/GlowPadView/master/example.png
?
6. Android Priority Job Queue Android后臺任務隊列
項目地址:https://github.com/path/android-priority-jobqueue
文檔介紹:https://github.com/path/android-priority-jobqueue#getting-started
?
7. jsoup 一個解析html的java庫,可方便的提取和操作數據
項目地址:https://github.com/jhy/jsoup
官方站點:http://jsoup.org/
作用:(1) 從一個url、文件或string獲得html并解析
(2) 利用dom遍歷或css選擇器查找、提取數據
(3) 操作html元素
(4) 依據白名單去除用于提交的非法數據防止xss攻擊
(5) 輸出整齊的html
?
8.ZIP java壓縮和解壓庫
項目地址:https://github.com/zeroturnaround/zt-zip
文檔介紹:https://github.com/zeroturnaround/zt-zip#examples
作用:(1) 解壓和壓縮,并支持目錄內遞歸操作
(2) 支持包括和排除某些元素
(3) 支持重命名元素
(4) 支持遍歷zip包內容
(5) 比較兩個zip包等功能
?
9. Cobub Razor 開源的mobile行為分析系統,包含web端、android端,支持ios和window phone
項目地址:https://github.com/cobub/razor
Demo地址:http://demo.cobub.com/razor
站點介紹:http://dev.cobub.com/
?
10. aFileChooser 文件選擇器,可內嵌到程序中。而無需使用系統或三方文件選擇器。
項目地址:https://github.com/iPaulPro/aFileChooser
?
11. androidpn 基于xmpp協議的消息推送解決方式,包含server端和android端。
項目地址:https://github.com/dannytiehui/androidpn
?
12. Android插件式開發
項目地址:https://github.com/umeng/apf
總結
以上是生活随笔為你收集整理的Android开源项目第二篇——工具库篇的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tomcat(2)--集群
- 下一篇: 作为程序员我给csdn博客添加打赏功能