Android牛逼开源项目分类汇总

mikel阅读(982)

Android开源项目分类汇总

第一部分 个性化控件(View)

主要介绍那些不错个性化的View,包括ListView、ActionBar、Menu、ViewPager、Gallery、 GridView、ImageView、ProgressBar、TextView、ScrollView、TimeView、TipView、 FlipView、ColorPickView、GraphView、UI Style等等。

一、ListView

  1. Android-pulltorefresh
    一个强大的拉动刷新开源项目,支持各种控件下拉刷新,ListView、ViewPager、WevView、ExpandableListView、 GridView、ScrollView、Horizontal ScrollView、Fragment上下左右拉动刷新,比下面johannilsson那个只支持ListView的强大的多。并且它实现的下拉刷新 ListView在item不足一屏情况下也不会显示刷新提示,体验更好。
    项目地址:https://github.com/chrisbanes/Android-PullToRefresh
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/pull-to-refreshview-demo.apk?raw=true
    APP示例:新浪微博各个页面
  2. Android-pulltorefresh-listview
    下拉刷新ListView
    项目地址:https://github.com/johannilsson/android-pulltorefresh
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/pull-to-refresh-listview-demo.apk?raw=true
    PS:这个被很多人使用的项目实际有不少bug,推荐使用上面的android-pulltorefresh
  3. DropDownListView
    下拉刷新及滑动到底部加载更多ListView
    项目地址:https://github.com/Trinea/AndroidCommon
    Demo地址:https://play.google.com/store/apps/details?id=cn.trinea.android.demo
    文档介绍:http://www.trinea.cn/android/dropdown-to-refresh-and-bottom-load-more-listview/
  4. DragSortListView
    拖动排序的ListView,同时支持ListView滑动item删除,各个Item高度不一、单选、复选、CursorAdapter做为适配器、拖动背景变化等
    项目地址:https://github.com/bauerca/drag-sort-listview
    Demo地址:https://play.google.com/store/apps/details?id=com.mobeta.android.demodslv
    APP示例:Wordpress Android
  5. SwipeListView
    支持定义ListView左右滑动事件,支持左右滑动位移,支持定义动画时间
    项目地址:https://github.com/47deg/android-swipelistview
    Demo地址:https://play.google.com/store/apps/details?id=com.fortysevendeg.android.swipelistview
    APP示例:微信
  6. Android-SwipeToDismiss
    滑动Item消失ListView
    项目地址:https://github.com/romannurik/Android-SwipeToDismiss
    支持3.0以下版本见:https://github.com/JakeWharton/SwipeToDismissNOA
    Demo地址:https://github.com/JakeWharton/SwipeToDismissNOA/SwipeToDismissNOA.apk/qr_code
  7. PinnedHeaderExpandableListView
    首先它是一个ExpandableListView,但是它的头部可以固定,其次,在它的上面还有一个头部可以来回伸缩
    项目地址:https://github.com/singwhatiwanna/PinnedHeaderExpandableListView
    APP示例:百度手机卫士垃圾清理界面
    效果图:Renderings
  8. StickyListHeaders
    GroupName滑动到顶端时会固定不动直到另外一个GroupName到达顶端的ExpandListView,支持快速滑动,支持Android2.3及以上
    项目地址:https://github.com/emilsjolander/StickyListHeaders
    APP示例:Android 4.0联系人
    效果图:Renderings
  9. pinned-section-listview
    GroupName滑动到顶端时会固定不动直到另外一个GroupName到达顶端的ExpandListView
    项目地址:https://github.com/beworker/pinned-section-listview
    效果图:Renderings
  10. PinnedHeaderListView
    GroupName滑动到顶端时会固定不动直到另外一个GroupName到达顶端的ExpandListView
    项目地址:https://github.com/JimiSmith/PinnedHeaderListView
  11. QuickReturn
    ListView/ScrollView的header或footer,当向下滚动时消失,向上滚动时出现
    项目地址:https://github.com/lawloretienne/QuickReturn
    Demo地址:https://play.google.com/store/apps/details?id=com.etiennelawlor.quickreturn
  12. QuickReturnHeader
    ListView/ScrollView的header或footer,当向下滚动时消失,向上滚动时出现
    项目地址:https://github.com/ManuelPeinado/QuickReturnHeader
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/quick-return-header-demo.apk?raw=true
    APP示例:google plus
  13. IndexableListView
    ListView右侧会显示item首字母快捷索引,点击可快速滑动到某个item
    项目地址:https://github.com/woozzu/IndexableListView
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/indexable-listview.apk?raw=true
    APP示例:微信通讯录、小米联系人
  14. CustomFastScrollView
    ListView快速滑动,同时屏幕中间PopupWindows显示滑动到的item内容或首字母
    项目地址:https://github.com/nolanlawson/CustomFastScrollViewDemo
    效果图:Renderings
  15. Android-ScrollBarPanel
    ListView滑动时固定的Panel指示显示在scrollbar旁边
    项目地址:https://github.com/rno/Android-ScrollBarPanel
    效果展示:https://github.com/rno/Android-ScrollBarPanel/raw/master/demo_capture.png
  16. SlideExpandableListView
    用户点击listView item滑出固定区域,其他item的区域收缩
    项目地址:https://github.com/tjerkw/Android-SlideExpandableListView
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/slide-expandable-listView-demo.apk?raw=true
  17. JazzyListView
    ListView及GridView item以特殊动画效果进入屏幕,效果包括grow、cards、curl、wave、flip、fly等等
    项目地址:https://github.com/twotoasters/JazzyListView
    Demo地址:https://play.google.com/store/apps/details?id=com.twotoasters.jazzylistview.sample
    效果展示:http://lab.hakim.se/scroll-effects/
  18. ListViewAnimations
    带Item显示动画的ListView,动画包括底部飞入、其他方向斜飞入、下层飞入、渐变消失、滑动删除等
    项目地址:https://github.com/nhaarman/ListViewAnimations
    Demo地址:https://play.google.com/store/apps/details?id=com.haarman.listviewanimations
    APP示例:Google plus、Google Now卡片式进入、小米系统中应用商店、联系人、游戏中心、音乐、文件管理器的ListView、Ultimate、Light Flow Lite、TreinVerkeer、Running Coach、Pearl Jam Lyrics、Calorie Chart、Car Hire、Super BART、DK FlashCards、Counter Plus、Voorlees Verhaaltjes 2.0
  19. DevsmartLib-Android
    横向ListView
    项目地址:https://github.com/dinocore1/DevsmartLib-Android
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/horizontal-listview-demo.apk?raw=true
  20. TwoWayView
    横向ListView的效果,继承自AdapterView
    项目地址:https://github.com/lucasr/twoway-view
  21. HorizontalVariableListView
    支持Item宽度不一致的ListView
    项目地址:https://github.com/sephiroth74/HorizontalVariableListView
  22. LinearListView
    用LinearLayout实现的ListView,可解决多个ListView并存等问题。目前自己也有需要,等亲自尝试过后会再具体介绍
    项目地址:https://github.com/frankiesardo/LinearListView
  23. MultiChoiceAdapter
    支持多选的ListView Adapter
    项目地址:https://github.com/ManuelPeinado/MultiChoiceAdapter
    Demo地址:https://play.google.com/store/apps/details?id=com.manuelpeinado.multichoiceadapter.demo
  24. EnhancedListView
    支持横向滑动删除列表项以及撤销删除的ListView,该项目的前身是SwipeToDismissUndoList
    项目地址:https://github.com/timroes/EnhancedListView
    Demo地址:https://play.google.com/store/apps/details?id=de.timroes.android.listviewdemo&rdid=de.timroes.android.listviewdemo
  25. ListBuddies
    自动滚动的双列ListView ,两个ListView滚动速度不一致,有视差效果
    项目地址:https://github.com/jpardogo/ListBuddies
    Demo地址:https://play.google.com/store/apps/details?id=com.jpardogo.android.listbuddies
    效果展示:Renderings
  26. PullToZoomInListView
    滑动ListView时使其HeaderView跟随滑动缩放
    项目地址:https://github.com/matrixxun/PullToZoomInListView
    效果展示:Renderings

二、ActionBar

  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. ActionBar-PullToRefresh
    下拉刷新,ActionBar出现加载中提示
    项目地址:https://github.com/chrisbanes/ActionBar-PullToRefresh
    Demo地址:https://play.google.com/store/apps/details?id=uk.co.senab.actionbarpulltorefresh.samples.stock
    APP示例:Gmail,Google plus,知乎等
  3. FadingActionBar
    ListView向下滚动逐渐显现的ActionBar
    项目地址:https://github.com/ManuelPeinado/FadingActionBar
    Demo地址:https://play.google.com/store/apps/details?id=com.manuelpeinado.fadingactionbar.demo
    APP示例:google music,知乎
  4. NotBoringActionBar
    google music下拉收缩的ActionBar
    项目地址:https://github.com/flavienlaurent/NotBoringActionBar
    Demo地址:http://flavienlaurent.com/blog/2013/11/20/making-your-action-bar-not-boring/
    APP示例:Google音乐
  5. RefreshActionItem
    带进度显示和刷新按钮的ActionBar
    项目地址:https://github.com/ManuelPeinado/RefreshActionItem
    Demo地址:https://play.google.com/store/apps/details?id=com.manuelpeinado.refreshactionitem.demo
    APP示例:The New York Times,DevAppsDirect.
  6. GlassActionBar
    类似玻璃的有一定透明度的ActionBar
    项目地址:https://github.com/ManuelPeinado/GlassActionBar
    Demo地址:https://play.google.com/store/apps/details?id=com.manuelpeinado.glassactionbardemo
    APP示例:google music

三、Menu

  1. MenuDrawer
    滑出式菜单,通过拖动屏幕边缘滑出菜单,支持屏幕上下左右划出,支持当前View处于上下层,支持Windows边缘、ListView边缘、ViewPager变化划出菜单等。
    项目地址:https://github.com/SimonVT/android-menudrawer
    Demo地址:http://simonvt.github.io/android-menudrawer/
    APP示例:Gmail、Google Music等大部分google app
  2. SlidingMenu
    滑出式菜单,通过拖动屏幕边缘滑出菜单,支持屏幕左右划出,支持菜单zoom、scale、slide up三种动画样式出现。
    项目地址:https://github.com/jfeinstein10/SlidingMenu
    Demo地址:https://play.google.com/store/apps/details?id=com.slidingmenu.example
    APP示例:Foursquare, LinkedIn, Zappos, Rdio, Evernote Food, Plume, VLC for Android, ESPN ScoreCenter, MLS MatchDay, 9GAG, Wunderlist 2, The Verge, MTG Familiar, Mantano Reader, Falcon Pro (BETA), MW3 Barracks
    MenuDrawer和SlidingMenu比较:SlidingMenu支持菜单动画样式出现,MenuDrawer支持菜单view处于内容的上下层
  3. ArcMenu
    支持类似Path的左下角动画旋转菜单及横向划出菜单、圆心弹出菜单
    项目地址:https://github.com/daCapricorn/ArcMenu
    APP示例:Path
    效果图:Renderings
    https://dl.dropboxusercontent.com/u/11369687/preview1.png
    https://dl.dropboxusercontent.com/u/11369687/raymenu.png
  4. android-satellite-menu
    类似Path的左下角动画旋转菜单
    项目地址:https://github.com/siyamed/android-satellite-menu
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/satellite-menu-demo.apk?raw=true
    APP示例:Path
  5. radial-menu-widget
    圆形菜单,支持二级菜单
    项目地址:https://code.google.com/p/radial-menu-widget/
    效果图:http://farm8.staticflickr.com/7377/11621125154_d1773c2dcc_o.jpg
  6. Android Wheel Menu
    圆形旋转选取菜单
    项目地址:https://github.com/anupcowkur/Android-Wheel-Menu
    效果图:Renderings
  7. FoldingNavigationDrawer
    滑动并以折叠方式打开菜单
    项目地址:https://github.com/tibi1712/FoldingNavigationDrawer-Android
    Demo地址:https://play.google.com/store/apps/details?id=com.ptr.folding.sample
    效果图:Renderings
  8. AndroidResideMenu
    仿 Dribbble 的边栏菜单
    项目地址:https://github.com/SpecialCyCi/AndroidResideMenu
    效果图:Renderings
  9. CircularFloatingActionMenu
    一个可定制的圆形的浮动菜单控件,类似于Path的圆形菜单。这个控件的可定制性更强,可以很容易的定制菜单出现消失时的动画,起始角度和半径。
    项目地址:https://github.com/oguzbilgener/CircularFloatingActionMenu
    Demo地址:https://github.com/oguzbilgener/CircularFloatingActionMenu/tree/master/samples
    效果图:Renderings
  10. NavigationDrawerSI
    Navigation Drawer的一个简单实现,滑动并以折叠方式打开菜单
    项目地址:https://github.com/mmBs/NavigationDrawerSI
    Demo地址:https://play.google.com/store/apps/details?id=mmbialas.pl.navigationdrawersi
    效果图:

