鍍金池/ 教程/ Android/ Android項(xiàng)目架構(gòu)
Launch mode 和 Intent flags專題
Canvas & Drawables
UTAustinX_UT.9.01x: Effective Thinking Through Mathematics
《JavaScript 語(yǔ)言精粹》
Memory leak專題
React基礎(chǔ)
《Test Driven Development: By Example》一書(shū)
Developer tools
安卓開(kāi)發(fā)技能樹(shù)
<a rel="nofollow" href="https://mp.weixin.qq.com/s?__biz=MzA3NDM
Best Practices for Interaction and Engagement
各個(gè)安卓版本引入的主要新特性
Building Apps with Connectivity &amp; the Cloud
List.toArray()再?gòu)?qiáng)轉(zhuǎn)是一定會(huì)失敗的
深入Android frameworks
Google dev 100 days系列視頻
Building Apps with Contacts &amp; Sign-In
關(guān)系型數(shù)據(jù)庫(kù)設(shè)計(jì)范式
《App研發(fā)錄》一書(shū)
REST API設(shè)計(jì)
Google IO 2015摘要
自定義View/ViewGroup以及高性能實(shí)現(xiàn)自定義UI
安卓系統(tǒng)點(diǎn)擊事件處理
《50 Android Hacks》一書(shū)
Building Apps with Content Sharing
Flux基礎(chǔ)
<a rel="nofollow" href="http://developer.android.com/training/in
依賴注入(以Dagger 2為例)
Java同步機(jī)制
Java對(duì)象內(nèi)存的使用情況
JSR133(Java memory model)
Google官方Material Design手冊(cè)(<a rel="nofollow" href="http://develop
Futurice公司安卓團(tuán)隊(duì)的建議
安卓性能優(yōu)化
  • 1.
Best Practices for Performance
<a rel="nofollow" href="http://www.vogella.com/tutorials/Android
<a rel="nofollow" href="http://blog.danlew.net/2014/11/19/styles
Handling Runtime Changes
<a rel="nofollow" href="http://www.vogella.com/tutorials/Android
Building Apps with Graphics &amp; Animation
<a rel="nofollow" href="http://tools.android.com/tech-docs/new-b
Android項(xiàng)目架構(gòu)
MVP(Model-View-Presenter)模式
<a rel="nofollow" href="http://www.infoq.com/cn/es6-in-depth/"">
《Android源碼設(shè)計(jì)模式解析與實(shí)戰(zhàn)》一書(shū)
Rx在Android中的最佳實(shí)踐
函數(shù)調(diào)用時(shí),傳遞參數(shù)應(yīng)該是不可變的(Immutable)
ProGuard
面向?qū)ο罅笤瓌t(SOLID+)
深入理解Java虛擬機(jī)
深入Java深淺拷貝、immutable、unmodifiable
Best Practices for User Input
UI上的一些高效方式/最佳實(shí)踐
<a rel="nofollow" href="https://blog.stylingandroid.com/ripples-
Best Practices for User Interface
安卓測(cè)試驅(qū)動(dòng)開(kāi)發(fā)/安卓測(cè)試驗(yàn)證
暗時(shí)間:學(xué)會(huì)正確思考
技術(shù)筆記
Aspect Oriented Programming(AOP)
Best Practices for Background Jobs
安卓系統(tǒng)動(dòng)效專題
Feed系統(tǒng)的設(shè)計(jì)
Data binding(MVVM,Model-View-ViewModel)
Effective Java一書(shū)筆記
<a rel="nofollow" href="http://developer.android.com/training/in
Rx (Reactive eXtention)
MultiDex專題
一些很棒的點(diǎn)子
WebRTC

Android項(xiàng)目架構(gòu)

從功能需求、設(shè)計(jì)模式、最佳實(shí)踐出發(fā)考慮

MVP模式

數(shù)據(jù)、顯示、控制解耦,mosby,作者blog1blog2

依賴注入

