├── .gitignore ├── .idea ├── compiler.xml ├── jarRepositories.xml └── misc.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── modularization │ │ └── app │ │ ├── ModularizationApp.java │ │ └── SplashActivity.java │ └── res │ ├── layout │ └── activity_splash.xml │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-v19 │ └── styles.xml │ ├── values-v21 │ └── styles.xml │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── biz-module-main ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── modularization │ │ └── biz │ │ └── module │ │ └── main │ │ ├── Constants.java │ │ ├── MainActivity.java │ │ └── http │ │ ├── ApiService.java │ │ └── ApiServiceWrap.java │ └── res │ ├── layout │ └── activity_main.xml │ └── values │ ├── dimens.xml │ └── strings.xml ├── biz-module-newhouse ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── debug │ └── AndroidManifest.xml │ ├── java │ └── com │ │ └── modularization │ │ └── biz │ │ └── module │ │ └── newhouse │ │ ├── Constants.java │ │ ├── MainActivity.java │ │ ├── NewHouseProviderImpl.java │ │ ├── http │ │ ├── ApiService.java │ │ └── ApiServiceWrap.java │ │ └── model │ │ └── GitHubUser.java │ ├── release │ └── AndroidManifest.xml │ └── res │ ├── layout │ └── new_house_activity_main.xml │ ├── mipmap-xxhdpi │ └── new_house_ic_launcher.png │ ├── mipmap-xxxhdpi │ └── new_house_ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── biz-module-renthouse ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── debug │ └── AndroidManifest.xml │ ├── java │ └── com │ │ └── modularization │ │ └── biz │ │ └── module │ │ └── renthouse │ │ ├── Constants.java │ │ ├── MainActivity.java │ │ ├── RentHouseProviderImpl.java │ │ └── http │ │ ├── ApiService.java │ │ └── ApiServiceWrap.java │ ├── release │ └── AndroidManifest.xml │ └── res │ ├── layout │ └── rent_house_activity_main.xml │ ├── mipmap-xxhdpi │ └── rent_house_ic_launcher.png │ ├── mipmap-xxxhdpi │ └── rent_house_ic_launcher.png │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── biz-module-secondhouse ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── debug │ └── AndroidManifest.xml │ ├── java │ └── com │ │ └── modularization │ │ └── biz │ │ └── module │ │ └── secondhouse │ │ ├── BlankFragment.java │ │ ├── Constants.java │ │ ├── MainActivity.java │ │ ├── SecondHouseProviderImpl.java │ │ └── http │ │ ├── ApiService.java │ │ └── ApiServiceWrap.java │ ├── release │ └── AndroidManifest.xml │ └── res │ ├── layout │ ├── fragment_blank.xml │ └── second_house_activity_main.xml │ ├── mipmap-xxhdpi │ └── second_house_ic_launcher.png │ ├── mipmap-xxxhdpi │ └── second_house_ic_launcher.png │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── biz-service-base ├── .gitignore ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── modularization │ └── biz │ └── service │ └── base │ ├── ErrorMessage.java │ └── ResponseCallback.java ├── biz-service-newhouse ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── modularization │ └── biz │ └── service │ └── newhouse │ ├── NewHouseApiData.java │ ├── NewHouseData.java │ ├── NewHouseProvider.java │ ├── NewHouseProviderHelper.java │ └── NewHouseRouterTable.java ├── biz-service-renthouse ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── modularization │ └── biz │ └── service │ └── renthouse │ ├── RentHouseData.java │ ├── RentHouseProvider.java │ ├── RentHouseProviderHelper.java │ └── RentHouseRouterTable.java ├── biz-service-secondhouse ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── modularization │ └── biz │ └── service │ └── secondhouse │ ├── SecondHouseData.java │ ├── SecondHouseProvider.java │ ├── SecondHouseProviderHelper.java │ └── SecondHouseRouterTable.java ├── build.gradle ├── dependencies.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lib-common ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── modularization │ │ └── common │ │ ├── base │ │ ├── activity │ │ │ └── BaseActivity.java │ │ ├── adapter │ │ │ └── BaseRecyclerViewAdapter.java │ │ ├── fragment │ │ │ └── BaseFragment.java │ │ ├── presenter │ │ │ └── BasePresenter.java │ │ ├── util │ │ │ ├── ActivityUtils.java │ │ │ ├── DateConvertUtils.java │ │ │ ├── NetworkUtils.java │ │ │ └── lifecycle │ │ │ │ ├── ActivityLifecycleEvent.java │ │ │ │ └── FragmentLifecycleEvent.java │ │ └── view │ │ │ └── BaseView.java │ │ └── model │ │ └── HouseDetail.java │ └── res │ ├── layout │ └── layout_app_bar.xml │ └── values │ ├── strings.xml │ └── styles.xml ├── lib-data-local ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── modularization │ │ └── data │ │ └── local │ │ ├── db │ │ ├── BaseDatabaseHelper.java │ │ └── UserDatabaseHelper.java │ │ ├── entities │ │ └── User.java │ │ └── preferences │ │ ├── AppSettings.java │ │ ├── ConfigurationListener.java │ │ └── Preferences.java │ └── res │ └── values │ └── strings.xml ├── lib-data-net ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── modularization │ └── data │ └── net │ ├── ApiClient.java │ ├── ApiConstants.java │ ├── SignInterceptor.java │ ├── configuration │ └── ApiConfiguration.java │ ├── converter │ ├── FastJsonConverterFactory.java │ ├── FastJsonRequestBodyConverter.java │ └── FastJsonResponseBodyConvert.java │ └── service │ └── ServiceWrap.java ├── lib-open-source ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── res │ └── values │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.aar 4 | *.ap_ 5 | *.aab 6 | 7 | # Files for the ART/Dalvik VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # Generated files 14 | bin/ 15 | gen/ 16 | out/ 17 | # Uncomment the following line in case you need and you don't have the release build type files in your app 18 | # release/ 19 | 20 | # Gradle files 21 | .gradle/ 22 | build/ 23 | 24 | # Local configuration file (sdk path, etc) 25 | local.properties 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Log Files 31 | *.log 32 | 33 | # Android Studio Navigation editor temp files 34 | .navigation/ 35 | 36 | # Android Studio captures folder 37 | captures/ 38 | 39 | # IntelliJ 40 | *.iml 41 | .idea/ 42 | 43 | # Keystore files 44 | # Uncomment the following lines if you do not want to check your keystore files in. 45 | #*.jks 46 | #*.keystore 47 | 48 | # External native build folder generated in Android Studio 2.2 and later 49 | .externalNativeBuild 50 | .cxx/ 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | # google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | 60 | # fastlane 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | fastlane/readme.md 66 | 67 | # Version control 68 | vcs.xml 69 | 70 | # lint 71 | lint/intermediates/ 72 | lint/generated/ 73 | lint/outputs/ 74 | lint/tmp/ 75 | # lint/reports/ 76 | 77 | # Android Profiling 78 | *.hprof -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Modularization Project 2 | 3 | > Android 模块化示例项目 4 | 5 | ## 模块化项目设计方案 6 | 7 | 推荐阅读: 8 | 9 | * [安居客 Android 项目架构演进](https://mp.weixin.qq.com/s?__biz=MzU4ODM2MjczNA==&mid=2247483731&idx=1&sn=76bd5612ba723171b6ebac69aaf039f8&chksm=fddca7d2caab2ec4eec8736cf4005615c401984e2218a0cfc71dddfe3a204495c4e8a7312b4a&scene=38#wechat_redirect) 10 | * [Android 模块化探索与实践](https://mp.weixin.qq.com/s?__biz=MzU4ODM2MjczNA==&mid=2247483732&idx=1&sn=b7ee1151b2c8ad2e997b8db39adf3267&chksm=fddca7d5caab2ec33905cc3350f31c0c98794774b0d04a01845565e3989b1f20205c7f432cb9&scene=38#wechat_redirect) 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.alibaba.arouter' 3 | 4 | android { 5 | compileSdkVersion 29 6 | buildToolsVersion '29.0.3' 7 | defaultConfig { 8 | applicationId "com.modularization.app" 9 | minSdkVersion 19 10 | targetSdkVersion 29 11 | versionCode 1 12 | versionName "1.0" 13 | multiDexEnabled true 14 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 15 | 16 | javaCompileOptions { 17 | annotationProcessorOptions { 18 | arguments = [AROUTER_MODULE_NAME: project.getName()] 19 | } 20 | } 21 | } 22 | 23 | buildTypes { 24 | release { 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 27 | } 28 | } 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_8 32 | targetCompatibility JavaVersion.VERSION_1_8 33 | } 34 | 35 | lintOptions { 36 | abortOnError false 37 | } 38 | } 39 | 40 | dependencies { 41 | implementation fileTree(include: ['*.jar'], dir: 'libs') 42 | 43 | implementation 'androidx.multidex:multidex:2.0.1' 44 | implementation 'androidx.appcompat:appcompat:1.2.0' 45 | implementation 'com.google.android.material:material:1.2.1' 46 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 47 | 48 | implementation project(':biz-module-main') 49 | implementation project(':biz-module-newhouse') 50 | implementation project(':biz-module-secondhouse') 51 | implementation project(':biz-module-renthouse') 52 | 53 | implementation project(':lib-common') 54 | implementation project(':lib-data-local') 55 | implementation project(':lib-data-net') 56 | 57 | implementation rootProject.ext.dependencies["butterknife"] 58 | annotationProcessor rootProject.ext.dependencies["butterknife-compiler"] 59 | 60 | implementation 'com.alibaba:arouter-api:1.5.1' 61 | annotationProcessor 'com.alibaba:arouter-compiler:1.5.1' 62 | } 63 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/baron/develop/android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/modularization/app/ModularizationApp.java: -------------------------------------------------------------------------------- 1 | package com.modularization.app; 2 | 3 | import android.app.Application; 4 | 5 | import androidx.multidex.MultiDex; 6 | 7 | import com.alibaba.android.arouter.launcher.ARouter; 8 | import com.modularization.data.local.preferences.Preferences; 9 | import com.modularization.data.net.ApiClient; 10 | 11 | /** 12 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 13 | */ 14 | public class ModularizationApp extends Application { 15 | 16 | @Override 17 | public void onCreate() { 18 | super.onCreate(); 19 | MultiDex.install(this); 20 | ARouter.init(this); 21 | ApiClient.getInstance().init(null); 22 | 23 | //初始化SP配置 24 | Preferences.getInstance(this).loadDefaults(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/modularization/app/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.modularization.app; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | 8 | import com.modularization.biz.module.main.MainActivity; 9 | 10 | 11 | /** 12 | * App闪屏页 13 | * 14 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 15 | */ 16 | public class SplashActivity extends AppCompatActivity { 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_splash); 22 | 23 | startActivity(new Intent(this, MainActivity.class)); 24 | finish(); 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/ModularizationProject/f6f664169230d13f1188bf773d92d58140328cf0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/ModularizationProject/f6f664169230d13f1188bf773d92d58140328cf0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-v19/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | 8 | @android:color/transparent 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Modularization 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /biz-module-main/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /biz-module-main/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'com.jakewharton.butterknife' 4 | } 5 | 6 | android { 7 | compileSdkVersion 29 8 | buildToolsVersion "29.0.3" 9 | 10 | defaultConfig { 11 | minSdkVersion 19 12 | targetSdkVersion 29 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | consumerProguardFiles "consumer-rules.pro" 18 | 19 | javaCompileOptions { 20 | annotationProcessorOptions { 21 | arguments = [AROUTER_MODULE_NAME: project.getName()] 22 | } 23 | } 24 | } 25 | 26 | buildTypes { 27 | release { 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 30 | } 31 | } 32 | 33 | compileOptions { 34 | sourceCompatibility JavaVersion.VERSION_1_8 35 | targetCompatibility JavaVersion.VERSION_1_8 36 | } 37 | } 38 | 39 | dependencies { 40 | 41 | implementation 'androidx.appcompat:appcompat:1.2.0' 42 | implementation 'com.google.android.material:material:1.2.1' 43 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 44 | 45 | implementation project(':lib-common') 46 | implementation project(':lib-data-local') 47 | implementation project(':lib-data-net') 48 | 49 | implementation project(path: ':biz-service-newhouse') 50 | implementation project(path: ':biz-service-secondhouse') 51 | implementation project(path: ':biz-service-renthouse') 52 | 53 | implementation rootProject.ext.dependencies["butterknife"] 54 | annotationProcessor rootProject.ext.dependencies["butterknife-compiler"] 55 | 56 | implementation 'com.alibaba:arouter-api:1.5.1' 57 | annotationProcessor 'com.alibaba:arouter-compiler:1.5.1' 58 | } -------------------------------------------------------------------------------- /biz-module-main/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BaronZ88/ModularizationProject/f6f664169230d13f1188bf773d92d58140328cf0/biz-module-main/consumer-rules.pro -------------------------------------------------------------------------------- /biz-module-main/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /biz-module-main/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /biz-module-main/src/main/java/com/modularization/biz/module/main/Constants.java: -------------------------------------------------------------------------------- 1 | package com.modularization.biz.module.main; 2 | 3 | /** 4 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 5 | */ 6 | public final class Constants { 7 | 8 | public static final class Service { 9 | public static final String ID = "id_main"; 10 | public static final String MODULE_NAME = "MainModule"; 11 | public static final String HOST = "https://api.github.com/"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /biz-module-main/src/main/java/com/modularization/biz/module/main/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.modularization.biz.module.main; 2 | 3 | import android.os.Bundle; 4 | import android.widget.TextView; 5 | 6 | import androidx.fragment.app.Fragment; 7 | 8 | import com.alibaba.android.arouter.launcher.ARouter; 9 | import com.modularization.biz.service.base.ResponseCallback; 10 | import com.modularization.biz.service.newhouse.NewHouseApiData; 11 | import com.modularization.biz.service.newhouse.NewHouseProviderHelper; 12 | import com.modularization.biz.service.newhouse.NewHouseRouterTable; 13 | import com.modularization.biz.service.renthouse.RentHouseData; 14 | import com.modularization.biz.service.renthouse.RentHouseProviderHelper; 15 | import com.modularization.biz.service.renthouse.RentHouseRouterTable; 16 | import com.modularization.common.base.activity.BaseActivity; 17 | import com.modularization.common.base.util.ActivityUtils; 18 | import com.modularization.common.model.HouseDetail; 19 | import com.modularization.biz.service.newhouse.NewHouseData; 20 | import com.modularization.biz.service.secondhouse.SecondHouseData; 21 | import com.modularization.biz.service.secondhouse.SecondHouseRouterTable; 22 | import com.modularization.biz.service.secondhouse.SecondHouseProviderHelper; 23 | import com.modularization.biz.service.base.ErrorMessage; 24 | 25 | import java.util.ArrayList; 26 | 27 | import butterknife.ButterKnife; 28 | import butterknife.OnClick; 29 | import butterknife.Unbinder; 30 | import rx.Subscription; 31 | import rx.subscriptions.CompositeSubscription; 32 | 33 | /** 34 | * App首页 35 | * 36 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 37 | */ 38 | public class MainActivity extends BaseActivity { 39 | 40 | private CompositeSubscription subscriptions; 41 | private Unbinder unbinder; 42 | 43 | @Override 44 | protected void onCreate(Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | setContentView(R.layout.activity_main); 47 | unbinder = ButterKnife.bind(this); 48 | 49 | setSupportActionBar(findViewById(R.id.toolbar)); 50 | if (getSupportActionBar() != null) { 51 | getSupportActionBar().setDisplayShowTitleEnabled(true); 52 | getSupportActionBar().setDisplayHomeAsUpEnabled(false); 53 | } 54 | 55 | subscriptions = new CompositeSubscription(); 56 | 57 | TextView newHouseTextView = findViewById(R.id.new_house_text_view); 58 | NewHouseData newHouseData = NewHouseProviderHelper.getNewHouseProvider().fetchNewHouseData(); 59 | newHouseTextView.setText(newHouseData.toString()); 60 | Subscription subscription = NewHouseProviderHelper.getNewHouseProvider().callNewHouseApi(new ResponseCallback() { 61 | @Override 62 | public void onSuccess(NewHouseApiData data) { 63 | newHouseTextView.setText(String.format("%s\n\n%s", newHouseTextView.getText(), data.toString())); 64 | } 65 | 66 | @Override 67 | public void onFailed(ErrorMessage errorMsg) { 68 | newHouseTextView.setText(String.format("%s\n\n%s", newHouseTextView.getText(), errorMsg)); 69 | } 70 | }); 71 | subscriptions.add(subscription); 72 | 73 | SecondHouseData secondHouseData = SecondHouseProviderHelper.getSecondHouseProvider().fetchSecondHouseData(); 74 | ((TextView) findViewById(R.id.second_house_text_view)).setText(secondHouseData.toString()); 75 | 76 | RentHouseData rentHouseData = RentHouseProviderHelper.getRentHouseProvider().fetchRentHouseData(); 77 | ((TextView) findViewById(R.id.rent_house_text_view)).setText(rentHouseData.toString()); 78 | 79 | Fragment fragment = SecondHouseProviderHelper.getSecondHouseProvider().getFragment(SecondHouseRouterTable.PATH_FRAGMENT_BLANK); 80 | ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment, R.id.fragment_container); 81 | } 82 | 83 | @OnClick(R2.id.btn_goto_new_house) 84 | void startNewHouseActivity() { 85 | ARouter.getInstance().build(NewHouseRouterTable.PATH_ACTIVITY_MAIN) 86 | .withString("cityId", "110") 87 | .withParcelable("houseDetail", new HouseDetail("10000", "潍坊新村", 66)) 88 | .navigation(); 89 | } 90 | 91 | @OnClick(R2.id.btn_goto_second_house) 92 | void startSecondHouseActivity() { 93 | 94 | ArrayList houseDetailList = new ArrayList<>(); 95 | houseDetailList.add(new HouseDetail("10001", "潍坊一村", 88)); 96 | houseDetailList.add(new HouseDetail("10002", "潍坊二村", 120)); 97 | houseDetailList.add(new HouseDetail("10004", "潍坊三村", 86)); 98 | 99 | ARouter.getInstance().build(SecondHouseRouterTable.PATH_ACTIVITY_MAIN) 100 | .withString("cityId", "111") 101 | .withParcelableArrayList("houseList", houseDetailList) 102 | .navigation(); 103 | } 104 | 105 | @OnClick(R2.id.btn_goto_rent_house) 106 | void startRentHouseActivity() { 107 | ArrayList brokerIdList = new ArrayList<>(); 108 | brokerIdList.add(20000); 109 | brokerIdList.add(20001); 110 | brokerIdList.add(20002); 111 | ARouter.getInstance().build(RentHouseRouterTable.PATH_ACTIVITY_MAIN) 112 | .withString("cityId", "112") 113 | .withIntegerArrayList("brokerIdList", brokerIdList) 114 | .navigation(); 115 | } 116 | 117 | @Override 118 | protected void onDestroy() { 119 | super.onDestroy(); 120 | if (unbinder != null) 121 | unbinder.unbind(); 122 | if (subscriptions != null) 123 | subscriptions.unsubscribe(); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /biz-module-main/src/main/java/com/modularization/biz/module/main/http/ApiService.java: -------------------------------------------------------------------------------- 1 | package com.modularization.biz.module.main.http; 2 | 3 | /** 4 | * 定义main模块API接口 5 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 6 | * 2017/1/5 7 | */ 8 | public interface ApiService { 9 | } 10 | -------------------------------------------------------------------------------- /biz-module-main/src/main/java/com/modularization/biz/module/main/http/ApiServiceWrap.java: -------------------------------------------------------------------------------- 1 | package com.modularization.biz.module.main.http; 2 | 3 | import com.modularization.biz.module.main.Constants; 4 | import com.modularization.data.net.service.ServiceWrap; 5 | 6 | /** 7 | * @author baronzhang (baron[dot]zhanglei[at]gmail[dot]com) 8 | */ 9 | public class ApiServiceWrap implements ServiceWrap { 10 | 11 | @Override 12 | public String getIdentify() { 13 | return Constants.Service.ID; 14 | } 15 | 16 | @Override 17 | public String getModuleName() { 18 | return Constants.Service.MODULE_NAME; 19 | } 20 | 21 | @Override 22 | public String getHost() { 23 | return Constants.Service.HOST; 24 | } 25 | 26 | @Override 27 | public Class getRealService() { 28 | return ApiService.class; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /biz-module-main/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 25 | 26 | 30 | 31 | 36 | 37 |