一個App架構例子分析--使用MVP模式;使用Otto實現模組通訊

來源:互聯網
上載者:User

標籤:

一、這個App整體的架構劃分:

 

分為四大模組: 1.app模組2.common模組3.domain模組4.model模組  app模組的依賴:dependencies {
    compile fileTree(dir: ‘libs‘, include: [‘*.jar‘])
    compile project(‘:domain‘)...}它依賴domain,領域層模組。在app模組中,應用了MVP模式,把一個activity中的View和Presenter劃分掉。 domain模組的依賴:dependencies {
    compile project (‘:common‘)
    compile project (‘:model‘)...}它依賴model模組。領域邏輯代碼放在這個模組;需要擷取資料,擷取資料的實現代碼則放在module模組;它依賴common,通用的功能,整個應用共用的代碼,放在common模組中。  model模組的依賴:dependencies {
    compile project(‘:common‘)....}這個模組只依賴common模組。model模組提供資料擷取,修改功能。 common模組的依賴:dependencies {
    compile ‘com.squareup:otto:1.3.5‘
    compile ‘com.google.dagger:dagger:2.0‘
    compile ‘org.glassfish:javax.annotation:10.0-b28‘
}它不依賴domain,app,model模組。它使用第三方類庫,來給其它模組提供功能。使用Dagger依賴注入架構,進行依賴注入;使用otto類庫,來實現匯流排方式的通訊。 二、整個執行流程簡要分析 app模組:MoviesActivity,MoviesPresenter。 domain模組:ConfigurationUsecase, GetMoviesUsecaseController。 module模組:RestMovieSource。 模組之間的通訊,協作使用Bus匯流排來實現。比如,module模組,接受了資料查詢的請求,查詢完畢之後,它就通過匯流排post出去;然後,app模組或者domain模組,使用匯流排訂閱了某個事件,那麼訂閱該事件的方法就會被回調。  三、依賴注入架構,注入流程     

一個App架構例子分析--使用MVP模式;使用Otto實現模組通訊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.