數(shù)據(jù)存儲(chǔ)

  • squidb,基于注解,編譯期生成DAO類,model類是編譯期生成的,而不是定義表結(jié)構(gòu)的類,對(duì)復(fù)雜SQL語(yǔ)句的支持非常好
  • DBFlow,基于注解,編譯期生成DAO類,對(duì)關(guān)系的支持很好
  • ActiveAndroid,基于注解,運(yùn)行時(shí)轉(zhuǎn)換
  • greenDAO,編譯期生成輔助代碼
  • StorIO,與rx集成,響應(yīng)式DBHelper框架

網(wǎng)絡(luò)連接處理

  • Retrofit,使用動(dòng)態(tài)代理將java接口轉(zhuǎn)化為REST API
  • OkHttp,優(yōu)化的HTTP client(共享連接,連接池,透明壓縮,緩存,重試等),支持web socket協(xié)議

異步處理

  • 響應(yīng)式編程(rx,在java7中使用lambda語(yǔ)法:retrolambda),消息的發(fā)出者和響應(yīng)的接收者在同一模塊內(nèi),局部性、單對(duì)單
  • 事件處理(EventBus,Otto),全局性事件、一對(duì)多比較合適

測(cè)試

持續(xù)集成

  • jenkins-ci,整合代碼托管工具,commit、merge request自動(dòng)觸發(fā)構(gòu)建

工具

  • 圖片加載
    • Fresco,多來(lái)源加載、緩存、內(nèi)存管理(存放在安卓非堆特殊內(nèi)存區(qū)域)、支持多種格式、多種功能(圓角)
    • Glide,多來(lái)源加載、緩存、Object pool內(nèi)存優(yōu)化、Context生命周期加載優(yōu)化、ListView、RecyclerView等加載優(yōu)化
    • Picasso,使用堆內(nèi)存,格式稍少
  • 模塊熱加載
    • dynamic-load-apk,通過(guò)代理實(shí)現(xiàn)啟動(dòng)、顯示、執(zhí)行安裝時(shí)未定義的Activity,Service,實(shí)現(xiàn)模塊熱加載
  • 錯(cuò)誤統(tǒng)計(jì)
    • fabric,提供crash統(tǒng)計(jì)、以及twitter集成
  • 調(diào)試
    • XLog,函數(shù)調(diào)用追蹤,log出參數(shù)、返回值、線程、執(zhí)行時(shí)間,支持方法、類的注解;
    • Fresco,chrome查看log,view heriachy,shared pref,db等;
    • LeakCanary,memory leak檢測(cè)工具;
  • 時(shí)間
    • ThreeTenBP,JSR310的java 8以前的兼容實(shí)現(xiàn),比安卓的Date類等強(qiáng)大無(wú)數(shù)倍;
    • ThreeTenABP,安卓的一個(gè)包裝,init過(guò)程性能更好;
  • 導(dǎo)航
    • FragmentArgs,F(xiàn)ragment啟動(dòng)時(shí)通過(guò)Argument傳遞參數(shù)
    • Dart,Activity之間通過(guò)Intent傳遞Extra參數(shù)
    • Pocket Knife,Activity的Extra傳遞參數(shù),SavedInstance做狀態(tài)保存/恢復(fù)
    • Aftermath,A simple, annotation-based Android library for generating onActivityForResult handlers.
  • 動(dòng)效
    • rebound,通過(guò)Android系統(tǒng)的property transition,加上各種變換函數(shù),實(shí)現(xiàn)模擬物理的動(dòng)效;
  • 設(shè)計(jì)

Develop maintainable apps

  • Libraries
    選擇第三方庫(kù)時(shí)的考慮
    • Documentation: 文檔是否全面
    • Repository Check-ins(Stability): 穩(wěn)定性、是否保持維護(hù)
    • Fulfils a Need: 滿足項(xiàng)目需求
  • Domain design
    • Keep code simple: OO,一個(gè)類只負(fù)責(zé)一件事
    • Use MVC/MVP/MVVM Pattern
    • Functional Test
    • Use the tools: IDE的重構(gòu)工具很強(qiáng)大
  • Code quality
    • Readability matters
    • 工具
      • CheckStyle
      • Lint
      • Findbugs
      • PMD
    • Refactor Gradually
  • Testing
    • Unit test: Every single line of code that you write should be tested. Peroid. -- Robert Martin
    • Junit(...) + Mockito
    • Continuous Integration
    • Code coverage

