Android開源項目第二篇——工具庫篇

本文爲那些不錯的Android開源項目第二篇——開發工具庫篇,**主要介紹經常使用的開發庫,包括依賴注入框架、圖片緩存、網絡相關、數據庫ORM建模、Android公共庫、Android 高版本向低版本兼容、多媒體相關及其餘**。

Android開源項目系列彙總已完成,包括:css

Android開源項目第一篇——個性化控件(View)篇

Android開源項目第二篇——工具庫篇

Android開源項目第三篇——優秀項目篇

Android開源項目第四篇——開發及測試工具篇

Android開源項目第五篇——優秀我的和團體篇html

經過這些項目你能夠大幅度減小沒必要要的開發而將精力放在更重要的地方。java

1、依賴注入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)REST客戶端:定義客戶端接口,自動生成REST請求的實現

(5)沒有你想象的複雜:AndroidAnnotations只是在在編譯時生成相應子類

(6)不影響應用性能:僅50kb,在編譯時完成,不會對運行時有性能影響。

PS:與roboguice的比較:roboguice經過運行時讀取annotations進行反射,因此可能影響應用性能,而AndroidAnnotations在編譯時生成子類,因此對性能沒有影響android

2. roboguice 幫你處理了不少代碼異常,利用annotation使得更少的代碼完成項目

項目地址:https://github.com/roboguice/roboguice

文檔介紹:https://github.com/roboguice/roboguice/wikiios

3. butterknife 利用annotation幫你快速完成View的初始化,減小代碼

項目地址:https://github.com/JakeWharton/butterknife

文檔介紹:http://jakewharton.github.io/butterknife/git

4. Dagger 依賴注入,適用於Android和Java

項目地址:https://github.com/square/dagger

文檔介紹:http://square.github.io/dagger/github

2、圖片緩存

1. Android-Universal-Image-Loader 圖片緩存web

目前使用最普遍的圖片緩存,支持主流圖片緩存的絕大多數特性。

項目地址: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模式shell

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)可根據系統配置初始化緩存等

3、網絡相關

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/androidqueryhttps://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連接傳送網頁和圖片等資源%E5%8D%8F%E8%AE%AE%E3%80%82SPDY%E5%8D%8F%E8%AE%AE%E6%98%AFGoogle%E5%BC%80%E5%8F%91%E7%9A%84%E5%9F%BA%E4%BA%8E%E4%BC%A0%E8%BE%93%E6%8E%A7%E5%88%B6%E5%8D%8F%E8%AE%AE%E7%9A%84%E5%BA%94%E7%94%A8%E5%B1%82%E5%8D%8F%E8%AE%AE%EF%BC%8C%E9%80%9A%E8%BF%87%E5%8E%8B%E7%BC%A9%EF%BC%8C%E5%A4%9A%E8%B7%AF%E5%A4%8D%E7%94%A8(%E4%B8%80%E4%B8%AATCP%E9%93%BE%E6%8E%A5%E4%BC%A0%E9%80%81%E7%BD%91%E9%A1%B5%E5%92%8C%E5%9B%BE%E7%89%87%E7%AD%89%E8%B5%84%E6%BA%90))和優先級來縮短加載時間。

(2) 若是SPDY不可用,利用鏈接池減小請求延遲

(3) Gzip壓縮

(4) Response緩存減小沒必要要的請求

8. Retrofit RESTFUL API設計

項目地址:https://github.com/square/retrofit

文檔介紹:http://square.github.io/retrofit/

4、數據庫 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能保存從服務器獲取的數據

5、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等等)

6、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

7、多媒體相關

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

8、其餘

1. Salvage view 帶View緩存的Viewpager PagerAdapter,很方便使用

項目地址:https://github.com/JakeWharton/salvage

2. Android-PasscodeLock 應用鎖,每次啓動或從任何Activity啓動應用都須要輸入四位數字的密碼方可進入

項目地址: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的圖案密碼解鎖

項目地址: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開機的圖案密碼解鎖,支付寶的密碼解鎖

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協議的消息推送解決方案,包括服務器端和android端。

項目地址:https://github.com/dannytiehui/androidpn

12. Android插件式開發

項目地址:https://github.com/umeng/apf

相關文章
相關標籤/搜索