工具庫
主要包括那些不錯的開發庫,包括依賴注入框架、圖片緩存、網絡相關、數據庫ORM建模、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) REST客戶端:定義客戶端接口,自動生成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/android/android-imagecache/
特點:(1)支持預取新圖片,支持等待隊列
(2)包含二級緩存,可自定義文件名保存規則
(3)可選擇多種緩存算法(FIFO、LIFO、LRU、MRU、LFU、MFU等13種)或自定義緩存算法
(4)可方便的保存及初始化恢復數據
(5)支持不同類型網絡處理
(6)可根據系統配置初始化緩存等
4.Cube ImageLoader
阿里巴巴一淘使用的圖片加載,綜合了Android-Universal-Image-Loader 和 square 等組件優點,簡單易用,良好的中文文檔支持
項目地址: 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/
效果圖:
三、網絡相關
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
文檔介紹: http://www.trinea.cn/android/android-http-cache
特點是:(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/
9.RoboSpice
Android異步網絡請求工具,支持緩存、REST等等
項目地址: https://github.com/stephanenicolas/robospice
Demo地址: https://github.com/stephanenicolas/RoboDemo/downloads
四、數據庫 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 能保存從服務器獲取的數據
4.Realm
移動端的數據庫,適用於 Phone、Tablet、Wearable,支持 ORM,線程安全、支持連表及數據庫加密,比 SQLite 性能更好
項目地址: https://github.com/realm/realm-java
文檔介紹: http://realm.io/docs/java/0.72.0/
5.ormlite-android
項目地址: https://github.com/j256/ormlite-android
文檔介紹: http://ormlite.com/sqlite_java_android_orm.shtml
6.Schematic
根據SQLite生成ContentProvider
項目地址: https://github.com/SimonVT/schematic
五、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.Volley
Google提供的網絡通信庫,使得網絡請求更簡單、更快速
項目地址: https://android.googlesource.com/platform/frameworks/volley
Github地址: https://github.com/mcxiaoke/android-volley
文檔地址: http://commondatastorage.googleapis.com/io-2013/presentations/110%20-%20Volley-%20Easy,%20Fast%20Networking%20for%20Android.pdf
3.AndroidCommon
Android公共庫
項目地址: 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)緩存(圖片緩存、預取緩存、網絡緩存)
(2) 公共View(下拉及底部加載更多ListView、底部加載更多ScrollView、滑動一頁Gallery)
(3) Android常用工具類(網絡、下載、Android資源操作、shell、文件、Json、隨機數、Collection等等)
4.shipfaster
整合了Dagger Otto Retrofit Robolectric Picasso OkHttp,方便快速開發
項目地址: https://github.com/pyricau/shipfaster
CleanAndroidCode
整合了Dagger Otto AndroidAnnotations,方便快速開發
項目地址: https://github.com/pyricau/CleanAndroidCode
5.xUtils
基於Afinal,包含DbUtils、ViewUtils、HttpUtils、BitmapUtils四大模塊,可用於快速開發
項目地址: https://github.com/wyouflf/xUtils
6.Afinal
Afinal是一個android的ioc,orm框架,內置了四大模塊功能:FinalAcitivity,FinalBitmap,FinalDb,FinalHttp。通過finalActivity,我們可以通過註解的方式進行綁定ui和事件。通過finalBitmap,我們可以方便的加載bitmap圖片,而無需考慮oom等問題。通過finalDB模塊,我們一行代碼就可以對android的sqlite數據庫進行增刪改查。通過FinalHttp模塊,我們可以以ajax形式請求http數據
項目地址: https://github.com/yangfuhai/afinal
官方網站: http://www.afinal.org
7.UltimateAndroid
UltimateAndroid是一個快速開發Android應用的框架,框架目前主要包含的功能有View Injection,ORM,異步網絡請求和圖片加載,自動化腳本測試,磁盤LRU等功能.同時提供了類似於TripleDes、Webview快速設置、Md5處理、String處理,Https處理等常用工具類,還有超過100多種UI控件效果。
項目地址: https://github.com/cymcsg/UltimateAndroid
官方網站: http://blog.marshalchen.com/UltimateAndroid/
六、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
4.SherlockNavigationDrawer
將Android NavigationDrawer和ActionbarSherlock結合,解決4.0以下NavigationDrawer的適配問題
項目地址: https://github.com/tobykurien/SherlockNavigationDrawer
文檔地址: http://developer.android.com/training/implementing-navigation/nav-drawer.html
5.Notifications4EveryWhere
將Android 4.1的Notification兼容到Android2.2++
項目地址: https://github.com/youxiachai/Notifications4EveryWhere
6.Android Switch Widget Backport
將Android Switch和SwitchPreference的兼容到Android2.1++
項目地址: https://github.com/BoD/android-switch-backport
Demo地址: https://play.google.com/store/apps/details?id=org.jraf.android.backport.switchwidget.sample
文檔介紹: https://github.com/BoD/android-switch-backport#using-the-switch
7.android-datepicker
將Android 4.0的datepicker兼容到Android2.2++
項目地址: https://github.com/SimonVT/android-datepicker
8.GlowPadBackport
Android 4.2的GlowPadView向後適配到API4以上
項目地址: https://github.com/frakbot/GlowPadBackport
9.Transitions Everywhere
Android 4.4 的 Transitions API 兼容到 Android 2.2 以上
項目地址: https://github.com/andkulikov/transitions-everywhere
七、多媒體相關
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
5.Bitmap Smart Clipping using OpenCV
圖片智能裁剪保留重要部分顯示
項目地址: https://github.com/beartung/tclip-android
利用淘寶的 http://code.taobao.org/p/tclip/ 庫完成
一淘玩客正在使用的圖片裁剪,自動識別圖片中的重要區域,並且在圖片裁剪時保留重要區域
特點:(1). 能進行人臉識別。圖片中有人臉,將自動視為人臉區域為重要區域,將不會被裁剪掉
(2).自動其它重要區域。如果圖片中未識別出人臉,則會根據特徵分佈計算出重區域
Cropper
圖片局部剪切工具,可觸摸控制選擇區域或旋轉
項目地址: https://github.com/edmodo/cropper
使用介紹: https://github.com/edmodo/cropper/wiki
效果圖:
6.android-crop
圖片裁剪Activity
項目地址: https://github.com/jdamcd/android-crop
效果圖:
7.TileView
可分塊顯示大圖,支持2D拖動、雙擊、雙指放大、雙指捏合
項目地址: https://github.com/moagrius/TileView
Demo地址: http://moagrius.github.io/TileView/TileViewDemo.apk
8.BlurEffectForAndroidDesign
圖片模糊效果
項目地址: https://github.com/PomepuyN/BlurEffectForAndroidDesign
9.android-eye
PC端網頁查看同一局域網內的手機攝像頭內容,可以用來監控哦
項目地址: https://github.com/Teaonly/android-eye
Demo地址: https://play.google.com/store/apps/details?id=teaonly.droideye
10.libpng for Android
PNG圖片的jni庫,支持幾乎png的所有特性
項目地址: https://github.com/julienr/libpng-android
文檔地址: http://www.libpng.org/pub/png/libpng.html
11.android-gpuimage
基於GPU的圖片濾鏡
項目地址: https://github.com/CyberAgent/android-gpuimage
12.AndroidFaceCropper
圖片臉部自動識別,將識別後的局部圖片返回
項目地址: https://github.com/lafosca/AndroidFaceCropper
13.Android Video Crop
利用TextureView播放和剪切視頻,類似ImageView.setScaleType
項目地址: https://github.com/dmytrodanylyk/android-video-crop
Demo地址: https://github.com/lafosca/AndroidFaceCropper/releases/download/1.0/FaceCropper-sample-debug-unaligned.apk
14.svg-android
Android Svg矢量圖形支持
項目地址: https://github.com/japgolly/svg-android https://github.com/japgolly/svg-android
15.Android Visualizer
從Android MediaPlayer獲得音頻,然後像iTunes及WinAmp一樣展示音軌
項目地址: https://github.com/felixpalmer/android-visualizer
16.ExoPlayer
包括儀表板和SmoothStreaming自適應回放,緩存持久化和自定義渲染器,方便自定義和擴展,並且可以通過應用商店更新
項目地址: https://github.com/google/ExoPlayer
17.DanmakuFlameMaster
android上開源彈幕解析繪製引擎項目
項目地址: https://github.com/ctiao/DanmakuFlameMaster
八、事件總線(訂閱者模式)
通過發佈/訂閱事件解耦事件發送和接受,從而簡化應用程序組件(Activities, Fragments及後臺線程)之間的通信
1.EventBus
greenrobot的開源項目
項目地址: https://github.com/greenrobot/EventBus
文檔介紹: https://github.com/greenrobot/EventBus#general-usage-and-api
特點:(1) 支持在不同類型的線程中處理訂閱,包括髮布所在線程,UI線程、單一後臺線程、異步線程
(2) 支持事件優先級定義,支持優先級高的訂閱者取消事件繼續傳遞,支持粘性事件,是不是跟系統的有序廣播、粘性廣播很像啊
(3) 不是基於annotations
(4) 性能更優
(5) 體積小
(6) 支持單例創建或創建多個對象
(7) 支持根據事件類型訂閱
2.Otto
Square的開源項目,基於Guava的Android優化
項目地址: https://github.com/square/otto
文檔介紹: http://square.github.io/otto/
EventBus與Otto的功能及性能對比文檔
EventBus與Otto性能對比Demo Apk
九、傳感器
1.Great Android Sensing Toolkit
Android感應器工具包,包含示例及使用過程中可能需要的算法
項目地址: https://github.com/gast-lib/gast-lib
Demo地址: https://play.google.com/store/apps/details?id=root.gast.playground
文檔介紹: https://github.com/gast-lib/gast-lib#documentation
2.SensorManager
Android傳感器管理
項目地址: https://github.com/nlathia/SensorManager
文檔介紹: https://docs.google.com/document/d/1TqThJULb-4e6TGb1gdkAaPCfyuXStjJpbnt7a0OZ9OE/edit
3.GPSLogger
記錄GPS信息
項目地址: https://github.com/mendhak/gpslogger
Demo地址: https://play.google.com/store/apps/details?id=com.mendhak.gpslogger
文檔介紹: http://code.mendhak.com/gpslogger/
4.Pedometer
計步器,使用硬件計步感應器
項目地址: https://github.com/j4velin/Pedometer
5.leapcast
ChromeCast模擬器的App
項目地址: https://github.com/dz0ny/leapcast
6.Arduino-Communicator
與Arduino通信的App
項目地址: https://github.com/jeppsson/Arduino-Communicator
7.android-pedometer
Android計步器
項目地址: https://github.com/bagilevi/android-pedometer
Demo地址: http://pedometer.googlecode.com/files/Pedometer-1.4.apk
8.OwnTracks for Android
自己的軌跡記錄
項目地址: https://github.com/owntracks/android
9.Shake Detector library for Android
Android手機震動搖晃檢測庫,提供供UI線程調用的回調接口
項目地址: https://github.com/tbouron/ShakeDetector
Demo地址: https://play.google.com/store/apps/details?id=com.github.tbouron.shakedetector.example
10.Android heart rate monitor
Android心跳檢測
項目地址: https://github.com/phishman3579/android-heart-rate-monitor
11.Bluetooth LE Library for Android
藍牙源信息,包括寶庫Mac、更新時間、RSSI、UUID、信號源距離、影響範圍等信息
項目地址: https://github.com/alt236/Bluetooth-LE-Library---Android
Demo地址: https://play.google.com/store/apps/details?id=uk.co.alt236.btlescan
72.farebot
通過NFC 從公交卡中讀取數據的一個應用
項目地址: https://github.com/codebutler/farebot
閱讀更多 HELLO開源 的文章