四、ViewPager 、Gallery

  1. Android-ViewPagerIndicator
    配合ViewPager使用的Indicator,支持各种位置和样式
    项目地址:https://github.com/JakeWharton/Android-ViewPagerIndicator
    Demo地址:https://play.google.com/store/apps/details?id=com.viewpagerindicator.sample
    APP示例:太多了。。
  2. JazzyViewPager
    支持Fragment切换动画的ViewPager,动画包括转盘、淡入淡出、翻页、层叠、旋转、方块、翻转、放大缩小等
    项目地址:https://github.com/jfeinstein10/JazzyViewPager
    Demo地址:https://github.com/jfeinstein10/JazzyViewPager/blob/master/JazzyViewPager.apk?raw=true
    效果类似桌面左右切换的各种效果,不过桌面并非用ViewPager实现而已
  3. Android-DirectionalViewPager
    支持横向和纵向(垂直)的ViewPager
    项目地址:https://github.com/JakeWharton/Android-DirectionalViewPager
    Demo地址:https://market.android.com/details?id=com.directionalviewpager.sample
  4. android-pulltorefresh
    支持下拉刷新的ViewPager
    项目地址:https://github.com/chrisbanes/Android-PullToRefresh
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/pull-to-refreshview-demo.apk?raw=true
    APP示例:新浪微博各个页面
  5. FancyCoverFlow
    支持Item切换动画效果的类似Gallery View
    项目地址:https://github.com/davidschreiber/FancyCoverFlow
    Demo地址:https://play.google.com/store/apps/details?id=at.technikum.mti.fancycoverflow.samples
    效果图:Renderings
  6. AndroidTouchGallery
    支持双击或双指缩放的Gallery(用ViewPager实现),相比下面的PhotoView,在被放大后依然能滑到下一个item,并且支持直接从url和文件中获取图片,
    项目地址:https://github.com/Dreddik/AndroidTouchGallery
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/touch-gallery-demo.apk?raw=true
    APP示例:类似微信中查看聊天记录图片时可双击放大,并且放大情况下能正常左右滑动到前后图片
  7. Android Auto Scroll ViewPager
    Android自动滚动 轮播循环的ViewPager
    项目地址:https://github.com/Trinea/android-auto-scroll-view-pager
    Demo地址:https://play.google.com/store/apps/details?id=cn.trinea.android.demo
    文档介绍:http://www.trinea.cn/android/auto-scroll-view-pager/
  8. Salvage view
    带View缓存的Viewpager PagerAdapter,很方便使用
    项目地址:https://github.com/JakeWharton/salvage
  9. Android PagerSlidingTabStrip
    配合ViewPager使用的Indicator,支持ViewPager Scroll时Indicator联动
    项目地址:https://github.com/astuetz/PagerSlidingTabStrip
    Demo地址:https://play.google.com/store/apps/details?id=com.astuetz.viewpager.extensions.sample
  10. ViewPager3D
    ViewPager3D效果
    项目地址:https://github.com/inovex/ViewPager3D
  11. AnimaTabsview
    仿网易云音乐标签切换的动画,带透明小三角
    项目地址: https://github.com/wuyexiong/transparent-over-animtabsview
    在线演示:http://v.youku.com/v_show/id_XNzA4MjY5NjA0.html

五、GridView

  1. StaggeredGridView
    允许非对齐行的GridView,类似Pinterest的瀑布流,并且跟ListView一样自带View缓存,继承自ViewGroup
    项目地址:https://github.com/maurycyw/StaggeredGridView
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/staggered-gridview-demo.apk?raw=true
    APP示例:Pinterest等
  2. AndroidStaggeredGrid
    允许非对齐行的GridView,类似Pinterest的瀑布流,继承自AbsListView
    项目地址:https://github.com/etsy/AndroidStaggeredGrid
    APP示例:Pinterest等
  3. PinterestLikeAdapterView
    允许非对齐行的GridView,类似Pinterest的瀑布流,允许下拉刷新
    项目地址:https://github.com/GDG-Korea/PinterestLikeAdapterView
    APP示例:Pinterest等
  4. DraggableGridView
    Item可拖动交换位置的GridView,实际是自己继承ViewGroup实现,类似桌面的单屏效果,可屏幕自动上下滚动进行Item移动交换,多屏效果见下面PagedDragDropGrid
    项目地址:https://github.com/thquinn/DraggableGridView
    Demo地址:https://github.com/thquinn/DraggableGridView/blob/master/bin/DraggableGridViewSample.apk?raw=true
  5. StickyGridHeaders
    GroupName滑动到顶端时会固定不动直到另外一个GroupName到达顶端的GridView
    项目地址:https://github.com/TonicArtos/StickyGridHeaders
    效果图:Renderings
  6. PagedDragDropGrid
    Item可拖动交换位置、拖动删除的自定义控件,实际是自己继承ViewGroup实现,类似桌面的多屏效果,可拖动到屏幕边缘,屏幕自动左右滚动进行Item移动交换,可拖动进行删除,单屏效果见上面DraggableGridView
    项目地址:https://github.com/mrKlar/PagedDragDropGrid
    在线演示:http://youtu.be/FYTSRfthSuQ
  7. Android-DraggableGridViewPager
    Item可拖动交换位置的GridView,实际是自己继承ViewGroup实现,类似桌面的多屏效果,可屏幕自动左右滚动进行Item移动交换,单屏效果见上面DraggableGridView
    项目地址:https://github.com/zzhouj/Android-DraggableGridViewPager
    Demo地址:https://github.com/Trinea/trinea-download/blob/master/draggable-grid-viewpager-demo.apk?raw=true
  8. TwoWayGridView
    可横向滚动的GridView
    项目地址:https://github.com/jess-anders/two-way-gridview

六、ImageView

  1. PhotoView
    支持双击或双指缩放的ImageView,在ViewPager等Scrolling view中正常使用,相比上面的AndroidTouchGallery,不仅支持ViewPager,同时支持单个ImageView
    项目地址:https://github.com/chrisbanes/PhotoView
    Demo地址:https://play.google.com/store/apps/details?id=uk.co.senab.photoview.sample
    APP示例:photup
  2. android-gif-drawable
    支持gif显示的view,用jni实现的,编译生成so库后直接xml定义view即可,而且本身不依赖于其他开源项目所以相对下面的ImageViewEx简单的多
    项目地址:https://github.com/koral–/android-gif-drawable
  3. ImageViewEx
    支持Gif显示的ImageView
    项目地址:https://github.com/frapontillo/ImageViewEx
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/imageviewex-demo.apk?raw=true
    依赖很多,编译过程很繁琐!|_|!
  4. RoundedImageView
    带圆角的ImageView
    项目地址:https://github.com/vinc3m1/RoundedImageView
    效果图:Renderings
  5. ColorArt
    根据图片的均色设置背景色显示文字和图片,类似itune11中效果
    项目地址:https://github.com/MichaelEvans/ColorArt
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/color-art-demo.apk?raw=true
  6. CircleImageView
    圆形的ImageView
    项目地址:https://github.com/hdodenhof/CircleImageView
    效果图:Renderings
  7. ImageViewZoom
    支持放大和平移的ImageView
    项目地址:https://github.com/sephiroth74/ImageViewZoom
    APP示例:https://play.google.com/store/apps/details?id=com.aviary.android.feather
  8. KenBurnsView
    实现Ken Burns effect效果,达到身临其境效果的ImageView
    项目地址:https://github.com/flavioarfaria/KenBurnsView
  9. CustomShapeImageView
    各种形状的ImageView, 相比上面的圆形ImageView,多了更多形状
    项目地址:https://github.com/MostafaGazar/CustomShapeImageView
    效果图:Renderings

七、ProgressBar

  1. SmoothProgressBar
    水平进度条
    项目地址:https://github.com/castorflex/SmoothProgressBar
    Demo地址:https://play.google.com/store/apps/details?id=fr.castorflex.android.smoothprogressbar.sample
  2. ProgressWheel
    支持进度显示的圆形ProgressBar
    项目地址:https://github.com/Todd-Davies/ProgressWheel
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/progress-wheel-demo.apk?raw=true
  3. android-square-progressbar
    在图片周围显示进度
    项目地址:https://github.com/mrwonderman/android-square-progressbar
    Demo地址:https://play.google.com/store/apps/details?id=net.yscs.android.square_progressbar_example
    APP示例:square
    效果图:Renderings
  4. HoloCircularProgressBar
    Android4.1 时钟App样式
    项目地址:https://github.com/passsy/android-HoloCircularProgressBar
    APP示例:Android4.1时钟App
    效果图:Renderings
  5. ProgressButton
    通过图钉的不同状态显示进度
    项目地址:https://github.com/f2prateek/progressbutton
    文档介绍:http://f2prateek.com/progressbutton/
    效果图:Renderings
  6. GoogleProgressBar
    类似google 多个圆形卡片翻转的progressBar
    项目地址:https://github.com/jpardogo/GoogleProgressBar
    效果图:Renderings
  7. TH-ProgressButton
    带圆形进度显示的按钮
    项目地址;https://github.com/torryharris/TH-ProgressButton
    效果图:RenderingsRenderingsRenderingsRenderings
  8. NumberProgressBar
    带数字进度的进度条
    项目地址:https://github.com/daimajia/NumberProgressBar
    效果图:Renderings
  9. CircularProgressDrawable
    带圆形进度显示的进度条
    项目地址:https://github.com/Sefford/CircularProgressDrawable
    效果图:Renderings
  10. circular-progress-button
    带进度显示的Button
    项目地址:https://github.com/dmytrodanylyk/circular-progress-button
    效果图:Renderings

八、TextView

包括TextView及所有继承自TextView控件,如EditText、Button、RadioButton

  1. android-flowtextview
    文字自动环绕其他View的Layout
    项目地址:https://code.google.com/p/android-flowtextview/
    效果图:http://i949.photobucket.com/albums/ad332/vostroman1500/1.png
  2. Android Form EditText
    验证输入合法性的编辑框,支持输入、英文、ip、url等多种正则验证
    项目地址:https://github.com/vekexasia/android-edittext-validator
    Demo地址:https://play.google.com/store/apps/details?id=com.andreabaccega.edittextformexample
  3. Emojicon
    支持emojis的TextView和EditText
    项目地址:https://github.com/rockerhieu/emojicon
    文档地址:http://rockerhieu.com/emojicon/
  4. android-circlebutton
    Android圆形按钮,实际实现是继承自ImageView
    项目地址:https://github.com/markushi/android-circlebutton
    Demo地址:https://github.com/markushi/android-circlebutton/blob/master/example/example.apk
  5. Segmented Radio Buttons for Android
    iOS’s segmented controls的实现
    项目地址:https://github.com/vinc3m1/android-segmentedradiobutton
    Demo地址:https://github.com/thquinn/DraggableGridView/blob/master/bin/DraggableGridViewSample.apk?raw=true
    效果图:Renderings
  6. Chips EditText Library
    支持国家名字联想从而选择显示该国国旗的EditText,实际就是通过SpannableStringBuilder实现
    项目地址:https://github.com/kpbird/chips-edittext-library
    Demo地址:https://github.com/kpbird/chips-edittext-library/tree/master/ChipsEditTextDemo/bin
  7. AutoFitTextView
    可固定边界内容字体大小自适应的TextView
    项目地址:https://github.com/grantland/android-autofittextview
  8. Shimmer for Android
    文字发淡光的TextView
    项目地址:https://github.com/RomainPiel/Shimmer-android
  9. Titanic
    可以显示水位上升下降(不知道该怎么描述 囧)的TextView
    项目地址:https://github.com/RomainPiel/Titanic
    效果图:Renderings
  10. android-iconify
    提供带Icon的TextView,Menu,Button等
    项目地址:https://github.com/JoanZapata/android-iconify
  11. Calligraphy
    让我们在android开发中使用自定义字体变得更加简单
    项目地址 :https://github.com/chrisjenx/Calligraphy
    效果图:Renderings
  12. CreditsRoll
    类似星球大战字幕效果的TextView
    项目地址:https://github.com/frakbot/CreditsRoll
  13. android-process-buton
    带加载或提交进度的Button
    项目地址:https://github.com/dmytrodanylyk/android-process-buton
  14. FButton
    扁平化的Button
    项目地址:https://github.com/hoang8f/android-flat-button
    Demo地址:https://play.google.com/store/apps/details?id=info.hoang8f.fbutton.demo
  15. FloatingActionButton
    一个类似Android版Google+浮动功能按钮的控件,可以响应ListView的滚动事件。当列表向上滚动的时候会自动显示,向下滚动的时候自动隐藏。
    项目地址:https://github.com/makovkastar/FloatingActionButton
    Demo地址:https://github.com/makovkastar/FloatingActionButton/tree/master/
    效果图:Renderings
  16. Android Saripaar
    Android表单验证
    项目地址:https://github.com/ragunathjawahar/android-saripaar/
  17. JumpingBeans
    文字像 Mexican beans 一样跳动
    项目地址:https://github.com/frakbot/JumpingBeans
    Demo地址:http://play.google.com/store/apps/details?id=net.frakbot.jumpingbeans.demo
    效果图:Renderings
  18. FancyButtons
    一个不用图片就可以帮助我们创建出漂亮按钮的库。
    项目地址:https://github.com/medyo/fancybuttons
    Demo地址:https://github.com/medyo/fancybuttons/tree/master/samples
    效果图:RenderingsRenderings