Android Clean Architecture

分層結(jié)構(gòu)

http://wiki.jikexueyuan.com/project/notes/images/clean_architecture1.png" alt="clean_architecture1.png" />

  • Entities: These are the business objects of the application.
  • Use Cases: These use cases orchestrate the flow of data to and from the entities. Are also called Interactors.
  • Interface Adapters: This set of adapters convert data from the format most convenient for the use cases and entities. Presenters and Controllers belong here.
  • Frameworks and Drivers: This is where all the details go: UI, tools, frameworks, etc.
  • Dependency Rule: source code dependencies can only point inwards and nothing in an inner circle can know anything at all about something in an outer circle.

安卓項(xiàng)目層次結(jié)構(gòu)示例

http://wiki.jikexueyuan.com/project/notes/images/clean_architecture_android.png" alt="clean_architecture_android.png" />

使用Rx后的層次結(jié)構(gòu)示例

http://wiki.jikexueyuan.com/project/notes/images/clean_architecture_evolution.png" alt="clean_architecture_evolution.png" />

  • Presentation layer: UI tests with Espresso 2 and Android Instrumentation.
  • Presenter && View test: 針對(duì)接口進(jìn)行單元測(cè)試;對(duì)UI簡(jiǎn)單交互結(jié)果邏輯的測(cè)試(如:Activity跳轉(zhuǎn),F(xiàn)ragment切換,相關(guān)接口調(diào)用);
  • Domain layer: JUnit + Mockito since it is a regular Java module.
  • Data layer: Migrated test battery to use Robolectric 3 + JUnit + Mockito.

代碼組織(包組織)

  • Package by layer
  • Package by feature
    • Higher Modularity
    • Easier Code Navigation
    • Minimizes Scope

Flux Architecture

  • 結(jié)構(gòu)圖
    http://wiki.jikexueyuan.com/project/notes/images/flux-graph-simple.png" alt="flux-graph-simple.png" />
    • View: Application interface. It create actions in response to user interactions. Activity or Fragment
    • Dispatcher: Central hub through which pass all actions and whose responsibility is to make them arrive to every Store. An event bus.
    • Store: Maintain the state for a particular application domain. They respond to actions according to current state, execute business logic and emit a change event when they are done. This event is used by the view to update its interface. Simple POJOs with two main attributes: Type: a String identifying the type of event; Data: a Map with the payload for this action.
    • More about Stores
      • Stores contain the status of the application and its business logic.
      • Stores react to Actions emitted by the Dispatcher, execute business logic and emit a change event as result.
      • ...

RxFlux

http://wiki.jikexueyuan.com/project/notes/images/rxflux_arch.png" alt="rxflux_arch.png" />

What is all this Clean Architecture jibber-jabber about?

基礎(chǔ)

  • SOLID
    • Single Responsiblity
    • Open/Closed
    • Liskov Substitution
    • Interface Segregation
    • Dependency Inversion
  • Abstraction
    • 面向接口編程
    • 高內(nèi)聚,低耦合
      • 內(nèi)聚:?jiǎn)我荒K內(nèi),各個(gè)部分之間的關(guān)系
      • 耦合:各個(gè)模塊之間的關(guān)系
  • Vertical slicing
    • Horizontal slicing:傳統(tǒng)方式,從服務(wù)提供方分包,例如DB, Network, ui...
    • Vertical slicing:源自敏捷,根據(jù)功能(use case)進(jìn)行分包,而將與該功能相關(guān)的db, network, ui等部分放到同一個(gè)模塊中