九、ScrollView

  1. Discrollview
    支持滚动时Item淡入淡出,平移,缩放效果的ScrollView
    项目地址:https://github.com/flavienlaurent/discrollview
    Demo地址:https://github.com/flavienlaurent/discrollview/raw/master/sample.apk
  2. PullScrollView
    仿照新浪微博Android客户端个人中心的ScrollView,下拉背景伸缩回弹效果。
    项目地址:https://github.com/MarkMjw/PullScrollView
    效果图:Renderings
  3. ParallaxScrollView
    支持视差滚动的ScrollView ,背景图片的滚动速度小于ScrollView中子控件的滚动速度
    项目地址:https://github.com/chrisjenx/ParallaxScrollView
    Demo地址:http://cloud.github.com/downloads/chrisjenx/ParallaxScrollView/ParallaxScrollViewDemo-v1.0.5.apk

十、TimeView

包括TimePicker、DatePicker、CalendarView、Clock等时间相关控件

  1. android-times-square
    Android日历时间部件,支持选取单个日期,多个日期,及日期区间段和对话框形式显示
    项目地址:https://github.com/square/android-times-square
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/times-square-demo.apk?raw=true
  2. android-calendar-card
    日历
    项目地址:https://github.com/kenumir/android-calendar-card
    Demo地址:https://play.google.com/store/apps/details?id=com.wt.calendarcardsample
    效果图:Renderings
  3. AndroidWheel
    Android Wheel支持城市、多种日期时间、密码、图片
    项目地址:https://code.google.com/p/android-wheel/
    效果图:Renderings
  4. GoogleDateTimePickers
    时间选择部件
    项目地址:https://github.com/Mirkoddd/GoogleDateTimePickers
    文档地址:https://play.google.com/store/apps/details?id=com.mirko.sample&hl=it
  5. DateTimePicker
    日期选择部件(Google Agenda的样式风格)
    项目地址:https://github.com/flavienlaurent/datetimepicker
    Demo地址:https://raw.github.com/biboune/datetimepicker/master/datetimepicker-sample.apk
    效果图:Renderings
  6. android-betterpickers
    提供日期、数字、时间(数字方式和钟表方式)、重复周期(闹钟的周期重复)、HMS(时、分、秒)的选择,支持以DialogFragment的弹窗选择
    项目地址:https://github.com/derekbrameyer/android-betterpickers
    Demo地址:https://play.google.com/store/apps/details?id=com.doomonafireball.betterpickers.sample 效果图:Renderings

十一、TipView

包括Toast、角标、UndoBar等提示性控件

  1. Crouton
    丰富样式的Toast,允许alert、comfirm、info样式及点击消失样式,允许设置Toast显示时间,允许自定义View。 本文32. SuperToasts为其扩展版
    项目地址:https://github.com/keyboardsurfer/Crouton
    Demo地址:http://play.google.com/store/apps/details?id=de.keyboardsurfer.app.demo.crouton
  2. supertooltips
    带动画效果的Tips显示
    项目地址:https://github.com/nhaarman/supertooltips
    Demo地址:https://play.google.com/store/apps/details?id=com.haarman.supertooltips
  3. Android ViewBadger
    为其他View添加角标等
    项目地址:https://github.com/jgilfelt/android-viewbadger
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/android-viewbadger.apk?raw=true
    效果图:Renderings
  4. SuperToasts
    更丰富样式的toast,支持Button、Progress、Horizontal Progress样式、支持进入动画、支持撤销及其动画设置
    项目地址:https://github.com/JohnPersano/SuperToasts
    Demo地址:https://play.google.com/store/apps/details?id=com.supertoastsdemo
    效果图:SuperButtonToast
  5. UndoBar
    屏幕底部显示取消或是确认的PopupWindows
    项目地址:https://github.com/soarcn/UndoBar
    效果图:Renderings
  6. UndoBar
    屏幕底部显示取消或是确认某操作
    项目地址:https://github.com/jenzz/Android-UndoBar
    效果图:Renderings
  7. Android-ActionItemBadge
    可以在ActionBar的MenuItem上显示一个小角标
    项目地址:https://github.com/mikepenz/Android-ActionItemBadge
    效果图:Renderings

十二、FlipView

  1. android-flip
    类似Flipboard翻转动画的实现
    项目地址:https://github.com/openaphid/android-flip
    Demo地址:https://github.com/openaphid/android-flip/blob/master/FlipView/Demo/APK/Aphid-FlipView-Demo.apk?raw=true
    APP示例:flipboard
  2. FlipImageView
    支持x、y、z及动画选择的翻转动画的实现
    项目地址:https://github.com/castorflex/FlipImageView
    Demo地址:https://play.google.com/store/apps/details?id=fr.castorflex.android.flipimageview
  3. FoldableLayout
    Flip翻转效果的ListView,目前还不支持ListView缓存
    项目地址:https://github.com/alexvasilkov/FoldableLayout
    Demo地址:http://play.google.com/store/apps/details?id=com.alexvasilkov.foldablelayout.sample

十三、ColorPickView

  1. ColorPickerView
    颜色选择器,支持PopupWindows或新的Activity中打开
    项目地址:https://code.google.com/p/color-picker-view/
    效果图:Renderings
  2. HoloColorPicker
    颜色选择器
    项目地址:https://github.com/LarsWerkman/HoloColorPicker
    Demo地址:https://docs.google.com/file/d/0BwclyDTlLrdXRzVnTGJvTlRfU2s/edit
  3. ColorPickerPreference
    颜色选择器
    项目地址:https://github.com/attenzione/android-ColorPickerPreference
    效果图:Renderings
  4. ColorPicker
    颜色选择器(Google Agenda中的样式风格)
    项目地址:https://github.com/flavienlaurent/colorpicker
    Demo地址:https://raw.github.com/biboune/colorpicker/master/colorpicker-sample.apk 效果图:Renderings

十四、GraphView

  1. achartengine
    强大的图表绘制工具,支持折线图、面积图、散点图、时间图、柱状图、条图、饼图、气泡图、圆环图、范围(高至低)条形图、拨号图/表、立方线图及各种图的结合
    项目地址:https://code.google.com/p/achartengine/
    官方网站http://www.achartengine.org/
    效果图:Renderings
    http://www.achartengine.org/dimages/sales_line_and_area_chart.png
    http://www.achartengine.org/dimages/temperature_range_chart.png
    http://www.achartengine.org/dimages/combined_chart.png
    http://www.achartengine.org/dimages/budget_chart.png
    APP示例:Wordpress Android,Google Analytics
  2. GraphView
    绘制图表和曲线图的View,可用于Android上的曲形图、柱状图、波浪图展示
    项目地址:https://github.com/jjoe64/GraphView
    Demo地址:https://play.google.com/store/apps/details?id=com.sothree.umano
    Demo项目:https://github.com/jjoe64/GraphView-Demos
    APP示例:Wordpress Android,Google Analytics
  3. HoloGraphLibrary
    绘制现状图、柱状图、饼状图
    项目地址:https://bitbucket.org/danielnadeau/holographlibrary/src
    文档介绍:https://bitbucket.org/danielnadeau/holographlibrary/wiki/Home
  4. XCL-Charts
    XCL-Charts基于原生的Canvas来绘制各种图表,在设计时,尽量在保证开发效率的同时,给使用者提供足够多的定制化能力。因此使用简便,同时 具有相当灵活的定制能力。目前支持3D/非3D柱形图(Bar Chart)、3D/非3D饼图(Pie Chart)、堆积图(Stacked Bar Chart)、面积图(Area Chart)、 折线图(Line Chart)、曲线图(Spline Chart)、环形图(Dount Chart)、南丁格尔玫瑰图(Rose Chart)、仪表盘(Dial Chart)、刻度盘(Gauge Chart)、雷达图(Radar Chart)、圆形图(Circle Chart)等图表。其它特性还包括支持图表缩放、手势移动、动画显示效果、高密度柱形显示、图表分界定制线、多图表的混合显示及同数据源不同类型图表切 换等。
    项目地址:https://github.com/xcltapestry/XCL-Charts
    Demo地址:https://github.com/xcltapestry/XCL-Charts/blob/master/XCL-Charts-demo/bin/XCL-Charts-demo.apk?raw=true
  5. EazeGraph
    Android 图表库,支持柱状图、分层柱状图、饼状图、线性图
    项目地址:https://github.com/blackfizz/EazeGraph
    Demo地址:https://play.google.com/store/apps/details?id=org.eazegraph.app
  6. MPAndroidChart
    一个简单的绘制图表和曲线图View的库,可绘制线性图、2D/3D柱状图、饼图、散点图等
    项目地址:https://github.com/PhilJay/MPAndroidChart
    Demo项目:https://github.com/PhilJay/MPAndroidChart/tree/master/MPChartExample
    效果图:




十五、UI Style

不同样式的系统UI风格,如IOS、Bootstrap风格

  1. UITableView
    ios风格控件,包括Button、ListView、TableView
    项目地址:https://github.com/thiagolocatelli/android-uitableview
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/ui-tableview-demo.apk?raw=true
  2. ATableView
    ios风格控件
    项目地址:https://github.com/dmacosta/ATableView
    Demo地址:https://play.google.com/store/apps/details?id=com.nakardo.atableview.demo
  3. Cards-UI
    卡片式View,支持单个卡片,item为卡片的ListView
    项目地址:https://github.com/afollestad/Cards-UI
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/cards-ui-demo.apk?raw=true
  4. cardslib
    卡片式View,支持单个卡片,item为卡片的ListView和GridView
    项目地址:https://github.com/gabrielemariotti/cardslib
    Demo地址:https://play.google.com/store/apps/details?id=it.gmariotti.cardslib.demo
  5. Android-Bootstrap
    Bootstrap 风格的按钮
    项目地址: https://github.com/Bearded-Hen/Android-Bootstrap
    效果图:Renderings

十六、其他

  1. SwipeBackLayout
    左右或向上滑动返回的Activity
    项目地址:https://github.com/Issacw0ng/SwipeBackLayout
    Demo地址:https://play.google.com/store/apps/details?id=me.imid.swipebacklayout.demo
    APP示例:知乎
  2. android-styled-dialogs
    可自定义样式的dialog,默认与Holo主题样式一致,在Android2.2以上同一样式
    项目地址:https://github.com/inmite/android-styled-dialogs
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/styled-dialogs-demo.apk?raw=true
  3. Android Sliding Up Panel
    可拖动的View,能在当前Activity上扶起一个可拖动的Panel
    项目地址:https://github.com/umano/AndroidSlidingUpPanel
    Demo地址:https://play.google.com/store/apps/details?id=com.sothree.umano
    APP示例:Google Music精简播放栏
  4. AndroidWheel
    Android Wheel支持城市、多种日期时间、密码、图片
    项目地址:https://code.google.com/p/android-wheel/
    效果图:Renderings
  5. TableFixHeaders
    第一列固定的Table
    项目地址:https://github.com/InQBarna/TableFixHeaders
    Demo地址:http://bit.ly/13buAIq
  6. Inscription
    可用于展示应用change和new feature信息
    项目地址:https://github.com/MartinvanZ/Inscription
  7. ActivityTransition
    Activity切换动画,包括渐变、flip、某个位置进入等等
    项目地址:https://github.com/ophilbert/ActivityTransition
    使用介绍:https://github.com/jfeinstein10/JazzyViewPager/blob/master/JazzyViewPager.apk?raw=true
    效果图:类似桌面左右切换的各种效果,不过桌面并非用ViewPager实现而已
  8. 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
    效果图:Renderings
  9. GlowPadView
    Android4锁屏界面解锁
    项目地址:https://github.com/nadavfima/GlowPadView
    效果图:https://raw.github.com/nadavfima/GlowPadView/master/example.png
  10. 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开机的图案密码解锁,支付宝的密码解锁
  11. RangeBar
    类似于SeekBar,不同的是可以选择一个范围内的值而不是单个值
    项目地址:https://github.com/edmodo/range-bar
    Demo地址:https://github.com/Trinea/TrineaDownload/blob/master/range-bar-demo.apk?raw=true
    效果图: Renderings
  12. ChromeView
    利用Chromium实现的WebView,解决各个Android版本WebView不同的问题,同时利用最新Chrome代码
    项目地址:https://github.com/pwnall/chromeview
  13. Android Slider Preference Library
    可添加到设置中的基于对话框的RankBar小部件
    项目地址:https://github.com/jayschwa/AndroidSliderPreference
  14. ShowcaseView library
    用于高亮显示应用程序的特定部分,从而突出突出重点
    项目地址:https://github.com/amlcurran/ShowcaseView
  15. android-segmented-control
    Android上的Segmented Controls,相当于RadioButton组
    项目地址:https://github.com/hoang8f/android-segmented-control
  16. Swipeable Cards
    类似Tinder的卡片效果,可以加载图片并动画效果展示,向左滑动表示喜欢,向右表示不喜欢
    项目地址:https://github.com/kikoso/Swipeable-Cards
    Demo地址:https://play.google.com/store/apps/details?id=info.hoang8f.fbutton.demo
  17. EdgeEffectOverride
    改变ScrollView, ListView, ExpandableListView, GridView, ViewPager等滚动控件滚动到边缘的颜色效果
    项目地址:https://github.com/AndroidAlliance/EdgeEffectOverride
  18. android-pinned-header-listviews
    使ExpandListView的Group滑动到顶端时会固定不动直到另外一个Group到达顶端
    项目地址:https://github.com/rtyley/android-pinned-header-listviews

第二部分 工具库

主要包括那些不错的开发库,包括依赖注入框架、图片缓存、网络相关、数据库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)可根据系统配置初始化缓存等

三、网络相关

  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. ormlite-android
    项目地址:https://github.com/j256/ormlite-android
    文档介绍:http://ormlite.com/sqlite_java_android_orm.shtml
  5. 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
  5. CleanAndroidCode
    整合了Dagger Otto AndroidAnnotations,方便快速开发
    项目地址:https://github.com/pyricau/CleanAndroidCode
  6. xUtils
    基于Afinal,包含DbUtils、ViewUtils、HttpUtils、BitmapUtils四大模块,可用于快速开发
    项目地址:https://github.com/wyouflf/xUtils
  7. 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

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

七、多媒体相关

  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).自动其它重要区域。如果图片中未识别出人脸,则会根据特征分布计算出重区域
  6. Cropper
    图片局部剪切工具,可触摸控制选择区域或旋转
    项目地址:https://github.com/edmodo/cropper
    使用介绍:https://github.com/edmodo/cropper/wiki
    效果图:Renderings
  7. android-crop
    图片裁剪Activity
    项目地址:https://github.com/jdamcd/android-crop
    效果图:Renderings
  8. TileView
    可分块显示大图,支持2D拖动、双击、双指放大、双指捏合
    项目地址:https://github.com/moagrius/TileView
    Demo地址:http://moagrius.github.io/TileView/TileViewDemo.apk
  9. BlurEffectForAndroidDesign
    图片模糊效果
    项目地址:https://github.com/PomepuyN/BlurEffectForAndroidDesign
  10. android-eye
    PC端网页查看同一局域网内的手机摄像头内容,可以用来监控哦
    项目地址:https://github.com/Teaonly/android-eye
    Demo地址:https://play.google.com/store/apps/details?id=teaonly.droideye
  11. libpng for Android
    PNG图片的jni库,支持几乎png的所有特性
    项目地址:https://github.com/julienr/libpng-android
    文档地址:http://www.libpng.org/pub/png/libpng.html
  12. android-gpuimage
    基于GPU的图片滤镜
    项目地址:https://github.com/CyberAgent/android-gpuimage
  13. AndroidFaceCropper
    图片脸部自动识别,将识别后的局部图片返回
    项目地址:https://github.com/lafosca/AndroidFaceCropper
  14. 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
  15. svg-android
    Android Svg矢量图形支持
    项目地址:https://github.com/japgolly/svg-android https://github.com/japgolly/svg-android
  16. Android Visualizer
    从Android MediaPlayer获得音频,然后像iTunes及WinAmp一样展示音轨
    项目地址:https://github.com/felixpalmer/android-visualizer
  17. ExoPlayer
    包括仪表板和SmoothStreaming自适应回放,缓存持久化和自定义渲染器,方便自定义和扩展,并且可以通过应用商店更新
    项目地址:https://github.com/google/ExoPlayer

八、事件总线(订阅者模式)

通过发布/订阅事件解耦事件发送和接受,从而简化应用程序组件(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
  12. farebot
    通过NFC 从公交卡中读取数据的一个应用
    项目地址:https://github.com/codebutler/farebot

十、安全

  1. SQLCipher
    Sqlite加密工具
    项目地址:https://github.com/sqlcipher/sqlcipher
    帮助文档:http://sqlcipher.net/sqlcipher-for-android/
  2. Conceal
    快速高效的进行文件加密解密
    项目地址:https://github.com/facebook/conceal
    文档介绍:https://github.com/facebook/conceal#usage
  3. 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,支付宝,挖财
  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
    效果图:Renderings
  5. GlowPadView
    Android 4锁屏界面解锁
    项目地址:https://github.com/nadavfima/GlowPadView
    效果图:https://raw.github.com/nadavfima/GlowPadView/master/example.png
  6. 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开机的图案密码解锁,支付宝的密码解锁

十一、插件化

  1. dynamic-load-apk
    Android动态加载Apk,热部署。支持一定程度不安装升级
    项目地址:https://github.com/singwhatiwanna/dynamic-load-apk
    文档介绍:http://blog.csdn.net/singwhatiwanna/article/details/22597587
  2. xCombine
    Android App插件式插件开发,插件必须先安装
    项目地址:https://github.com/wyouflf/xCombine
    文档介绍:http://my.oschina.net/u/1171837/blog/155377
  3. Android Plugin Framework
    Android插件式开发,开放的源码目前不完整
    项目地址:https://github.com/umeng/apf

十二、文件

对不同文档类型的处理,包括PDF、Word、EPub、Html、Zip等

  1. purePDF
    允许从任何运行的SWF文件读取和创建PDF文档
    项目地址:https://github.com/sephiroth74/purePDF
  2. Office 365 SDK for Android Preview
    可支持Microsoft SharePoint Lists, Microsoft SharePoint Files, Microsoft Exchange Calendar, Microsoft Exchange Contacts, Microsoft Exchange Mail
    项目地址:https://github.com/OfficeDev/Office-365-SDK-for-Android
  3. OpenSpritz-Android
    EPub阅读器
    项目地址:https://github.com/OnlyInAmerica/OpenSpritz-Android
  4. jsoup
    一个解析html的java库,可方便的提取和操作数据
    项目地址:https://github.com/jhy/jsoup
    官方网站:http://jsoup.org/
    作用:(1) 从一个url、文件或string获得html并解析
    (2) 利用dom遍历或css选择器查找、提取数据
    (3) 操作html元素
    (4) 根据白名单去除用于提交的非法数据防止xss攻击
    (5) 输出整齐的html
  5. ZIP
    java压缩和解压库
    项目地址:https://github.com/zeroturnaround/zt-zip
    文档介绍:https://github.com/zeroturnaround/zt-zip#examples
    作用:(1) 解压和压缩,并支持文件夹内递归操作
    (2) 支持包含和排除某些元素
    (3) 支持重命名元素
    (4) 支持遍历zip包内容
    (5) 比较两个zip包等功能

十三、其他

  1. Salvage view
    带View缓存的Viewpager PagerAdapter,很方便使用
    项目地址:https://github.com/JakeWharton/salvage
  2. Android Priority Job Queue
    Android后台任务队列
    项目地址:https://github.com/path/android-priority-jobqueue
    文档介绍:https://github.com/path/android-priority-jobqueue#getting-started
  3. Cobub Razor
    开源的mobile行为分析系统,包括web端、android端,支持ios和window phone
    项目地址:https://github.com/cobub/razor
    Demo地址:http://demo.cobub.com/razor
    网站介绍:http://dev.cobub.com/
  4. Countly
    Android移动端数据采集分析系统
    项目地址:https://github.com/Countly/countly-sdk-android
    官网地址:https://count.ly/
  5. aFileChooser
    文件选择器,可内嵌到程序中,而无需使用系统或三方文件选择器。
    项目地址:https://github.com/iPaulPro/aFileChooser
  6. androidpn
    基于xmpp协议的消息推送解决方案,包括服务器端和android端。
    项目地址:https://github.com/dannytiehui/androidpn
  7. Bolts
    Android的异步编程模式
    项目地址:https://github.com/BoltsFramework/Bolts-Android/
    与AsyncTask比较:(1) 使用的是无大小限制的线程池
    (2) 任务可组合可级联,防止了代码耦合
  8. CastCompanionLibrary-android
    使Android程序中更快的接入Google Cast
    项目地址:https://github.com/googlecast/CastCompanionLibrary-android
    文档介绍:https://developers.google.com/cast/
  9. CastVideos-android
    从Android设备分享Video通过Google Cast
    项目地址:https://github.com/googlecast/CastVideos-android
    文档介绍:https://developers.google.com/cast/
  10. Uninstall_Statics
    Android应用自身被卸载监听及打开浏览器等反馈功能实现
    项目地址:https://github.com/sevenler/Uninstall_Statics
    文档介绍:http://www.cnblogs.com/zealotrouge/p/3157126.html
    http://www.cnblogs.com/zealotrouge/p/3159772.html
  11. Memento
    保证在系统配置改变时,Activity中的某些数据可以简单安全的保持不变
    项目地址:https://github.com/mttkay/memento
    文档介绍:https://github.com/mttkay/memento#usage
  12. FreeFlow
    布局引擎,更简单的创建自定义布局,并且当数据和布局改变时更美观的过渡动画
    项目地址:https://github.com/Comcast/FreeFlow
    Demo地址:https://github.com/Comcast/FreeFlow/releases
  13. Android Gesture Detectors Framework
    Android手势框架,支持双指旋转、移动、平移、缩放等
    项目地址:https://github.com/Almeros/android-gesture-detectors
  14. Mapbox Android SDK
    Android Map的替代版
    项目地址:https://github.com/mapbox/mapbox-android-sdk
  15. Activity animation
    Activity跳转动画,支持各个方向波浪的效果
    项目地址:https://github.com/flavienlaurent/activityanimation
    在线演示:https://www.youtube.com/watch?v=-E0sc6w_Jck
  16. KryoNet
    通过NIO提供客户端和服务器端TCP/UDP网络传输的Java库
    项目地址:https://github.com/EsotericSoftware/kryonet
  17. Rebound
    一个模仿弹簧反弹的Java库,可用于创建动画
    项目地址:https://github.com/facebook/rebound
  18. Android Social Networks
    社交网络接入统一管理器,可方便的从Twitter, LinkedIn, Facebook, Google Plus登陆、获得个人信息、发送消息、发送专篇、添加或删除好友
    项目地址:https://github.com/antonkrasov/AndroidSocialNetworks
    Demo地址:https://play.google.com/store/apps/details?id=com.github.androidsocialnetworks.apidemos
  19. Magnet
    创建类似 Facebook 聊天桌面悬浮窗的效果
    项目地址:https://github.com/premnirmal/Magnet
  20. Parceler
    通过注解及工具类自动完成实体类 Parcelable及值传递
    项目地址:https://github.com/johncarl81/parceler
  21. AcDisplay
    将 Android 的通知都集中到锁屏显示
    项目地址:https://github.com/AChep/AcDisplay
    Demo地址:https://play.google.com/store/apps/details?id=com.achep.acdisplay

第三部分 优秀项目

主要介绍那些Android还不错的完整项目,目前包含的项目主要依据是项目有意思或项目分层规范比较好。
Linux
项目地址:https://github.com/torvalds/linux
Android
项目地址:https://android.googlesource.com/https://github.com/android
以上两个项目,不解释

(1) ZXing
二维码扫描工具
项目地址:https://github.com/zxing/zxinghttps://code.google.com/p/zxing/
APK地址:https://play.google.com/store/apps/details?id=com.google.zxing.client.android
PS:现在市面上很多应用的二维码扫描功能都是从这个修改而来

(2) photup
编辑机批量上传照片到facebook上
项目地址:https://github.com/chrisbanes/photup
APK地址:https://play.google.com/store/apps/details?id=uk.co.senab.photup
PS:代码分包合理,很棒。不过这个项目依赖的开源项目比较多,比较难编译

(3) github-android
Github的Android客户端项目
项目地址:https://github.com/github/android
APK地址:https://play.google.com/store/apps/details?id=com.github.mobile

(4) Notes
MIUI便签
项目地址:https://github.com/MiCode/Notes
APK地址:https://github.com/Trinea/TrineaDownload/blob/master/miui-note-demo.apk?raw=true
PS:项目分包比较合理,相比较miui的文件管理器https://github.com/MiCode/FileExplorer 代码规范较好得多

(5) weicuiyuan
四次元-新浪微博客户端
项目地址:https://github.com/qii/weiciyuan
APK地址:https://play.google.com/store/apps/details?id=org.qii.weiciyuan

(6) gnucash-android
一个记账理财软件
项目地址:https://github.com/codinguser/gnucash-android
APK地址:http://play.google.com/store/apps/details?id=org.gnucash.android

(7) AntennaPod
支持rss订阅、音乐订阅
项目地址:https://github.com/danieloeh/AntennaPod
APK地址:https://play.google.com/store/apps/details?id=de.danoeh.antennapod

(8) ChaseWhisplyProject
打鬼游戏
项目地址:https://github.com/tvbarthel/ChaseWhisplyProject
APK地址:https://play.google.com/store/apps/details?id=fr.tvbarthel.games.chasewhisply

(9) Tweet Lanes
功能完整的Twitter客户端
项目地址:https://github.com/chrislacy/TweetLanes
APK地址:https://play.google.com/store/apps/details?id=com.tweetlanes.android

(10) Financius
简单易用的记账程序
项目地址:https://github.com/mvarnagiris/Financius
APK地址:https://play.google.com/store/apps/details?id=com.code44.finance

(11) todo.txt-android
todo.txt的官方Android应用
项目地址:https://github.com/ginatrapani/todo.txt-android
APK地址:https://play.google.com/store/apps/details?id=com.todotxt.todotxttouch

(12) simpletask
基于todo.txt官方应用的另一个客户端
项目地址:https://github.com/mpcjanssen/simpletask-android
APK地址:https://play.google.com/store/apps/details?id=nl.mpcjanssen.todotxtholo

(13) Muzei Live Wallpaper
定时更换桌面精美壁纸
项目地址:https://github.com/romannurik/muzei
APK地址:https://play.google.com/store/apps/details?id=net.nurik.roman.muzei

第四部分 开发工具及测试工具

主要介绍和Android开发工具和测试工具相关的开源项目。

一、开发效率工具

  1. Parceler
    通过注解及工具类自动完成实体类 Parcelable及值传递项目地址:https://github.com/johncarl81/parceler
  2. Json2Java
    根据JSon数据自动生成对应的Java实体类,还支持Parcel、Gson Annotations对应代码自动生成。期待后续的提取父类以及多url构建整个工程的功能
    项目地址:https://github.com/jonfhancock/JsonToJava
    在线演示:http://jsontojava.appspot.com/
  3. IntelliJ Plugin for Android Parcelable boilerplate code generation
    Android studio插件,生成Parcelable代码
    项目地址:https://github.com/mcharmas/android-parcelable-intellij-plugin
    效果图:Holo Colors Idea
  4. Android Holo Colors IntelliJ Plugin
    Android studio插件,生成holo样式9 patch图片
    项目地址:https://github.com/jeromevdl/android-holo-colors-idea-plugin
    效果图:Holo Colors Idea
  5. Android Drawable Factory
    用于生成各个分辨率的图片
    项目地址:https://github.com/tizionario/AndroidDrawableFactory
    效果图:Android Drawable Factory
  6. SelectorChapek for Android
    Android Studio插件,可根据固定文件名格式资源自动生成drawable selectors xml文件。
    项目地址:https://github.com/inmite/android-selector-chapek
  7. Android Action Bar Style Generator
    Android ActionBar样式生成器,可在线选择ActionBar样式自动生成所需要的图片资源及xml文件
    项目地址:https://github.com/jgilfelt/android-actionbarstylegenerator
    在线演示:http://jgilfelt.github.io/android-actionbarstylegenerator/
  8. ButterKnifeZelezny
    用于快速生成ButterKnifeView注入代码的Android Studio/IDEA插件
    项目地址:https://github.com/inmite/android-butterknife-zelezny
  9. RoboCoP
    利用Gradle task根据固定格式的json文件生成ContentProvider
    项目地址:https://github.com/mediarain/RoboCoP
  10. appiconsizes
    用于生成各个分辨率的图片
    项目地址:http://www.appiconsizes.com/
  11. Gradle Retrolambda Plugin
    Retrolambda是将Java8的Lambdas应用于Java7的工具,本项目是Gradle插件,通过Retrolambda从而使Java或Android项目用Java8的Lambdas编写,将编译后的字节码转换为Java6和7的字节码从而正常运行
    项目地址:https://github.com/evant/gradle-retrolambda
  12. Dagger IntelliJ Plugin
    dagger的intellij插件
    项目地址:https://github.com/square/dagger-intellij-plugin
  13. Android Gen Drawable Maven plugin
    在编译时根据SVG描述文件生成不同分辨率的jpg、png或点9图片
    项目地址:https://github.com/avianey/androidgendrawable-maven-plugin
  14. Android Asset Studio
    各种Android资源自动生成器,包括启动图标、ActionBar图标、通知栏图标、点9等
    项目地址:https://github.com/romannurik/AndroidAssetStudio
    在线演示:http://romannurik.github.io/AndroidAssetStudio/

二、开发自测相关

  1. Quality Tools for Android
    Android测试及自测工具集合和示例
    项目地址:https://github.com/stephanenicolas/Quality-Tools-for-Android
  2. android-test-kit
    Google的Android测试工具
    包括GoogleInstrumentationTestRunner(增强版的InstrumentationTestRunner)和Espresso(用于快速写出可靠测试用例的API)
    项目地址:https://code.google.com/p/android-test-kit/
    文档介绍:https://code.google.com/p/android-test-kit/w/list
  3. robolectric
    测试用例编写框架
    项目地址:https://github.com/robolectric/robolectric
    Demo地址:https://github.com/robolectric/robolectricsample
    文档介绍:http://robolectric.org/
    特点:(1). 不需要模拟器在一般JVM就可以运行测试用例
    (2). 能完成在真机上的大部分测试包括感应器
    其他的测试用例及相关模块Mock可见:android-mock, mockito, easy-mock
  4. Android FEST
    提供一些列方便的断言,可用于提高编写Android自测代码效率
    项目地址:https://github.com/square/fest-android
  5. BoundBox
    可用于测试类各种访问权限的属性、方法。实际是通过BoundBox这个annotation生成一个属性和方法都是public权限的中间类并对此类进行测试完成的
    项目地址:https://github.com/stephanenicolas/boundbox
  6. Hugo
    用于打印函数信息及执行时间的工具,仅在Debug模式生效
    项目地址:https://github.com/JakeWharton/hugo
  7. scalpel
    在应用下面添加一层用于界面调试,待详细补充 // TODO
    项目地址:https://github.com/JakeWharton/scalpel
  8. Android Screenshot library
    Android截图工具类,用于在持续集成时截图
    项目地址:https://github.com/rtyley/android-screenshot-lib
  9. sonar-android-lint-plugin
    将android lint的错误在sonar中展现
    项目地址:https://github.com/SonarCommunity/sonar-android

三、测试工具

  1. Spoon
    可用于android不同机型设备自动化测试,能将应用apk和测试apk运行在不同机器上并生成相应测试报告。
    项目地址:https://github.com/square/spoon
  2. Tencent APT
    APT是腾讯开源的一个Android平台高效性能测试组件,提供丰富实用的功能,适用于开发自测、定位性能瓶颈;测试人员完成性能基准测试、竞品对比测试
    项目地址:https://github.com/stormzhang/APT
  3. Emmagee
    网易开源的性能测试工具,包括CPU、内存、网络流量、启动时间、电池状态等
    项目地址:https://github.com/NetEase/Emmagee
  4. Android py-uiautomator
    py-uiautomator是一个对Android uiautomator用python进行封装的测试框架.
    项目地址:https://github.com/xiaocong/uiautomator

四、开发及编译环境

  1. Buck
    facebook开源的Android编译工具,效率是ant的两倍。主要优点在于:
    (1) 加快编译速度,通过并行利用多核cpu和跟踪不变资源减少增量编译时间实现
    (2) 可以在编译系统中生成编译规则而无须另外的系统生成编译规则文件
    (3) 编译同时可生成单元测试结果
    (4) 既可用于IDE编译也可用于持续集成编译
    (5) facebook持续优化中
    项目地址:https://github.com/facebook/buck
  2. Android Maven Plugin
    Android Maven插件,可用于对android三方依赖进行管理。在J2EE开发中,maven是非常成熟的依赖库管理工具,可统一管理依赖库。
    项目地址:https://github.com/jayway/maven-android-plugin
  3. umeng-muti-channel-build-tool
    渠道打包工具
    项目地址:https://github.com/umeng/umeng-muti-channel-build-tool
    另可参见Google的构建系统Gradle:http://tools.android.com/tech-docs/new-build-system/user-guide
  4. Genymotion
    目前最好用最快的android模拟器
    项目地址:http://www.genymotion.com/
    Android studio集成控件: http://plugins.jetbrains.com/plugin/7269?pr=idea
    Cyril Mottier推荐:http://cyrilmottier.com/2013/06/27/a-productive-android-development-environment/
  5. gradle-mvn-push
    方便的将Gradle的Artifacts上传到Maven仓库
    项目地址:https://github.com/chrisbanes/gradle-mvn-push
    文档介绍:https://github.com/chrisbanes/gradle-mvn-push#usage
  6. Android Emulator Plugin for Jenkins
    Android模拟器 jenkins插件,用于Jenkins做持续集成时跑模拟器测试
    项目地址:https://github.com/jenkinsci/android-emulator-plugin
  7. Android Maven Plugin
    管理应用所需要的依赖库。包括的构建工具有Maven、Gradle、ant、sbt
    项目地址:https://github.com/mosabua/maven-android-sdk-deployer
  8. SDK Manager Plugin
    下载和管理Android SDK的Gradle插件
    项目地址:https://github.com/JakeWharton/sdk-manager-plugin
  9. Gradle Protobuf Plugin
    将.proto文件转换成Java文件的gradle插件
    项目地址:https://github.com/andrewkroh/gradle-protobuf-plugin

五、其他

  1. ViewServer
    允许app运行在任何手机上都可以用HierarchyViewer查看
    项目地址:https://github.com/romainguy/ViewServer
  2. GridWichterle for Android
    在整个系统上显示一个grid,用来帮助查看应用布局及使得布局更美观,可设置grid网格大小和颜色,android推荐48dp和8dp,可见 Android Design Guidelines – Metrics and Grids
    项目地址:https://github.com/inmite/android-grid-wichterle
    APK地址:https://play.google.com/store/apps/details?id=eu.inmite.android.gridwichterle
    PS:比起hierarchyviewer相差甚远,不过偶尔可用来作为布局查看工具。
  3. Catlog
    手机端log查看工具,支持不同颜色显示、关键字过滤、级别过滤、进程id过滤、录制功能等
    项目地址:https://github.com/nolanlawson/Catlog
    在线演示:https://play.google.com/store/apps/details?id=com.nolanlawson.logcat
  4. PID Cat
    根据package查看logcat日志
    项目地址:https://github.com/JakeWharton/pidcat
  5. ACRA
    应用崩溃信息上报到GoogleDoc工具,网页版展现结果三方开源地址https://github.com/BenoitDuffez/crashreportsviewer
    项目地址:https://github.com/ACRA/acra
    文档地址:https://github.com/ACRA/acra/wiki/BasicSetup
  6. Crashlytics
    提供丰富的应用崩溃信息收集
    轻量级,丰富,可自定义应用崩溃信息收集器,附有邮件通知
    项目地址:http://www.crashlytics.com/
    集成插件:Android Studio, Eclipse and IntelliJ
  7. Android Resource Navigator
    chrome插件,可以方便的查看github上android源码工程的styles.xml和themes.xml。主要功能:
    (1) 快速打开android styles.xml themes.xml
    (2) 方便在资源间跳转。styles.xml themes.xml文件中资源链接跳转,可以方便跳转到某个资源
    (3) 方便查找某个style和theme。chrome地址栏输入arn+tab+搜索内容回车即可
    (4) 自动下载不同分辨率下的drawable
    (5) 通过映射查找那些不是按照固定命名规则命名的style和theme
    项目地址:https://github.com/jgilfelt/android-resource-navigator
    在线演示:https://chrome.google.com/webstore/detail/android-resource-navigato/agoomkionjjbejegcejiefodgbckeebo?hl=en&gl=GB
  8. android-resource-remover
    根据lint的提示删除项目中无用的资源,减少包的大小
    项目地址:https://github.com/KeepSafe/android-resource-remover
  9. Telescope
    通过手势截图以特定主题发送到特定邮箱地址报告Bug
    项目地址:https://github.com/mattprecious/telescope
  10. Complete Android Fragment & Activity Lifecycle
    完整的Android Fragment/Activity生命周期图
    项目地址:https://github.com/xxv/android-lifecycle

第五部分

主要介绍那些乐于分享并且有一些很不错的开源项目的个人和组织。Follow大神,深挖大神的项目和following,你会发现很多。

一、个人

  1. JakeWharton
    就职于Square,绝对牛逼的大神,项目主要集中在Android版本兼容,ViewPager及开发工具上
    Github地址:https://github.com/JakeWharton
    代表作:ActionBarSherlock,Android-ViewPagerIndicator,Nine Old Androids,SwipeToDismissNOA,hugo,butterknife,Android- DirectionalViewPager, scalpel
    pidcat另外对square及其他开源项目有很多贡献
    主页:http://jakewharton.com/
  2. Chris Banes
    Github地址:https://github.com/chrisbanes
    代表作:ActionBar-PullToRefresh,PhotoView,Android-BitmapCache,Android-PullToRefresh
    主页:http://chris.banes.me/
  3. Koushik Dutta
    就职于ClockworkMod
    Github地址:https://github.com/koush
    代表作:Superuser,AndroidAsync,UrlImageViewHelper,ion, 另外对https://github.com/CyanogenMod 的开源项目有很多贡献
    主页:http://koush.com/
  4. Simon Vig
    Github地址:https://github.com/SimonVT
    代表作:android-menudrawer,MessageBar
    主页:http://simonvt.net/
  5. Manuel Peinado
    Github地址:https://github.com/ManuelPeinado
    代表作:FadingActionBar,GlassActionBar,RefreshActionItem,QuickReturnHeader
  6. Emil Sj?lander
    Github地址:https://github.com/emilsjolander
    代表作:StickyListHeaders,sprinkles,android-FlipView
    主页:http://emilsjolander.se/
  7. greenrobot
    Github地址:https://github.com/greenrobot
    代表作:greenDAO,EventBus
    主页:http://greenrobot.de/
  8. Jeff Gilfelt
    Github地址:https://github.com/jgilfelt
    代表作:android-mapviewballoons,android-viewbadger,android-actionbarstylegenerator,android-sqlite-asset-helper
    主页:http://jeffgilfelt.com
  9. Romain Guy
    Android team成员(2013.10已离开Android team,仍在Google)
    Github地址:https://github.com/romainguy
    代表作:ViewServer
    主页:http://www.curious-creature.org/category/android/
    個人攝影作品:http://www.flickr.com/photos/romainguy
  10. sephiroth74
    就职于Aviary.com
    Github地址:https://github.com/sephiroth74
    代表作:ImageViewZoom,HorizontalVariableListView,AndroidWheel,purePDF
    主页:http://www.sephiroth.it/
  11. Cyril Mottier
    Google开发者专家认证,发布一些Android技巧及文章
    Github地址:https://github.com/cyrilmottier
    代表作:GreenDroid,Polaris
    主页:http://cyrilmottier.com/

二、组织

  1. Square
    有态度有良心的企业,很多不错的分享
    Github地址:https://github.com/square
    代表作:okhttp、fest-android,android-times-square、picasso、dagger、spoon等等
    主页:http://square.github.io/
  2. Inmite s.r.o.
    Github地址:https://github.com/inmite
    代表作:android-styled-dialogs,android-grid-wichterle,android-selector-chapek
    主页:http://www.inmite.eu/

三、博客

Chet Haase
Android framework UI team 成员
主页:http://graphics-geek.blogspot.com/

HTML5利用现代设备传感器轻松地提供高级的Web用户体验

mikel阅读(709)

今天,我们在 HTML5Labs.com 上发布了 W3C DeviceOrientation 事件规范草稿的原型实施。此规范定义了提供设备的物理方向和运动相关信息的新 DOM 事件。此类 API 将允许 Web 开发者利用现代设备的传感器轻松地提供高级的 Web 用户体验。
开发者获益
利用设备方向 API,开发者可以探索游戏的新输入机制、应用程序的新笔势(例如“摇晃以清屏”或“倾斜以缩放”)或者甚至放大实际体验。原型的安装包括一个示例游戏,帮助您开始了解 API。

该视频以动态形式说明本博文中介绍的概念。
如何工作
设备方向 API 公开了两种不同类型的传感器数据:方向和运动。
当设备的物理方向变化时(例如用户倾斜或旋转设备),将会在窗口触发 deviceorientation 事件,并提供旋转的 alpha、beta 和 gamma 角度(以度表示):

显示由与 3D X、Y 和 Z 轴相关的 deviceorientation 事件返回的旋转的 alpha、beta 和 gamma 角:alpha = 绕 Z 轴旋转、beta = 绕 X 轴旋转和 gamma = 绕 Y 轴旋转。

<div id="directions"></div>
<script>
window.addEventListener("deviceorientation", findNorth);
function findNorth(evt) {
var directions = document.getElementById("directions");
if (evt.alpha < 5 || evt.alpha > 355) {
directions.innerHTML = "North!";
} else if (evt.alpha < 180) {
directions.innerHTML = "Turn Left";
} else {
directions.innerHTML = "Turn Right";
}
}
</script>

HTML5实现摇一摇的功能(实测后)

mikel阅读(750)

利用html5实现类似微信的手机摇一摇功能,并播放音乐。

1、  deviceOrientation:封装了方向传感器数据的事件,可以获取手机静止状态下的方向数据,例如手机所处角度、方位、朝向等。

2、  deviceMotion:封装了运动传感器数据的事件,可以获取手机运动状态下的运动加速度等数据。

不多说直接上代码,

JavaScript


var SHAKE_THRESHOLD = 3000;
var last_update = 0;
var x = y = z = last_x = last_y = last_z = 0;
function init() {
if (window.DeviceMotionEvent) {
window.addEventListener('devicemotion', deviceMotionHandler, false);
} else {
alert('not support mobile event');
}
}
function deviceMotionHandler(eventData) {
var acceleration = eventData.accelerationIncludingGravity;
var curTime = new Date().getTime();
if ((curTime - last_update) &gt; 100) {
var diffTime = curTime - last_update;
last_update = curTime;
x = acceleration.x;
y = acceleration.y;
z = acceleration.z;
var speed = Math.abs(x + y + z - last_x - last_y - last_z) / diffTime * 10000;

if (speed &gt; SHAKE_THRESHOLD) {
alert("摇动了");
media.setAttribute("src", "http://211.148.5.228:8002/Pages/test/Kalimba.mp3");
media.load();
media.play();
}
last_x = x;
last_y = y;
last_z = z;
}
}

Html:


&lt;!DOCTYPE html&gt;

&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta charset="utf-8" /&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&gt;
&lt;title&gt;摇一摇功能&lt;/title&gt;
&lt;script type="text/javascript"&gt;
//Javascript
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="init()"&gt;
&lt;p&gt;用力摇一摇你手机&lt;/p&gt;
&lt;audio style="display:hiden" id="musicBox" preload="metadata" controls src="http://211.148.5.228:8002/Pages/test/Kalimba.mp3" autoplay="false"&gt;
&lt;/audio&gt;
&lt;/body&gt;
&lt;/html&gt;

IOS 测试:Safari 弹框\不播放音乐, Chroma 弹框\不播放音乐,UC弹框\不播放音乐

Andriod 测试:UC弹框\播放音乐,Chroma 弹框\播放音乐,内置浏览器 弹框\播放音乐

 

[转载]Mugeda HTML5技术教程之12:制作跨屏互动应用 - mugedatech - 博客园

mikel阅读(697)

来源: [转载][Mugeda HTML5技术教程之12]制作跨屏互动应用 – mugedatech – 博客园

mugeda动画平台还可以用来制作跨屏互动的动画应 用,比如在PC端的大屏幕上显示动画的主界面,同时会显示出供手机扫描的二维码,手机扫描后会在手机上显示手机端动画界面。通过手机就可以和PC端的显示 界面跨屏互动操作。这种动画应用在类似一些商场搞活动,或者户外宣传等常见可以使用。可以制作一对一玩的跨屏互动应用,也可以制作一对多玩(多个玩家同时 玩)的跨屏互动应用。为了更好的理解跨屏互动应用的使用,本文档将通过一个简单的例子来演示跨屏动画的制作过程。

 

一、制作动画

1.PC端动画制作

a.在PC端,设置舞台吃尺寸为宽700、高480

b.在舞台中放在一个文字对象,并命名为info(用于显示连接及通讯信息)

c.在舞台中放在一个二维码的图片。(该二维码会在运行时被用真实的客户端连接的二维码替换)。给该图片命名qrc。

如图:

 

2.移动端动画制作

a.设置舞台尺寸为宽320、高416

b.在舞台中放一个用圆角矩形和文字组成的按钮,文字内容为connectPC。为该按钮设置动作为回调函数,触发方式:单击,函数名字:connectPC

如图:

 

c.用同步骤b相同的方式,再创建两个按钮,文字分别为sayHello、sayOK,函数名字分别为sayHello、sayOK。

最后舞台如图:

 

3.导入脚本

a.PC端,点击菜单栏的文件-》导入-》脚本。在弹出的导入脚本对话框中,勾选JQuery.js、socketio.js、JQuery.qrcode.js。点击确定。

如图:

 

b.用同样的方式在移动端导入socketio.js

导入文件说明:

跨屏动画通讯用到的Mugeda.Socket对象是基于socket.io封装的,所以PC端和移动端都需要导 入socketio.js文件。PC端需要在游戏开始时动态更换二维码图片,所以需要导入与二维码相关的库文件jQuery.js、 jQuery.qrcode.js

二、编写代码

用到的主要对象说明:

Mugeda.Socket对象,用于维护存连接相关数据和操作。

Mugeda.Socket.Client对象,用于维护存匿名认证客户的信息和操作。

实现通讯的主要步骤:

1.PC端先向服务器发起连接请求,产生连接

2.然后PC端通过侦听authorization事件获取到非认证用户(即客户端)带request和token的地址,进而通过replaceQrcode将动画中的图片对象替换为二维码。

3.玩家通过手机等移动设备扫描二维码,在自己的设备中打开客户端,

4.客户端向服务器发起连接请求,并产生连接

5.客户端与PC端通讯

连接服务器

通过实例化Mugeda.Socket对象,产生连接。Mugeda.Socket类的构造函数为:

Mugeda.Socket(request, token, isRegisteredUser, guestURL, server, port)

其中:

request:{string}请求字符串

token:{string}令牌

isRegisteredUser:{bool,缺省false}是否为认证客户。

server:{string,缺省为SERVER_URL常量} 服务器地址

port:{string,缺省为SERVER_PORT常量}服务器端口

  1. 认证用户的实例化:认证用户拥有request、token以及非认证客户的游戏地址url,使用以下方式实例化Mugeda.Socket

var a = new Mugeda.Socket(request, token, true, url)

  1. 匿名用户的实例化:匿名用户通常来自二维码的扫描,网页地址中包含request和token,可通过以下方式直接从地址中获取

var a = new Mugeda.Socket()

a.getReqestAndTokenFromUrl()

实例化Mugeda.socket对象后,认证用户和匿名用户都使用以下形式的方式连接服务器。

a.connect(function(err){})

在回调函数中,查看err字符串,如果为空,说明连接成功,否则,可能是token不对。

认证用户(即PC端)获取匿名用户(即客户端)队列

认证用户通过a.clients获取匿名用户数组,最早连接的用户在队列前面。数组的每一个元素都为Mugeda.Socket.Client实例。

侦听cliententer和clientleave事件,这两个事件在匿名用户连接和断开时刻发生。

a.addEventListener(‘cliententer’, function(client){

 

})

a.addEventListener(‘clientleave’, function(client){

 

})

认证用户对匿名用户的操作

  1. 发送消息

对Client实例发送消息:

client.send(event, data, callback)

其中:

event{stirng},自定义事件名

data{string、number、object、null}发送的数据,其中number和string在发送前会被转化为{data: string}或{data.number}的形式。

callback{function},对需要匿名用户立即回复的情形,callback函数会传递到匿名客户,由匿名客户直接调用。

对全体Client发送消息

a.sendAll(event, data)

参数含义同上。

  1. 检测Client是否有回应

client.checkAvailable(callback, timeout)

其中:

callback{function}回调

timeout{number,缺省10}超时秒数

检测非认证用户是否有回应,若有,callback回调,回调函数的第一个参数为true;否则,timeout后,callback回调,回调函数的第一个参数为false。

  1. 不断检测Client的存在性

client.checkAvailableContinuously(callback, interval, timeout)

匿名用户将每隔interval秒(缺省5秒)向认证用户发送一个心跳包,当timeout(缺省20秒)后,callback回调且第一个参数为false。

  1. 得到Client实例在a.clients数组中的Index

a.getClientIndexByUserId(client.user)

匿名用户的操作

  1. 发送消息

a.send(event, data, callback)

参数含义同上。

  1. 检测与服务器的连接讯速度

a.benchmark(callback, times, timeout)

匿名用户多次向服务器发送数据,服务器收到后返回数据,测试数据来回所用时间/2。

其中:

callback{function}回调函数,格式为function(averageTime, timeArray),其中timeArray记录了每一次的时间,averageTime为平均时间,单位均为ms。

times{number,缺省为3}测试的次数。

timeout{number,缺省2000}超时的时间,单位ms。

其他事件

  1. 认证何用户消息侦听

a.addEventListener(‘message’, function(client, event, data, callback){

console.log(event, data)

})

侦听匿名用户通过a.send发送的消息。client为发送消息的用户的Client对象,其余参数同上。

  1. 匿名用户消息侦听

a.addEventListener(‘message’, function(event, data, callback){

console.log(event, data)

})

形式与上面类似,但是回调少了client参数。

  1. 匿名用户侦听PC断开事件

a.addEventListener(‘disconnected’, function(){

})

 

1.PC端代码

a.定义SocketComm对象

var mugeda=Mugeda.getMugedaObject();

var scene = null;

var info = null;

var isConnect = false;

var SocketComm = function(){//定义SocketComm对象

this.socket = null;

this.scene = null;

this.connected = null;

this.name = (new Date()).getTime();

var _=this;

this.setup = function(callback, scene){

connect = new Mugeda.Socket(‘dejipuzzle’,’d2f7335a19ecc3ed2a0cbe66580fdd05′, true,

‘https://cn.mugeda.com/client/preview_css3.html?id=d20c8a20’);//通过实例化Mugeda.Socket类,产生连接

this.scene = scene;

connect.connect(function(err){//认证用户(PC端)连接服务器

if(err){

Mugeda.log(err);

}

else{

_.connected = true

callback({

event: ‘connect’

})

}

})

connect.addEventListener(‘authorization’,function(){//认证用户(PC端)侦听authorization事件

var replaceQrcode = function(imgObj, url) {//将动画中的图片对象替换为二维码

var cvs, height, width;

var holder = document.createElement(‘div’);

holder.width = imgObj.width;

holder.height = imgObj.height;

if (url) {

$(holder).empty().qrcode({

text: url,

ecLevel: ‘L’

});

width = imgObj.width;

height = imgObj.height;

$(imgObj.dom).css(‘background-image’, ‘none’);

$(imgObj.dom).css(‘background-color’, ‘white’);

$(imgObj.dom).css(‘padding’, ‘4px’);

cvs = $(holder).find(‘canvas’);

cvs.css(‘margin’, ‘2px’);

cvs.css(‘width’, (width – 4) + ‘px’);

cvs.css(‘height’, (height – 4) + ‘px’);

imgObj.dom.src = cvs[0].toDataURL();

}

};

var qrc = scene.getObjectByName(‘qrc’);//获取舞台中原来的二维码图片对象

replaceQrcode(qrc, this.clientURL);//通过this.clientURL获取非认证用户带request和token的地址,并替换二维码

console.log(this.clientURL);

})

connect.addEventListener(‘cliententer’, function(client){//侦听cliententer在匿名用户连接时触发。

info.text = (“用户接入成功。”);

console.log(client);

})

connect.addEventListener(‘clientleave’, function(client){//侦听clientleave事件,在匿名用户断开时触发。

info.text = (“用户离开。”);

console.log(client);

})

connect.addEventListener(‘disconnect’, function () {//侦听disconnect事件

callback({

‘event’:’disconnect’

});

_.connected = false;

isConnect = false;

});

connect.addEventListener(‘message’, function(client, event, data){

//侦听匿名用户通过a.send发送的消息。并调用在setup的回调函数中处理

callback({

‘event’:event,

‘client’:client,

‘data’:data

});

})

};

}

b.在renderReady监听回调中调用SocketComm实例的setup方法

var cross = new SocketComm();//实例化SocketComm对象

mugeda.addEventListener(“renderReady”, function () {

scene = mugeda.scene;

info = scene.getObjectByName(‘info’);//获取info对象,显示连接状态和移动端发来的消息

 

var processMessage = function(msg){//setup处理消息的回调函数

if(!mugeda || !scene)

return;

msg = msg || {};

if(msg.event == “connect”){

info.text = (“连接成功。等待用户接入。”);

}

else if(msg.event == “disconnect”){

info.text = (“连接断开”);

}

else if(msg.event == “update”){

console.log(msg.data);

}

else if(msg.event == ‘mobilemessage’) {//处理匿名用户(客户端)发来的消息

var data = msg.data;

info.text = data;

}

}

 

cross.setup(processMessage, scene);//调用SocketComm实例的setup方法

});

2.移动端代码

var mugeda=Mugeda.getMugedaObject();

mugeda.addEventListener(“renderReady”, function () {

scene = mugeda.scene;

var hello = scene.getObjectByName(‘hello’);//获取sayHello按钮对象

var ok = scene.getObjectByName(‘ok’);//获取sayOK按钮对象

var connectButton = scene.getObjectByName(‘connect’);//获取connectPC按钮对象

hello.left = -700;//sayHello按钮移到舞台外

ok.left = -700;//sayOK按钮移到舞台外

 

var socket = new Mugeda.Socket();//实例化Mugeda.Socket对象

socket.getReqestAndTokenFromUrl();//获取request和token

 

socket.addEventListener(‘authorization’, function(){//侦听authorization事件

console.log(this.clientURL);

});

socket.addEventListener(‘message’, function(event, data, callback){//侦听PC端通过send发送的消息

console.log(event, data);

processMessage(event,data, callback);

})

socket.addEventListener(‘disconneted’, function(){//匿名用户(移动端)侦听PC断开事件

console.log(‘disconneted’);

error.text = “连接失败,请重新刷二维码”;

scene.gotoAndPause(errorFrame);

})

window.connectPC = function(){//connectPC按钮的回调函数

socket.connect(function(err){//回调中,查看err字符串,为空,说明连接成功。

if(err){

console.log(err);

if(err.indexOf && err.indexOf(‘handshake’)>=0){

console.log(“无效的二维码。请重新刷二维码。”)

}

}

else{

console.log(‘connect OK’);

connectButton.left = -700;//connectPC按钮移到舞台外

hello.left = 76;//sayHello按钮移到舞台内

ok.left = 76;//sayOK按钮移到舞台内

}

});//匿名用户(移动端)连接服务器

};

window.sayHello = function(){//sayHello按钮的回调函数

socket.send(‘mobilemessage’, “Hello,World!”);//向PC端发送消息

};

window.sayOK = function(){//sayOK按钮的回调函数

socket.send(‘mobilemessage’, “I’m OK!”);//向PC端发送消息

};

});

二、运行程序

先运行PC端程序,用移动设备扫描PC端的二维码来运行移动端。

移动端点击connectPC按钮连接服务器。

点击sayHello和sayOK按钮,可以在PC端看到交互结果。

实例预览:

https://cn.mugeda.com/client/preview_css3.html?id=d8297427
总 结,该例子只是用了最简单的示例来演示怎么建立一个最简单(Hello World)的跨屏互动应用。具体到商业级的产品的肯定还需要根据具体的产品需求制作更加丰富的动画内容。后面章节中会有一些案例分析,其中有一篇是是一 款跨屏动画的案例分析。敬请期待后续更多文章推出。感觉好的请帮忙点赞^_^

[转载]HTML5+NodeJs实现WebSocket即时通讯 - W·Axes - 博客园

mikel阅读(885)

来源: [转载]HTML5+NodeJs实现WebSocket即时通讯 – W·Axes – 博客园

声明:本文为原创文章,如需转载,请注明来源WAxes,谢谢!

最近都在学习HTML5,做canvas游戏之类的,发现HTML5中除了 canvas这个强大的工具外,还有WebSocket也很值得注意。可以用来做双屏互动游戏,何为双屏互动游戏?就是通过移动端设备来控制PC端网页游 戏。这样的话就要用到实时通讯了,而WebSocket无疑是最合适的。WebSocket相较于HTTP来说,有很多的优点,主要表现在 WebSocket只建立一个TCP连接,可以主动推送数据到客户端,而且还有更轻量级的协议头,减少数据传送量。所以WebSocket暂时来说是实时 通讯的最佳协议了。

至于服务器语言选择nodeJs,一是因为自己是做前端的,对JavaScript比较熟悉,相比于其他后台语言,自然会更喜欢nodeJs了,二是NodeJs本身事件驱动的方式很擅长与大量客户端保持高并发的连接。所以就选择NodeJs了。

服务器的实现很简单,先装一个nodeJs的模块,叫nodejs- websocket , 直接在nodeJs命令行中敲入:npm install nodejs-websocket回车就可以安装好了,然后就可以开始建立服务器了,因为有了nodejs-websocket模块,所以很多工作都不用 我们自己做,直接调用别人封装好的方法就行了:

【服务端代码】,根据客户端传来的消息判断哪个是game1,哪个是game2,保存connection对象。


var ws = require("nodejs-websocket");
console.log("开始建立连接...")

var game1 = null,game2 = null , game1Ready = false , game2Ready = false;
var server = ws.createServer(function(conn){
conn.on("text", function (str) {
console.log("收到的信息为:"+str)
if(str==="game1"){
game1 = conn;
game1Ready = true;
conn.sendText("success");
}
if(str==="game2"){
game2 = conn;
game2Ready = true;
}

if(game1Ready&amp;&amp;game2Ready){
game2.sendText(str);
}

conn.sendText(str)
})
conn.on("close", function (code, reason) {
console.log("关闭连接")
});
conn.on("error", function (code, reason) {
console.log("异常关闭")
});
}).listen(8001)
console.log("WebSocket建立完毕")

【game1代码】:通过点击获取三个框的内容,传到服务器


&lt;!doctype html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta charset="UTF-8"&gt;
&lt;title&gt;Document&lt;/title&gt;
&lt;style&gt;
.kuang{text-align: center;margin-top:200px;}
#mess{text-align: center}
.value{width: 200px;height:200px;border:1px solid;text-align: center;line-height: 200px;display: inline-block;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="mess"&gt;正在连接...&lt;/div&gt;
&lt;div class="kuang"&gt;
&lt;div class="value" id="value1"&gt;小明小明&lt;/div&gt;
&lt;div class="value" id="value2"&gt;大胸大胸&lt;/div&gt;
&lt;div class="value" id="value3"&gt;小张小张&lt;/div&gt;
&lt;/div&gt;

&lt;script&gt;
var mess = document.getElementById("mess");
if(window.WebSocket){
var ws = new WebSocket('ws://192.168.17.80:8001');

ws.onopen = function(e){
console.log("连接服务器成功");
ws.send("game1");
}
ws.onclose = function(e){
console.log("服务器关闭");
}
ws.onerror = function(){
console.log("连接出错");
}

ws.onmessage = function(e){
mess.innerHTML = "连接成功"
document.querySelector(".kuang").onclick = function(e){
var time = new Date();
ws.send(time + "  game1点击了“" + e.target.innerHTML+"”");
}
}
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

【game2代码】:获取服务推送来的消息,并且显示


&lt;!doctype html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta charset="UTF-8"&gt;
&lt;title&gt;Document&lt;/title&gt;
&lt;style&gt;
.kuang{text-align: center;margin-top:200px;}
#mess{text-align: center}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="mess"&gt;&lt;/div&gt;

&lt;script&gt;
var mess = document.getElementById("mess");
if(window.WebSocket){
var ws = new WebSocket('ws://192.168.17.80:8001');

ws.onopen = function(e){
console.log("连接服务器成功");
ws.send("game2");
}
ws.onclose = function(e){
console.log("服务器关闭");
}
ws.onerror = function(){
console.log("连接出错");
}

ws.onmessage = function(e){
var time = new Date();
mess.innerHTML+=time+"的消息:"+e.data+"&lt;br&gt;"
}
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

运行截图:

 

代码非常简单:很容易看懂,nodejs-WebSocket的调用也非常简洁明了,具体nodejs-websocket的API可以看https://www.npmjs.org/package/nodejs-websocket,里面都有介绍,自己测试一下,就很容易了,客户端的实现也是很简单,就通过onopen,onmessage等几个方法就可以实现了。

Android 自动获取经纬度,计算距离、经纬度、方位角

mikel阅读(711)

这种公式我必然是不知道的,谷歌翻了翻,有人(http://xxyyyboy.blog.163.com/blog/static/765832620110410457662/)说是
1.Lat1 Lung1 表示A点经纬度,Lat2 Lung2 表示B点经纬度;
2.a=Lat1 – Lat2 为两点纬度之差 b=Lung1 -Lung2 为两点经度之差;
3.6378.137为地球半径,单位为千米;
计算出来的结果单位为千米。
也有人http://panyee.cnblogs.com/archive/2006/07/04/442771.html)说直接从google maps的脚本里扒了段代码,maps的代码:计算的结果是米为单位。
    // 计算两点距离
    privatefinaldoubleEARTH_RADIUS = 6378137.0;
privatedouble gps2m(double lat_a, double lng_a, double lat_b, double lng_b) {
       double radLat1 = (lat_a * Math.PI / 180.0);
       double radLat2 = (lat_b * Math.PI / 180.0);
       double a = radLat1 – radLat2;
       double b = (lng_a – lng_b) * Math.PI / 180.0;
       double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
              + Math.cos(radLat1) * Math.cos(radLat2)
              * Math.pow(Math.sin(b / 2), 2)));
       s = s * EARTH_RADIUS;
       s = Math.Round(s * 10000) / 10000;
       return s;
    }
两点经纬度,计算方位角
计算方位角pab,
其中lat_a, lng_a是A的纬度和经度; lat_b, lng_b是B的纬度和经度。代码如下:
    // 计算方位角pab。
    privatedouble gps2d(double lat_a, double lng_a, double lat_b, double lng_b) {
       double d = 0;
       lat_a=lat_a*Math.PI/180;
       lng_a=lng_a*Math.PI/180;
       lat_b=lat_b*Math.PI/180;
       lng_b=lng_b*Math.PI/180;
        d=Math.sin(lat_a)*Math.sin(lat_b)+Math.cos(lat_a)*Math.cos(lat_b)*Math.cos(lng_b-lng_a);
       d=Math.sqrt(1-d*d);
       d=Math.cos(lat_b)*Math.sin(lng_b-lng_a)/d;
       d=Math.asin(d)*180/Math.PI;
//     d = Math.round(d*10000);
       return d
}

获取Android设备的方向

mikel阅读(787)

带有g-sensor的Android设备上可通过API获取到设备的运动加速度,应用程序通过一些假设和运算,可以从加速度计算出设备的方向

获取设备运动加速度的基本代码是:


SensorManager sm = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
sm.registerListener(new SensorEventListener() {

public void onSensorChanged(SensorEvent event) {
if (Sensor.TYPE_ACCELEROMETER != event.sensor.getType()) {
return;
}

float[] values = event.values;
float ax = values[0];
float ay = values[1];
float az = values[2];

// TODO Have fun with the acceleration components...

}

public void onAccuracyChanged(Sensor sensor, int accuracy) {

}
}, sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);

SendorEventListener 通过 SendorEvent 回调参数获得当前设备在坐标系x、y、z轴上的加速度分量。SensorEvent 的 api doc 中定义了这里使用的坐标系为:

我暂且称之为“设备坐标系”吧,设备坐标系是固定于设备的,与设备的方向(在世界坐标系中的朝向)无关

精确地说,Sensor Event 所提供的加速度数值,是设备以地球为参照物的加速度减去重力加速度的叠加后的值。我是这样理解的:当以重力加速度g向地面作自由落体运动时,手机处于失重 状态,g-sensor以这种状态作为加速度的0;而当手机处于静止状态(相对于地面)时,为了抵御自由落体运动的趋势,它有一个反向(向上)的g的加速 度。因此,得出一个结论:当设备处于静止或者匀速运动状态时,它有一个垂直地面向上的g的加速度,这个g投影到设备坐标系的x、y、z轴上,就是SensorEvent 提供给我们的3个分量的数值。在“设备处于静止或者匀速运动状态”的假设的前提下,可以根据SensorEvent所提供的3个加速度分量计算出设备相对于地面的方向

前面所提到的“设备的方向”是一个含糊的说法。这里我们精确地描述设备方向为:以垂直于地面的方向为正方向,用设备坐标系x、y、z轴与正方向轴之 间的夹角Ax、Ay、Az来描述设备的方向,如下图所示。可以看出,设备还有一个自由度,即:绕着正方向轴旋转,Ax、Ay、Az不变。但Ax、Ay、 Az的约束条件,对于描述设备相对于正方向轴的相对位置已经足够了。如果需要完全约束设备相对于地面的位置,除了正方向轴外,还需要引入另一个参照轴,例 如连接地球南、北极的地轴(如果设备上有地磁强度Sensor,则可满足该约束条件)

Ax、Ay、Az的范围为[0, 2*PI)。例如,当Ay=0时,手机y轴竖直向上;Ay=PI时,手机y轴向下;Ay=PI/2时,手机水平、屏幕向上;Ay=3*PI/2时,手机水平、屏幕向下

根据3D矢量代数的法则,可知:

  • Gx=g*cos(Ax)
  • Gy=g*cos(Ay)
  • Gz=g*cos(Az)
  • g^2=Gz^2+Gy^2+Gz^2

因此,根据Gx、Gy、Gz,可以计算出Ax、Ay、Az

在x-y平面上的2D简化

当Ax、Ay确定时,Az有两种可能的值,二者相差PI,确定了设备屏幕的朝向是向上还是向下。大多数情况下,我们只关心Ax、Ay(因为程序UI 位于x-y平面?),而忽略Az,例如,Android的屏幕自动旋转功能,不管使用者是低着头看屏幕(屏幕朝上)、还是躺在床上看(屏幕朝下),UI始 终是底边最接近地心的方向

那么我们设Gx与Gy的矢量和为g’(即:g在x-y平面上的投影),将计算简化到x-y 2D平面上。记y轴相对于g’的偏角为A,以A来描述设备的方向。以逆时针方向为正,A的范围为[0, 2*PI)

有:

  • g’^2=Gx^2+Gy^2
  • Gy=g’*cos(A)
  • Gx=g’*sin(A)

则:

  • g’=sqrt(Gx^2+Gy^2)
  • A=arccos(Gy/g’)

由于arccos函数值范围为[0, PI];而A>PI时,Gx=g’*sin(A)<0,因此,根据Gx的符号分别求A的值为:

  • 当Gx>=0时,A=arccos(Gy/g’)
  • 当Gx<0时,A=2*PI-arccos(Gy/g’)

注意:由于cos函数曲线关于直线x=n*PI 对称,因此arccos函数的曲线如果在y轴方向[0, 2*PI]范围内补全的话,则关于直线y=PI对称,因此有上面当Gx<0时的算法

考虑应用程序的屏幕旋转

前面计算出了Android设备的“物理屏幕”相对于地面的旋转角度,而应用程序的UI又相对于“物理屏幕”存在0、90、180、270度4种可能的旋转角度,要综合考虑进来。也就是说:

  • UI相对于地面的旋转角度=物理屏幕相对于地面的旋转角度-UI相对于物理屏幕的旋转角度

Android应用获取屏幕旋转角度的方法为:

<pre>        int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
        int degree= 90 * rotation;
        float rad = (float)Math.PI / 2 * rotation;

Demo

根据上面的算法,我写了一个“不倒翁”的Demo,当设备旋转时,不倒翁始终是站立的。软件市场上不少“水平尺”一类的应用,其实现原理应该是与此相同的

下载Demo源代码

Activity实现了SensorEventListener,并且注册到SensorManager。同时设置屏幕方向固定为LANDSCAPE:


private GSensitiveView gsView;
private SensorManager sm;

@Override
public void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
super.onCreate(savedInstanceState);

gsView = new GSensitiveView(this);
setContentView(gsView);

sm = (SensorManager) getSystemService(SENSOR_SERVICE);
sm.registerListener(this, sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
}

@Override
protected void onDestroy() {
sm.unregisterListener(this);
super.onDestroy();
}

当g-sensor数据变化时的回调如下。这里就是根据我们前面推论的算法计算出UI旋转的角度,并且调用GSensitiveView.setRotation()方法通知View更新


public void onSensorChanged(SensorEvent event) {
if (Sensor.TYPE_ACCELEROMETER != event.sensor.getType()) {
return;
}

float[] values = event.values;
float ax = values[0];
float ay = values[1];

double g = Math.sqrt(ax * ax + ay * ay);
double cos = ay / g;
if (cos &gt; 1) {
cos = 1;
} else if (cos &lt; -1) {
cos = -1;
}
double rad = Math.acos(cos);
if (ax &lt; 0) {
rad = 2 * Math.PI - rad;
}

int uiRot = getWindowManager().getDefaultDisplay().getRotation();
double uiRad = Math.PI / 2 * uiRot;
rad -= uiRad;

gsView.setRotation(rad);
}

GSensitiveView是扩展ImageView的自定义类,主要是根据旋转角度绘制图片:


private static class GSensitiveView extends ImageView {

private Bitmap image;
private double rotation;
private Paint paint;

public GSensitiveView(Context context) {
super(context);
BitmapDrawable drawble = (BitmapDrawable) context.getResources().getDrawable(R.drawable.budaow);
image = drawble.getBitmap();

paint = new Paint();
}

@Override
protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);

double w = image.getWidth();
double h = image.getHeight();

Rect rect = new Rect();
getDrawingRect(rect);

int degrees = (int) (180 * rotation / Math.PI);
canvas.rotate(degrees, rect.width() / 2, rect.height() / 2);
canvas.drawBitmap(image, //
(float) ((rect.width() - w) / 2),//
(float) ((rect.height() - h) / 2),//
paint);
}

public void setRotation(double rad) {
rotation = rad;
invalidate();
}

}

 

[转载]阮一峰:理解矩阵乘法_IT新闻_博客园

mikel阅读(988)

来源: [转载]阮一峰:理解矩阵乘法_IT新闻_博客园

作者: 阮一峰

大多数人在高中,或者大学低年级,都上过一门课《线性代数》。这门课其实是教矩阵。

刚学的时候,还蛮简单的,矩阵加法就是相同位置的数字加一下。

矩阵减法也类似。

矩阵乘以一个常数,就是所有位置都乘以这个数。

但是,等到矩阵乘以矩阵的时候,一切就不一样了。

这个结果是怎么算出来的?

教科书告诉你,计算规则是,第一个矩阵第一行的每个数字(2 和1),各自乘以第二个矩阵第一列对应位置的数字(1 和1),然后将乘积相加( 2 x 1 + 1 x 1),得到结果矩阵左上角的那个值3。

也就是说,结果矩阵第m行与第n列交叉位置的那个值,等于第一个矩阵第m行与第二个矩阵第n列,对应位置的每个值的乘积之和。

怎么会有这么奇怪的规则?

我一直没理解这个规则的含义,导致《线性代数》这门课就没学懂。研究生时发现,线性代数是向量计算的基础,很多重要的数学模型都要用到向量计算,所以我做不了复杂模型。这一直让我有点伤心。

前些日子,受到一篇文章的启发,我终于想通了,矩阵乘法到底是什么东西。关键就是一句话,矩阵的本质就是线性方程式,两者是一一对应关系。如果从线性方程式的角度,理解矩阵乘法就毫无难度。

下面是一组线性方程式。

矩阵的最初目的,只是为线性方程组提供一个简写形式。

老实说,从上面这种写法,已经能看出矩阵乘法的规则了:系数矩阵第一行的 2 和1,各自与 x 和 y 的乘积之和,等于3。不过,这不算严格的证明,只是线性方程式转为矩阵的书写规则。

下面才是严格的证明。有三组未知数 x、y 和 t,其中 x 和 y 的关系如下。

x 和 t 的关系如下。

有了这两组方程式,就可以求 y 和 t 的关系。从矩阵来看,很显然,只要把第二个矩阵代入第一个矩阵即可。

从方程式来看,也可以把第二个方程组代入第一个方程组。

上面的方程组可以整理成下面的形式。

最后那个矩阵等式,与前面的矩阵等式一对照,就会得到下面的关系。

矩阵乘法的计算规则,从而得到证明。

Android GPS两点间距离

mikel阅读(1004)

Android中可采用如下代码获取距离:

Java代码
public double getDistance(double lat1, double lon1, double lat2, double lon2) {
float[] results=new float[1];
Location.distanceBetween(lat1, lon1, lat2, lon2, results);
return results[0];
}
在其他设备若没有类似Android的Location的distanceBetween方法开采用如下代码获取:

Java代码
double distance(double lat1, double lon1, double lat2, double lon2) {
double theta = lon1 – lon2;
double dist = Math.sin(deg2rad(lat1)) * Math.sin(deg2rad(lat2))
+ Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2))
* Math.cos(deg2rad(theta));
dist = Math.acos(dist);
dist = rad2deg(dist);
double miles = dist * 60 * 1.1515;
return miles;
}
//将角度转换为弧度
static double deg2rad(double degree) {
return degree / 180 * Math.PI;
}
//将弧度转换为角度
static double rad2deg(double radian) {
return radian * 180 / Math.PI;
}
这个计算得出的结果是英里,如果要转换成公里,需要乘以1.609344,若是海里需要乘以0.8684

从此学习网 http://www.congci.com/item/android-gps-distance

关于java、Android中Math的一些用法

mikel阅读(854)

java.math.Math类常用的常量和方法:

Math.PI 记录的圆周率
Math.E记录e的常量
Math.abs 求绝对值
Math.sin 正弦函数 Math.asin 反正弦函数
Math.cos 余弦函数 Math.acos 反余弦函数
Math.tan 正切函数 Math.atan 反正切函数&nbsp;Math.atan2 商的反正切函数
Math.toDegrees 弧度转化为角度 Math.toRadians 角度转化为弧度
Math.ceil 得到不小于某数的最大整数
Math.floor 得到不大于某数的最大整数

例如:Math.floor(12.7) =12.0

Math.ceil(12.7) =13.0

ceil()是天花板,即向上取整。floor是地板,向下取整。round是四舍五入。

 

Math.IEEEremainder 求余
Math.max 求两数中最大
Math.min 求两数中最小
Math.sqrt 求开方
Math.pow 求某数的任意次方, 抛出ArithmeticException处理溢出异常

Math.sqrt(x):平方根
Math.pow(x,y):x的y次方

Math.exp 求e的任意次方
Math.log10 以10为底的对数
Math.log 自然对数
Math.rint 求距离某数最近的整数(可能比某数大,也可能比它小)
Math.round 同上,返回int型或者long型(上一个函数返回double型)
Math.random 返回0,1之间的一个随机数

java.math.BigInteger(大整数):
BigInteger bi1=new BigInteger(“1234567890123456890”);
BigInteger bi2=BigInteger.valueOf(123L);
bi1=bi1.add(bi2);//b1+b2
bi1=bi1.multiply(bi2);//b1*b2
bi1=bi1.subtract(bi2);//b1-b2
bi1=bi1.divide(bi2);// b1/b2

java.math.BigDecimal(大浮点数):
BigDecimal bd = new BigDecimal(“3.1415926”);
bd = bd.setScale(2,BigDecimal.ROUND_DOWN);//取3.1415926小数点后面二位