├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── io │ │ └── liweijie │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── io │ │ │ └── liweijie │ │ │ └── CustomApplication.java │ └── res │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── github │ └── io │ └── liweijie │ └── ExampleUnitTest.java ├── app2 ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── io │ │ └── liweijie │ │ └── app2 │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── io │ │ │ └── liweijie │ │ │ └── app2 │ │ │ └── CustomApplication.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── github │ └── io │ └── liweijie │ └── app2 │ └── ExampleUnitTest.java ├── art ├── app1.gif ├── app2.gif ├── home.gif ├── module.gif └── moduleDirectory.png ├── base ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── io │ │ └── liweijie │ │ └── base │ │ ├── BaseActivity.java │ │ ├── BaseApplication.java │ │ ├── BaseFragment.java │ │ ├── BaseRecyclerFragment.java │ │ ├── dao │ │ └── UserInfo.java │ │ ├── moduleinterface │ │ ├── config │ │ │ ├── ImmutableMap.java │ │ │ ├── ModuleOptions.java │ │ │ └── MyBundle.java │ │ ├── module │ │ │ ├── app │ │ │ │ └── AppService.java │ │ │ ├── app2 │ │ │ │ └── App2Service.java │ │ │ ├── home │ │ │ │ ├── HomeIntent.java │ │ │ │ └── HomeService.java │ │ │ ├── module1 │ │ │ │ ├── Module1Intent.java │ │ │ │ └── Module1Service.java │ │ │ ├── module2 │ │ │ │ ├── Module2Intent.java │ │ │ │ └── Module2Service.java │ │ │ ├── module3 │ │ │ │ ├── Module3Intent.java │ │ │ │ └── Module3Service.java │ │ │ ├── module4 │ │ │ │ ├── Module4Intent.java │ │ │ │ └── Module4Service.java │ │ │ └── module5 │ │ │ │ ├── Module5Intent.java │ │ │ │ └── Module5Service.java │ │ ├── provider │ │ │ ├── IAppProvider.java │ │ │ ├── IBaseProvider.java │ │ │ ├── IFragmentProvider.java │ │ │ ├── IHomeProvider.java │ │ │ ├── IModule1Provider.java │ │ │ ├── IModule2Provider.java │ │ │ ├── IModule3Provider.java │ │ │ ├── IModule4Provider.java │ │ │ └── IModule5Provider.java │ │ └── router │ │ │ ├── ModuleManager.java │ │ │ ├── MyRouter.java │ │ │ └── ServiceManager.java │ │ ├── util │ │ ├── LG.java │ │ └── Util.java │ │ └── view │ │ ├── BaseRecyclerView.java │ │ └── adapter │ │ ├── BaseAdapter.java │ │ └── VH.java │ └── res │ ├── layout │ └── fragment_core_recycler_view.xml │ └── values │ ├── colors.xml │ ├── ids.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── config.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── home ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── debug │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── github │ │ └── io │ │ └── liweijie │ │ └── home │ │ └── debug │ │ └── HomeDebugApplication.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── io │ │ │ └── liweijie │ │ │ └── home │ │ │ ├── HomeActivity.java │ │ │ ├── HomeProvider.java │ │ │ └── SplashActivity.java │ └── res │ │ ├── drawable-xhdpi │ │ └── home_splash_bg.jpg │ │ ├── layout │ │ ├── activity_home.xml │ │ └── activity_splash.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── release │ └── AndroidManifest.xml ├── modulelib1 ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── debug │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── io │ │ │ └── liweijie │ │ │ └── lib1 │ │ │ └── debug │ │ │ ├── Module1DebugApplication.java │ │ │ └── activity │ │ │ └── Module1DebugActivity.java │ └── res │ │ └── layout │ │ └── module1_debug_activity.xml │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── io │ │ │ └── liweijie │ │ │ └── lib1 │ │ │ ├── Module1Fragment.java │ │ │ ├── Mudule1Provider.java │ │ │ ├── adapter │ │ │ └── Module1Adapter.java │ │ │ └── bean │ │ │ └── Books.java │ └── res │ │ ├── layout │ │ ├── module1_fragment_main.xml │ │ └── module1_fragment_main_item.xml │ │ └── values │ │ └── strings.xml │ └── release │ └── AndroidManifest.xml ├── modulelib2 ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── io │ │ └── liweijie │ │ └── lib2 │ │ ├── Module2Fragment.java │ │ └── Module2Provider.java │ └── res │ ├── layout │ └── module2_fragment_main.xml │ └── values │ └── strings.xml ├── modulelib3 ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── io │ │ └── liweijie │ │ └── lib2 │ │ ├── Module3Fragment.java │ │ └── Module3Provider.java │ └── res │ ├── layout │ └── module2_main_fragment.xml │ └── values │ └── strings.xml ├── modulelib4 ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── io │ │ └── liweijie │ │ └── lib4 │ │ ├── Module4Activity.java │ │ └── Module4Provider.java │ └── res │ ├── layout │ └── module4_main_activity.xml │ └── values │ └── strings.xml ├── modulelib5 ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── io │ │ └── liweijie │ │ └── lib5 │ │ ├── Module5Activity.java │ │ └── Module5Provider.java │ └── res │ ├── layout │ └── module5_activity_main.xml │ └── values │ └── strings.xml ├── readme.md └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 27 | 28 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.8 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android.compileSdkVersion 5 | buildToolsVersion rootProject.ext.android.buildToolsVersion 6 | 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.android.minSdkVersion 9 | targetSdkVersion rootProject.ext.android.targetSdkVersion 10 | versionCode 101 11 | versionName "1.0.1" 12 | applicationId "com.github.io.liweijie" 13 | javaCompileOptions { 14 | annotationProcessorOptions { 15 | arguments = [moduleName: project.getName()] 16 | } 17 | } 18 | } 19 | 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_1_7 22 | targetCompatibility JavaVersion.VERSION_1_7 23 | } 24 | 25 | 26 | buildTypes { 27 | release { 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | } 31 | 32 | } 33 | 34 | dependencies { 35 | compile fileTree(dir: 'libs', include: ['*.jar']) 36 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 37 | exclude group: 'com.android.support', module: 'support-annotations' 38 | }) 39 | testCompile 'junit:junit:4.12' 40 | annotationProcessor rootProject.ext.dependencies["aroutercompiler"] 41 | if (rootProject.ext.isMouleDebugHome) { 42 | compile project(':home') 43 | } 44 | if (rootProject.ext.isModule1Debug) { 45 | compile project(':modulelib1') 46 | } 47 | compile project(':modulelib2') 48 | compile project(':modulelib3') 49 | compile project(':modulelib4') 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /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/liweijie/Library/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/androidTest/java/com/github/io/liweijie/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.github.io.liweijie", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/io/liweijie/CustomApplication.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie; 2 | 3 | 4 | import com.alibaba.android.arouter.launcher.ARouter; 5 | import com.github.io.liweijie.base.BaseApplication; 6 | import com.github.io.liweijie.base.moduleinterface.provider.IModule2Provider; 7 | import com.github.io.liweijie.base.moduleinterface.provider.IModule3Provider; 8 | import com.github.io.liweijie.base.moduleinterface.provider.IModule4Provider; 9 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 10 | import com.github.io.liweijie.base.moduleinterface.config.ModuleOptions; 11 | import com.github.io.liweijie.base.moduleinterface.provider.IHomeProvider; 12 | import com.github.io.liweijie.base.moduleinterface.provider.IModule1Provider; 13 | import com.github.io.liweijie.base.util.LG; 14 | 15 | /** 16 | * 作者:黎伟杰-子然 on 2017/3/26. 17 | * 邮箱:liweijie@linghit.com 18 | * description: 19 | * update by: 20 | * update day: 21 | */ 22 | public class CustomApplication extends BaseApplication { 23 | @Override 24 | public void onCreate() { 25 | super.onCreate(); 26 | initARouter(); 27 | } 28 | 29 | private void initARouter() { 30 | if (LG.isDebug) { 31 | ARouter.openLog(); 32 | ARouter.openDebug(); 33 | ARouter.printStackTrace(); 34 | } 35 | ARouter.init(this); 36 | ModuleOptions.ModuleBuilder builder = new ModuleOptions.ModuleBuilder(this) 37 | .addModule(IHomeProvider.HOME_MAIN_SERVICE, IHomeProvider.HOME_MAIN_SERVICE) 38 | .addModule(IModule1Provider.MODULE1_MAIN_SERVICE, IModule1Provider.MODULE1_MAIN_SERVICE) 39 | .addModule(IModule2Provider.MODULE2_MAIN_SERVICE, IModule2Provider.MODULE2_MAIN_SERVICE) 40 | .addModule(IModule3Provider.MODULE3_MAIN_SERVICE, IModule3Provider.MODULE3_MAIN_SERVICE) 41 | .addModule(IModule4Provider.MODULE4_MAIN_SERVICE, IModule4Provider.MODULE4_MAIN_SERVICE); 42 | 43 | ModuleManager.getInstance().init(builder.build()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ModularSample 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/github/io/liweijie/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app2/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app2/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android.compileSdkVersion 5 | buildToolsVersion rootProject.ext.android.buildToolsVersion 6 | 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.android.minSdkVersion 9 | targetSdkVersion rootProject.ext.android.targetSdkVersion 10 | versionCode 101 11 | versionName "1.0.1" 12 | applicationId "com.github.io.liweijie.app2" 13 | javaCompileOptions { 14 | annotationProcessorOptions { 15 | arguments = [moduleName: project.getName()] 16 | } 17 | } 18 | } 19 | 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_1_7 22 | targetCompatibility JavaVersion.VERSION_1_7 23 | } 24 | 25 | 26 | buildTypes { 27 | release { 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | } 31 | 32 | } 33 | 34 | dependencies { 35 | compile fileTree(dir: 'libs', include: ['*.jar']) 36 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 37 | exclude group: 'com.android.support', module: 'support-annotations' 38 | }) 39 | testCompile 'junit:junit:4.12' 40 | annotationProcessor rootProject.ext.dependencies["aroutercompiler"] 41 | if (rootProject.ext.isMouleDebugHome) { 42 | compile project(':home') 43 | } 44 | if (rootProject.ext.isModule1Debug) { 45 | compile project(':modulelib1') 46 | } 47 | compile project(':modulelib2') 48 | compile project(':modulelib4') 49 | compile project(':modulelib5') 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /app2/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/liweijie/Library/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 | -------------------------------------------------------------------------------- /app2/src/androidTest/java/com/github/io/liweijie/app2/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.app2; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.github.io.liweijie.app2", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app2/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app2/src/main/java/com/github/io/liweijie/app2/CustomApplication.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.app2; 2 | 3 | import com.alibaba.android.arouter.launcher.ARouter; 4 | import com.github.io.liweijie.base.BaseApplication; 5 | import com.github.io.liweijie.base.moduleinterface.config.ModuleOptions; 6 | import com.github.io.liweijie.base.moduleinterface.provider.IHomeProvider; 7 | import com.github.io.liweijie.base.moduleinterface.provider.IModule1Provider; 8 | import com.github.io.liweijie.base.moduleinterface.provider.IModule2Provider; 9 | import com.github.io.liweijie.base.moduleinterface.provider.IModule4Provider; 10 | import com.github.io.liweijie.base.moduleinterface.provider.IModule5Provider; 11 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 12 | import com.github.io.liweijie.base.util.LG; 13 | 14 | /** 15 | * 作者:黎伟杰-子然 on 2017/3/26. 16 | * 邮箱:liweijie@linghit.com 17 | * description: 18 | * update by: 19 | * update day: 20 | */ 21 | public class CustomApplication extends BaseApplication { 22 | @Override 23 | public void onCreate() { 24 | super.onCreate(); 25 | initARouter(); 26 | } 27 | 28 | private void initARouter() { 29 | if (LG.isDebug) { 30 | ARouter.openLog(); 31 | ARouter.openDebug(); 32 | ARouter.printStackTrace(); 33 | } 34 | ARouter.init(this); 35 | ModuleOptions.ModuleBuilder builder = new ModuleOptions.ModuleBuilder(this) 36 | .addModule(IHomeProvider.HOME_MAIN_SERVICE, IHomeProvider.HOME_MAIN_SERVICE) 37 | .addModule(IModule1Provider.MODULE1_MAIN_SERVICE, IModule1Provider.MODULE1_MAIN_SERVICE) 38 | .addModule(IModule2Provider.MODULE2_MAIN_SERVICE, IModule2Provider.MODULE2_MAIN_SERVICE) 39 | .addModule(IModule4Provider.MODULE4_MAIN_SERVICE, IModule4Provider.MODULE4_MAIN_SERVICE) 40 | .addModule(IModule5Provider.MODULE5_MAIN_SERVICE, IModule5Provider.MODULE5_MAIN_SERVICE); 41 | 42 | ModuleManager.getInstance().init(builder.build()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app2/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 18 | 19 | -------------------------------------------------------------------------------- /app2/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/app2/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app2/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/app2/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app2/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/app2/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app2/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/app2/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app2/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/app2/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app2/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app2/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app2/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app2/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | App2 3 | 4 | -------------------------------------------------------------------------------- /app2/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app2/src/test/java/com/github/io/liweijie/app2/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.app2; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /art/app1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/art/app1.gif -------------------------------------------------------------------------------- /art/app2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/art/app2.gif -------------------------------------------------------------------------------- /art/home.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/art/home.gif -------------------------------------------------------------------------------- /art/module.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/art/module.gif -------------------------------------------------------------------------------- /art/moduleDirectory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/art/moduleDirectory.png -------------------------------------------------------------------------------- /base/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /base/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android.compileSdkVersion 5 | buildToolsVersion rootProject.ext.android.buildToolsVersion 6 | 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.android.minSdkVersion 9 | targetSdkVersion rootProject.ext.android.targetSdkVersion 10 | versionCode 101 11 | versionName "1.0.1" 12 | 13 | javaCompileOptions { 14 | annotationProcessorOptions { 15 | arguments = [moduleName: project.getName()] 16 | } 17 | } 18 | } 19 | 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_1_7 22 | targetCompatibility JavaVersion.VERSION_1_7 23 | } 24 | 25 | 26 | buildTypes { 27 | release { 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | } 31 | 32 | } 33 | 34 | dependencies { 35 | compile fileTree(dir: 'libs', include: ['*.jar']) 36 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 37 | exclude group: 'com.android.support', module: 'support-annotations' 38 | }) 39 | testCompile 'junit:junit:4.12' 40 | 41 | compile rootProject.ext.dependencies["supportv4"] 42 | compile rootProject.ext.dependencies["appcompatv7"] 43 | compile rootProject.ext.dependencies["recyclerviewv7"] 44 | 45 | compile rootProject.ext.dependencies["arouterapi"] 46 | annotationProcessor rootProject.ext.dependencies["aroutercompiler"] 47 | } 48 | } -------------------------------------------------------------------------------- /base/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/liweijie/Library/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 | -------------------------------------------------------------------------------- /base/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | 6 | /** 7 | * 作者:黎伟杰-子然 on 2017/3/21. 8 | * 邮箱:liweijie@linghit.com 9 | * description: 10 | * update by: 11 | * update day: 12 | */ 13 | public class BaseActivity extends AppCompatActivity { 14 | 15 | @Override 16 | public void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/BaseApplication.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base; 2 | 3 | import android.app.Application; 4 | 5 | import com.github.io.liweijie.base.util.LG; 6 | 7 | /** 8 | * 作者:黎伟杰-子然 on 2017/4/16. 9 | * 邮箱:liweijie@linghit.com 10 | * description: 11 | * update by: 12 | * update day: 13 | */ 14 | public class BaseApplication extends Application { 15 | @Override 16 | public void onCreate() { 17 | super.onCreate(); 18 | LG.isDebug = true; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.IdRes; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.Fragment; 7 | import android.util.Log; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | 12 | import java.lang.reflect.Field; 13 | 14 | /** 15 | * 作者:黎伟杰-子然 on 2017/3/21. 16 | * 邮箱:liweijie@linghit.com 17 | * description: 18 | * update by: 19 | * update day: 20 | */ 21 | public abstract class BaseFragment extends Fragment { 22 | 23 | private static final String TAG = BaseFragment.class.getSimpleName(); 24 | protected View mContentView; 25 | 26 | @Override 27 | public void onCreate(@Nullable Bundle savedInstanceState) { 28 | log("OnCreate"); 29 | super.onCreate(savedInstanceState); 30 | } 31 | 32 | @Override 33 | public void onStart() { 34 | log("onStart"); 35 | super.onStart(); 36 | } 37 | 38 | @Override 39 | public void onResume() { 40 | log("onResume"); 41 | super.onResume(); 42 | } 43 | 44 | @Override 45 | public void onPause() { 46 | log("onPause"); 47 | super.onPause(); 48 | } 49 | 50 | @Override 51 | public void onStop() { 52 | log("onStop"); 53 | super.onStop(); 54 | } 55 | 56 | @Override 57 | public void onDestroy() { 58 | log("onDestroy"); 59 | super.onDestroy(); 60 | } 61 | 62 | @Override 63 | public void onDestroyView() { 64 | super.onDestroyView(); 65 | 66 | //解决嵌套 Fragment 的bug 67 | try { 68 | Field childFragmentManager = Fragment.class.getDeclaredField("mChildFragmentManager"); 69 | childFragmentManager.setAccessible(true); 70 | childFragmentManager.set(this, null); 71 | 72 | } catch (NoSuchFieldException e) { 73 | throw new RuntimeException(e); 74 | } catch (IllegalAccessException e) { 75 | throw new RuntimeException(e); 76 | } 77 | } 78 | 79 | @Nullable 80 | @Override 81 | public final View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 82 | log("onCreateView"); 83 | return mContentView = getContentView(inflater, container, savedInstanceState); 84 | } 85 | 86 | public abstract View getContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState); 87 | 88 | public T findViewById(@IdRes int id) { 89 | return (T) mContentView.findViewById(id); 90 | } 91 | 92 | protected void log(String msg) { 93 | Log.i(TAG, msg); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/BaseRecyclerFragment.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.LayoutInflater; 8 | import android.view.MotionEvent; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | 12 | /** 13 | * 作者:黎伟杰-子然 on 2017/3/21. 14 | * 邮箱:liweijie@linghit.com 15 | * description: 16 | * update by: 17 | * update day: 18 | */ 19 | public abstract class BaseRecyclerFragment extends BaseFragment { 20 | protected RecyclerView mRecyclerView; 21 | 22 | @Override 23 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 24 | super.onViewCreated(view, savedInstanceState); 25 | mRecyclerView = findViewById(R.id.core_recycler_view); 26 | if (mRecyclerView == null) { 27 | throw new IllegalArgumentException("必须包含id 为 core_recycler_view 的RecyclerView"); 28 | } 29 | mRecyclerView.setLayoutManager(getLayoutManager()); 30 | mRecyclerView.setAdapter(getAdapter()); 31 | } 32 | 33 | protected abstract RecyclerView.Adapter getAdapter(); 34 | 35 | protected RecyclerView.LayoutManager getLayoutManager() { 36 | return new LinearLayoutManager(getActivity()); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/dao/UserInfo.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.dao; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 作者:黎伟杰-子然 on 2017/4/16. 7 | * 邮箱:liweijie@linghit.com 8 | * description: 9 | * update by: 10 | * update day: 11 | */ 12 | public class UserInfo implements Serializable { 13 | private String name; 14 | private int age; 15 | 16 | public UserInfo() { 17 | } 18 | 19 | public UserInfo(String name, int age) { 20 | this.name = name; 21 | this.age = age; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public int getAge() { 33 | return age; 34 | } 35 | 36 | public void setAge(int age) { 37 | this.age = age; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/config/ImmutableMap.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.config; 2 | 3 | import com.github.io.liweijie.base.util.Util; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | /** 9 | * 作者:黎伟杰-子然 on 2017/4/13. 10 | * 邮箱:liweijie@linghit.com 11 | * description: 12 | * update by: 13 | * update day: 14 | */ 15 | public class ImmutableMap { 16 | 17 | private Map mPaths; 18 | 19 | public ImmutableMap() { 20 | mPaths = new HashMap<>(); 21 | } 22 | 23 | public void add(String key, String value) { 24 | if (Util.isNull(key, value)) return; 25 | mPaths.put(key, value); 26 | } 27 | 28 | public void add(Map mPaths) { 29 | if (mPaths == null) return; 30 | this.mPaths.putAll(mPaths); 31 | } 32 | 33 | public boolean containsKey(String key) { 34 | return mPaths.containsKey(key); 35 | } 36 | 37 | public String get(String key) { 38 | return mPaths.get(key); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/config/ModuleOptions.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.config; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * 作者:黎伟杰-子然 on 2017/4/13. 7 | * 邮箱:liweijie@linghit.com 8 | * description: 9 | * update by: 10 | * update day: 11 | */ 12 | public class ModuleOptions { 13 | 14 | private ModuleOptions.ModuleBuilder builder; 15 | 16 | private ModuleOptions(ModuleOptions.ModuleBuilder builder) { 17 | this.builder = builder; 18 | } 19 | 20 | public boolean hasModule(String key) { 21 | return builder.containModule(key); 22 | } 23 | 24 | public String getModule(String key) { 25 | return builder.getModuleEntrance(key); 26 | } 27 | 28 | public Context getContext() { 29 | return builder.context; 30 | } 31 | 32 | public static class ModuleBuilder { 33 | private Context context; 34 | private ImmutableMap mModules; 35 | 36 | public ModuleBuilder(Context context) { 37 | this.context = context; 38 | mModules = new ImmutableMap(); 39 | } 40 | 41 | public ModuleOptions.ModuleBuilder addModule(String key, String value) { 42 | mModules.add(key, value); 43 | return this; 44 | } 45 | 46 | public boolean containModule(String key) { 47 | return mModules.containsKey(key); 48 | } 49 | 50 | public String getModuleEntrance(String key) { 51 | return mModules.get(key); 52 | } 53 | 54 | public ModuleOptions build() { 55 | return new ModuleOptions(this); 56 | } 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/config/MyBundle.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.config; 2 | 3 | import android.os.Bundle; 4 | import android.os.Parcelable; 5 | import android.text.TextUtils; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 作者:黎伟杰-子然 on 2017/4/16. 11 | * 邮箱:liweijie@linghit.com 12 | * description:链式调用 13 | * update by: 14 | * update day: 15 | */ 16 | public class MyBundle { 17 | private Bundle bundle; 18 | 19 | public MyBundle() { 20 | bundle = new Bundle(); 21 | } 22 | 23 | public MyBundle put(String key, int value) { 24 | bundle.putInt(key, value); 25 | return this; 26 | } 27 | 28 | public MyBundle put(String key, long value) { 29 | bundle.putLong(key, value); 30 | return this; 31 | } 32 | 33 | public MyBundle put(String key, String value) { 34 | if (TextUtils.isEmpty(value)) { 35 | return this; 36 | } 37 | bundle.putString(key, value); 38 | return this; 39 | } 40 | 41 | public MyBundle put(String key, Serializable value) { 42 | if (value == null) { 43 | return this; 44 | } 45 | bundle.putSerializable(key, value); 46 | return this; 47 | } 48 | 49 | public MyBundle put(String key, Parcelable value) { 50 | if (value == null) { 51 | return this; 52 | } 53 | bundle.putParcelable(key, value); 54 | return this; 55 | } 56 | 57 | public MyBundle put(String key, String[] arrays) { 58 | if (arrays == null) { 59 | return this; 60 | } 61 | bundle.putStringArray(key, arrays); 62 | return this; 63 | } 64 | 65 | public Bundle build() { 66 | return bundle; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/app/AppService.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.app; 2 | 3 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 4 | import com.github.io.liweijie.base.moduleinterface.provider.IAppProvider; 5 | 6 | /** 7 | * 作者:黎伟杰-子然 on 2017/4/13. 8 | * 邮箱:liweijie@linghit.com 9 | * description: 10 | * update by: 11 | * update day: 12 | */ 13 | public class AppService { 14 | private static boolean hasModule() { 15 | return ModuleManager.getInstance().hasModule(IAppProvider.APP_MAIN_SERVICE); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/app2/App2Service.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.app2; 2 | 3 | import com.github.io.liweijie.base.moduleinterface.provider.IAppProvider; 4 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 5 | 6 | /** 7 | * 作者:黎伟杰-子然 on 2017/4/13. 8 | * 邮箱:liweijie@linghit.com 9 | * description: 10 | * update by: 11 | * update day: 12 | */ 13 | public class App2Service { 14 | private static boolean hasModule() { 15 | return ModuleManager.getInstance().hasModule(IAppProvider.APP_MAIN_SERVICE); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/home/HomeIntent.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.home; 2 | 3 | import com.github.io.liweijie.base.moduleinterface.config.MyBundle; 4 | import com.github.io.liweijie.base.moduleinterface.provider.IHomeProvider; 5 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 6 | import com.github.io.liweijie.base.moduleinterface.router.MyRouter; 7 | 8 | /** 9 | * 作者:黎伟杰-子然 on 2017/4/16. 10 | * 邮箱:liweijie@linghit.com 11 | * description: 12 | * update by: 13 | * update day: 14 | */ 15 | public class HomeIntent { 16 | private static boolean hasModule() { 17 | return ModuleManager.getInstance().hasModule(IHomeProvider.HOME_MAIN_SERVICE); 18 | } 19 | public static void launchHome(int tabType) { 20 | //HomeActivity 21 | MyBundle bundle = new MyBundle(); 22 | bundle.put(IHomeProvider.HOME_TABTYPE, tabType); 23 | MyRouter.newInstance(IHomeProvider.HOME_ACT_HOME) 24 | .withBundle(bundle) 25 | .navigation(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/home/HomeService.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.home; 2 | 3 | import android.app.Activity; 4 | 5 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 6 | import com.github.io.liweijie.base.moduleinterface.router.ServiceManager; 7 | import com.github.io.liweijie.base.moduleinterface.provider.IHomeProvider; 8 | 9 | /** 10 | * 作者:黎伟杰-子然 on 2017/4/16. 11 | * 邮箱:liweijie@linghit.com 12 | * description: 13 | * update by: 14 | * update day: 15 | */ 16 | public class HomeService { 17 | 18 | private static boolean hasModule() { 19 | return ModuleManager.getInstance().hasModule(IHomeProvider.HOME_MAIN_SERVICE); 20 | } 21 | 22 | public static void selectedTab(Activity activity, int position) { 23 | if (!hasModule()) return; 24 | ServiceManager.getInstance().getHomeProvider().selectedTab(activity, position); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/module1/Module1Intent.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.module1; 2 | 3 | /** 4 | * 作者:黎伟杰-子然 on 2017/4/13. 5 | * 邮箱:liweijie@linghit.com 6 | * description: 7 | * update by: 8 | * update day: 9 | */ 10 | public class Module1Intent { 11 | } 12 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/module1/Module1Service.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.module1; 2 | 3 | import android.support.v4.app.Fragment; 4 | 5 | import com.github.io.liweijie.base.moduleinterface.provider.IModule1Provider; 6 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 7 | import com.github.io.liweijie.base.moduleinterface.router.ServiceManager; 8 | 9 | /** 10 | * 作者:黎伟杰-子然 on 2017/4/13. 11 | * 邮箱:liweijie@linghit.com 12 | * description: 13 | * update by: 14 | * update day: 15 | */ 16 | public class Module1Service { 17 | private static boolean hasModule1() { 18 | return ModuleManager.getInstance().hasModule(IModule1Provider.MODULE1_MAIN_SERVICE); 19 | } 20 | 21 | public static Fragment getModule1Frgment(Object... args) { 22 | if(!hasModule1()) return null; 23 | return ServiceManager.getInstance().getModule1Provider().newInstance(args); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/module2/Module2Intent.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.module2; 2 | 3 | /** 4 | * 作者:黎伟杰-子然 on 2017/4/13. 5 | * 邮箱:liweijie@linghit.com 6 | * description: 7 | * update by: 8 | * update day: 9 | */ 10 | public class Module2Intent { 11 | } 12 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/module2/Module2Service.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.module2; 2 | 3 | import android.support.v4.app.Fragment; 4 | 5 | import com.github.io.liweijie.base.moduleinterface.provider.IModule2Provider; 6 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 7 | import com.github.io.liweijie.base.moduleinterface.router.ServiceManager; 8 | 9 | /** 10 | * 作者:黎伟杰-子然 on 2017/4/13. 11 | * 邮箱:liweijie@linghit.com 12 | * description: 13 | * update by: 14 | * update day: 15 | */ 16 | public class Module2Service { 17 | private static boolean hasModule2() { 18 | return ModuleManager.getInstance().hasModule(IModule2Provider.MODULE2_MAIN_SERVICE); 19 | } 20 | 21 | public static Fragment getModule2Fragment(Object... args) { 22 | if (!hasModule2()) return null; 23 | return ServiceManager.getInstance().getModule2Provider().newInstance(args); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/module3/Module3Intent.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.module3; 2 | 3 | /** 4 | * 作者:黎伟杰-子然 on 2017/4/13. 5 | * 邮箱:liweijie@linghit.com 6 | * description: 7 | * update by: 8 | * update day: 9 | */ 10 | public class Module3Intent { 11 | } 12 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/module3/Module3Service.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.module3; 2 | 3 | import android.support.v4.app.Fragment; 4 | 5 | import com.github.io.liweijie.base.moduleinterface.provider.IModule3Provider; 6 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 7 | import com.github.io.liweijie.base.moduleinterface.router.ServiceManager; 8 | 9 | /** 10 | * 作者:黎伟杰-子然 on 2017/4/13. 11 | * 邮箱:liweijie@linghit.com 12 | * description: 13 | * update by: 14 | * update day: 15 | */ 16 | public class Module3Service { 17 | 18 | private static boolean hasModule3() { 19 | return ModuleManager.getInstance().hasModule(IModule3Provider.MODULE3_MAIN_SERVICE); 20 | } 21 | 22 | public static Fragment getModule2Fragment(Object... args) { 23 | if (!hasModule3()) return null; 24 | return ServiceManager.getInstance().getModule3Provider().newInstance(args); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/module4/Module4Intent.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.module4; 2 | 3 | import android.app.Activity; 4 | 5 | import com.github.io.liweijie.base.moduleinterface.config.MyBundle; 6 | import com.github.io.liweijie.base.moduleinterface.provider.IModule4Provider; 7 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 8 | import com.github.io.liweijie.base.moduleinterface.router.MyRouter; 9 | 10 | import java.io.Serializable; 11 | 12 | /** 13 | * 作者:黎伟杰-子然 on 2017/4/13. 14 | * 邮箱:liweijie@linghit.com 15 | * description: 16 | * update by: 17 | * update day: 18 | */ 19 | public class Module4Intent { 20 | 21 | private static boolean hasModule4() { 22 | return ModuleManager.getInstance().hasModule(IModule4Provider.MODULE4_MAIN_SERVICE); 23 | } 24 | 25 | public static void launchModule4(Activity activity, int requestCode, Serializable data) { 26 | if (!hasModule4()) return; 27 | MyBundle bundle = new MyBundle(); 28 | bundle.put("data", data); 29 | MyRouter.newInstance(IModule4Provider.MODULE4_ACT_MAIN) 30 | .withBundle(bundle) 31 | .navigation(activity, requestCode); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/module4/Module4Service.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.module4; 2 | 3 | import com.github.io.liweijie.base.moduleinterface.provider.IModule4Provider; 4 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 5 | 6 | /** 7 | * 作者:黎伟杰-子然 on 2017/4/13. 8 | * 邮箱:liweijie@linghit.com 9 | * description: 10 | * update by: 11 | * update day: 12 | */ 13 | public class Module4Service { 14 | private boolean hasModule1() { 15 | return ModuleManager.getInstance().hasModule(IModule4Provider.MODULE4_MAIN_SERVICE); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/module5/Module5Intent.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.module5; 2 | 3 | import com.github.io.liweijie.base.moduleinterface.config.MyBundle; 4 | import com.github.io.liweijie.base.moduleinterface.provider.IModule5Provider; 5 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 6 | import com.github.io.liweijie.base.moduleinterface.router.MyRouter; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 作者:黎伟杰-子然 on 2017/4/13. 12 | * 邮箱:liweijie@linghit.com 13 | * description: 14 | * update by: 15 | * update day: 16 | */ 17 | public class Module5Intent { 18 | private static boolean hasModule5() { 19 | return ModuleManager.getInstance().hasModule(IModule5Provider.MODULE5_MAIN_SERVICE); 20 | } 21 | 22 | public static void launchModule5(Serializable data) { 23 | if (!hasModule5()) return; 24 | MyBundle bundle = new MyBundle(); 25 | bundle.put("data", data); 26 | MyRouter.newInstance(IModule5Provider.MODULE5_ACT_MAIN) 27 | .withBundle(bundle) 28 | .navigation(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/module/module5/Module5Service.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.module.module5; 2 | 3 | import com.github.io.liweijie.base.moduleinterface.provider.IModule5Provider; 4 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 5 | 6 | /** 7 | * 作者:黎伟杰-子然 on 2017/4/13. 8 | * 邮箱:liweijie@linghit.com 9 | * description: 10 | * update by: 11 | * update day: 12 | */ 13 | public class Module5Service { 14 | private boolean hasModule1() { 15 | return ModuleManager.getInstance().hasModule(IModule5Provider.MODULE5_MAIN_SERVICE); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/provider/IAppProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.provider; 2 | 3 | /** 4 | * 作者:黎伟杰-子然 on 2017/4/16. 5 | * 邮箱:liweijie@linghit.com 6 | * description: 7 | * update by: 8 | * update day: 9 | */ 10 | public interface IAppProvider extends IBaseProvider{ 11 | String APP_MAIN_SERVICE = "/app/main/service"; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/provider/IBaseProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.provider; 2 | 3 | import com.alibaba.android.arouter.facade.template.IProvider; 4 | 5 | /** 6 | * 作者:黎伟杰-子然 on 2017/4/16. 7 | * 邮箱:liweijie@linghit.com 8 | * description: 9 | * update by: 10 | * update day: 11 | */ 12 | interface IBaseProvider extends IProvider{ 13 | 14 | } 15 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/provider/IFragmentProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.provider; 2 | 3 | import android.support.v4.app.Fragment; 4 | 5 | /** 6 | * 作者:黎伟杰-子然 on 2017/4/13. 7 | * 邮箱:liweijie@linghit.com 8 | * description: 9 | * update by: 10 | * update day: 11 | */ 12 | public interface IFragmentProvider extends IBaseProvider { 13 | 14 | Fragment newInstance(Object... args); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/provider/IHomeProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.provider; 2 | 3 | import android.app.Activity; 4 | 5 | /** 6 | * 作者:黎伟杰-子然 on 2017/4/16. 7 | * 邮箱:liweijie@linghit.com 8 | * description: 9 | * update by: 10 | * update day: 11 | */ 12 | public interface IHomeProvider extends IBaseProvider { 13 | //Service 14 | String HOME_MAIN_SERVICE = "/home/main/service"; 15 | //开屏 16 | String HOME_ACT_SPLASH = "/home/act/splash"; 17 | //home主页 18 | String HOME_ACT_HOME = "/home/act/home"; 19 | String HOME_TABTYPE = "home_tab_type"; 20 | 21 | void toast(String msg); 22 | 23 | void selectedTab(Activity activity,int position); 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/provider/IModule1Provider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.provider; 2 | 3 | /** 4 | * 作者:黎伟杰-子然 on 2017/4/16. 5 | * 邮箱:liweijie@linghit.com 6 | * description: 7 | * update by: 8 | * update day: 9 | */ 10 | public interface IModule1Provider extends IFragmentProvider { 11 | //服务 12 | String MODULE1_MAIN_SERVICE = "/module1/main/service"; 13 | //作为Fragment被添加时候的key 14 | String MODULE1_KEY_FRAGMENT = "module1_key_fragment"; 15 | } 16 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/provider/IModule2Provider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.provider; 2 | 3 | /** 4 | * 作者:黎伟杰-子然 on 2017/4/16. 5 | * 邮箱:liweijie@linghit.com 6 | * description: 7 | * update by: 8 | * update day: 9 | */ 10 | public interface IModule2Provider extends IFragmentProvider{ 11 | //服务 12 | String MODULE2_MAIN_SERVICE = "/module2/main/service"; 13 | //作为Fragment被添加时候的key 14 | String MODULE2_KEY_FRAGMENT = "module2_key_fragment"; 15 | } 16 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/provider/IModule3Provider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.provider; 2 | 3 | /** 4 | * 作者:黎伟杰-子然 on 2017/4/16. 5 | * 邮箱:liweijie@linghit.com 6 | * description: 7 | * update by: 8 | * update day: 9 | */ 10 | public interface IModule3Provider extends IFragmentProvider{ 11 | //服务 12 | String MODULE3_MAIN_SERVICE = "/module3/main/service"; 13 | //作为Fragment被添加时候的key 14 | String MODULE3_KEY_FRAGMENT = "module3_key_fragment"; 15 | } 16 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/provider/IModule4Provider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.provider; 2 | 3 | /** 4 | * 作者:黎伟杰-子然 on 2017/4/16. 5 | * 邮箱:liweijie@linghit.com 6 | * description: 7 | * update by: 8 | * update day: 9 | */ 10 | public interface IModule4Provider extends IFragmentProvider{ 11 | String MODULE4_MAIN_SERVICE = "/module4/main/service"; 12 | String MODULE4_ACT_MAIN = "/module4/act/main"; 13 | } 14 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/provider/IModule5Provider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.provider; 2 | 3 | /** 4 | * 作者:黎伟杰-子然 on 2017/4/16. 5 | * 邮箱:liweijie@linghit.com 6 | * description: 7 | * update by: 8 | * update day: 9 | */ 10 | public interface IModule5Provider extends IFragmentProvider{ 11 | String MODULE5_MAIN_SERVICE = "/module5/main/service"; 12 | String MODULE5_ACT_MAIN = "/module5/act/main"; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/router/ModuleManager.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.router; 2 | 3 | 4 | import com.github.io.liweijie.base.moduleinterface.config.ModuleOptions; 5 | 6 | /** 7 | * 作者:黎伟杰-子然 on 2017/4/13. 8 | * 邮箱:liweijie@linghit.com 9 | * description: 10 | * update by: 11 | * update day: 12 | */ 13 | public class ModuleManager { 14 | 15 | private ModuleOptions options; 16 | 17 | private ModuleManager() { 18 | } 19 | 20 | private static class ModuleManagerHolder { 21 | private static final ModuleManager instance = new ModuleManager(); 22 | } 23 | 24 | public static ModuleManager getInstance() { 25 | return ModuleManagerHolder.instance; 26 | 27 | } 28 | 29 | public void init(ModuleOptions options) { 30 | if (this.options == null && options != null) { 31 | this.options = options; 32 | } 33 | } 34 | 35 | public ModuleOptions getOptions() { 36 | return options; 37 | } 38 | 39 | public boolean hasModule(String key) { 40 | return options.hasModule(key); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/router/MyRouter.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.router; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | 6 | import com.alibaba.android.arouter.facade.Postcard; 7 | import com.alibaba.android.arouter.facade.callback.NavigationCallback; 8 | import com.alibaba.android.arouter.launcher.ARouter; 9 | import com.github.io.liweijie.base.moduleinterface.config.MyBundle; 10 | 11 | /** 12 | * 作者:黎伟杰-子然 on 2017/4/16. 13 | * 邮箱:liweijie@linghit.com 14 | * description: 15 | * update by: 16 | * update day: 17 | */ 18 | public class MyRouter { 19 | 20 | private Postcard postcard; 21 | 22 | private MyRouter(Postcard postcard) { 23 | this.postcard = postcard; 24 | } 25 | 26 | public static MyRouter newInstance(String path) { 27 | return new MyRouter(ARouter.getInstance().build(path)); 28 | } 29 | 30 | private boolean checkPostcard() { 31 | if (postcard == null) 32 | throw new IllegalArgumentException("MyRouter 的 postcard 为null"); 33 | return true; 34 | } 35 | 36 | 37 | public MyRouter withBundle(MyBundle bundle) { 38 | if (bundle == null) return this; 39 | checkPostcard(); 40 | postcard.with(bundle.build()); 41 | return this; 42 | } 43 | 44 | public MyRouter addFlag(int flag) { 45 | checkPostcard(); 46 | postcard.withFlags(flag); 47 | return this; 48 | } 49 | 50 | public Object navigation() { 51 | return navigation(null); 52 | } 53 | 54 | public Object navigation(Context context) { 55 | return navigation(context, null); 56 | } 57 | 58 | public void navigation(Activity activity, int requestCode) { 59 | navigation(activity, requestCode, null); 60 | } 61 | 62 | public Object navigation(Context context, NavigationCallback callback) { 63 | checkPostcard(); 64 | return postcard.navigation(context, callback); 65 | } 66 | 67 | 68 | public void navigation(Activity activity, int requestCode, NavigationCallback callback) { 69 | postcard.navigation(activity, requestCode, callback); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/moduleinterface/router/ServiceManager.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.moduleinterface.router; 2 | 3 | import com.alibaba.android.arouter.facade.annotation.Autowired; 4 | import com.alibaba.android.arouter.launcher.ARouter; 5 | import com.github.io.liweijie.base.moduleinterface.provider.IAppProvider; 6 | import com.github.io.liweijie.base.moduleinterface.provider.IHomeProvider; 7 | import com.github.io.liweijie.base.moduleinterface.provider.IModule1Provider; 8 | import com.github.io.liweijie.base.moduleinterface.provider.IModule2Provider; 9 | import com.github.io.liweijie.base.moduleinterface.provider.IModule3Provider; 10 | 11 | /** 12 | * 作者:黎伟杰-子然 on 2017/4/13. 13 | * 邮箱:liweijie@linghit.com 14 | * description:注意,这不是一个完全的单例模式,不能私有化构造器以及属性 15 | * update by: 16 | * update day: 17 | */ 18 | public class ServiceManager { 19 | //服务注入看自己的具体实现 20 | //自动注入 21 | @Autowired 22 | IHomeProvider homeProvider; 23 | //可以不使用@Autowired,手动发现服务 24 | IModule1Provider module1Provider; 25 | IModule2Provider module2Provider; 26 | IModule3Provider module3Provider; 27 | 28 | 29 | public ServiceManager() { 30 | ARouter.getInstance().inject(this); 31 | 32 | } 33 | 34 | private static final class ServiceManagerHolder { 35 | private static final ServiceManager instance = new ServiceManager(); 36 | } 37 | 38 | public static ServiceManager getInstance() { 39 | return ServiceManagerHolder.instance; 40 | } 41 | 42 | /** 43 | * @return 44 | */ 45 | public IHomeProvider getHomeProvider() { 46 | return homeProvider; 47 | } 48 | 49 | 50 | public IModule1Provider getModule1Provider() { 51 | return module1Provider != null ? module1Provider : (module1Provider = ((IModule1Provider) MyRouter.newInstance(IModule1Provider.MODULE1_MAIN_SERVICE).navigation())); 52 | } 53 | 54 | public IModule2Provider getModule2Provider() { 55 | return module2Provider != null ? module2Provider : (module2Provider = ((IModule2Provider) MyRouter.newInstance(IModule2Provider.MODULE2_MAIN_SERVICE).navigation())); 56 | } 57 | 58 | public IModule3Provider getModule3Provider() { 59 | return module3Provider != null ? module3Provider : (module3Provider = ((IModule3Provider) MyRouter.newInstance(IModule3Provider.MODULE3_MAIN_SERVICE).navigation())); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/util/LG.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.util; 2 | 3 | import android.util.Log; 4 | 5 | /** 6 | * 作者:黎伟杰-子然 on 2017/4/17. 7 | * 邮箱:liweijie@linghit.com 8 | * description: 9 | * update by: 10 | * update day: 11 | */ 12 | public class LG { 13 | 14 | public static boolean isDebug = false; 15 | 16 | private static final String DETAULT_TAG = "---Module Sample Log>>>"; 17 | 18 | public static void d(String msg) { 19 | d(DETAULT_TAG, msg); 20 | } 21 | 22 | private static void d(String tag, String msg) { 23 | Log.i(tag, msg); 24 | } 25 | 26 | public static void e(String msg) { 27 | e(DETAULT_TAG, msg); 28 | } 29 | 30 | private static void e(String tag, String msg) { 31 | Log.e(tag, msg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/util/Util.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.util; 2 | 3 | import android.text.TextUtils; 4 | 5 | /** 6 | * 作者:黎伟杰-子然 on 2017/4/13. 7 | * 邮箱:liweijie@linghit.com 8 | * description: 9 | * update by: 10 | * update day: 11 | */ 12 | public class Util { 13 | public static boolean isNull(String... args) { 14 | if (args == null) return true; 15 | for (String item : args) { 16 | if (TextUtils.isEmpty(item)) return true; 17 | } 18 | return false; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/view/BaseRecyclerView.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.view; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.util.AttributeSet; 7 | 8 | /** 9 | * 作者:黎伟杰-子然 on 2017/3/20. 10 | * 邮箱:liweijie@linghit.com 11 | * description: 12 | * update by: 13 | * update day: 14 | */ 15 | public class BaseRecyclerView extends RecyclerView{ 16 | public BaseRecyclerView(Context context) { 17 | super(context); 18 | } 19 | 20 | public BaseRecyclerView(Context context, @Nullable AttributeSet attrs) { 21 | super(context, attrs); 22 | } 23 | 24 | public BaseRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) { 25 | super(context, attrs, defStyle); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/view/adapter/BaseAdapter.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.view.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.ViewGroup; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 作者:黎伟杰-子然 on 2017/4/13. 10 | * 邮箱:liweijie@linghit.com 11 | * description: 12 | * update by: 13 | * update day: 14 | */ 15 | public abstract class BaseAdapter extends RecyclerView.Adapter { 16 | 17 | private List mDatas; 18 | 19 | public BaseAdapter(List mDatas) { 20 | this.mDatas = mDatas; 21 | } 22 | 23 | @Override 24 | public V onCreateViewHolder(ViewGroup parent, int viewType) { 25 | return getHolder(parent, viewType); 26 | } 27 | 28 | protected abstract V getHolder(ViewGroup parent, int viewType); 29 | 30 | @Override 31 | public int getItemCount() { 32 | return mDatas == null ? 0 : mDatas.size(); 33 | } 34 | 35 | @Override 36 | public void onBindViewHolder(V holder, int position) { 37 | holder.init(this.mDatas.get(position)); 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /base/src/main/java/com/github/io/liweijie/base/view/adapter/VH.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.base.view.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.IdRes; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.View; 7 | 8 | /** 9 | * 作者:黎伟杰-子然 on 2017/4/13. 10 | * 邮箱:liweijie@linghit.com 11 | * description: 12 | * update by: 13 | * update day: 14 | */ 15 | public abstract class VH extends RecyclerView.ViewHolder { 16 | 17 | private Context context; 18 | private T data; 19 | 20 | public VH(View itemView) { 21 | super(itemView); 22 | context = itemView.getContext(); 23 | } 24 | 25 | protected void init(T data) { 26 | this.data = data; 27 | setData(data); 28 | } 29 | 30 | protected abstract void setData(T data); 31 | 32 | protected V findvViewById(@IdRes int id) { 33 | return (V) itemView.findViewById(id); 34 | } 35 | 36 | protected T getData() { 37 | return data; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /base/src/main/res/layout/fragment_core_recycler_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /base/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /base/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /base/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Base 3 | 4 | -------------------------------------------------------------------------------- /base/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | apply from: "config.gradle" 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /config.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | android = [ 3 | compileSdkVersion : 23, 4 | buildToolsVersion : "23.0.3", 5 | minSdkVersion : 15, 6 | targetSdkVersion : 23, 7 | androidSupportSdkVersion: "23.4.0", 8 | ] 9 | 10 | dependencies = [ 11 | arouterapi : 'com.alibaba:arouter-api:1.2.1', 12 | aroutercompiler: 'com.alibaba:arouter-compiler:1.1.2', 13 | supportdesign : 'com.android.support:design:23.4.0', 14 | recyclerviewv7 : 'com.android.support:recyclerview-v7:23.4.0', 15 | supportv4 : 'com.android.support:support-v4:23.4.0', 16 | appcompatv7 : 'com.android.support:appcompat-v7:23.4.0', 17 | //分包 18 | multidex : 'com.android.support:multidex:1.0.1', 19 | ] 20 | //home是否是作为模块,true的时候是,false的时候可以独立运行,不想改了ORZ 21 | isMouleDebugHome = true; 22 | //module1是否是作为模块,true的时候是,false的时候可以独立运行 23 | isModule1Debug = true; 24 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /home/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /home/build.gradle: -------------------------------------------------------------------------------- 1 | if (rootProject.ext.isMouleDebugHome) { 2 | apply plugin: 'com.android.library' 3 | } else { 4 | apply plugin: 'com.android.application' 5 | } 6 | android { 7 | compileSdkVersion rootProject.ext.android.compileSdkVersion 8 | buildToolsVersion rootProject.ext.android.buildToolsVersion 9 | 10 | defaultConfig { 11 | minSdkVersion rootProject.ext.android.minSdkVersion 12 | targetSdkVersion rootProject.ext.android.targetSdkVersion 13 | versionCode 101 14 | versionName "1.0.1" 15 | if (!rootProject.ext.isMouleDebugHome) { 16 | applicationId "com.github.io.liweijie.home" 17 | } 18 | 19 | javaCompileOptions { 20 | annotationProcessorOptions { 21 | arguments = [moduleName: project.getName()] 22 | } 23 | } 24 | } 25 | 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_1_7 28 | targetCompatibility JavaVersion.VERSION_1_7 29 | } 30 | 31 | 32 | buildTypes { 33 | release { 34 | minifyEnabled false 35 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 36 | } 37 | 38 | } 39 | 40 | sourceSets { 41 | main { 42 | if (!rootProject.ext.isMouleDebugHome) { 43 | manifest.srcFile 'src/debug/AndroidManifest.xml' 44 | java.srcDir 'src/debug/java/' 45 | } else { 46 | manifest.srcFile 'src/release/AndroidManifest.xml' 47 | java.srcDir 'src/release/java/' 48 | } 49 | 50 | } 51 | } 52 | } 53 | dependencies { 54 | compile fileTree(dir: 'libs', include: ['*.jar']) 55 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 56 | exclude group: 'com.android.support', module: 'support-annotations' 57 | }) 58 | compile project(':base') 59 | testCompile 'junit:junit:4.12' 60 | annotationProcessor rootProject.ext.dependencies["aroutercompiler"] 61 | } -------------------------------------------------------------------------------- /home/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/liweijie/Library/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 | -------------------------------------------------------------------------------- /home/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /home/src/debug/java/com/github/io/liweijie/home/debug/HomeDebugApplication.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.home.debug; 2 | 3 | import com.alibaba.android.arouter.launcher.ARouter; 4 | import com.github.io.liweijie.base.BaseApplication; 5 | import com.github.io.liweijie.base.moduleinterface.config.ModuleOptions; 6 | import com.github.io.liweijie.base.moduleinterface.provider.IHomeProvider; 7 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 8 | import com.github.io.liweijie.base.util.LG; 9 | 10 | /** 11 | * 作者:黎伟杰-子然 on 2017/4/19. 12 | * 邮箱:liweijie@linghit.com 13 | * description: 14 | * update by: 15 | * update day: 16 | */ 17 | public class HomeDebugApplication extends BaseApplication { 18 | @Override 19 | public void onCreate() { 20 | super.onCreate(); 21 | initARouter(); 22 | } 23 | private void initARouter() { 24 | if (LG.isDebug) { 25 | ARouter.openLog(); 26 | ARouter.openDebug(); 27 | ARouter.printStackTrace(); 28 | } 29 | ARouter.init(this); 30 | ModuleOptions.ModuleBuilder builder = new ModuleOptions.ModuleBuilder(this) 31 | .addModule(IHomeProvider.HOME_MAIN_SERVICE, IHomeProvider.HOME_MAIN_SERVICE); 32 | ModuleManager.getInstance().init(builder.build()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /home/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /home/src/main/java/com/github/io/liweijie/home/HomeActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.home; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.app.FragmentTransaction; 7 | import android.view.View; 8 | import android.widget.Toast; 9 | 10 | import com.alibaba.android.arouter.facade.annotation.Route; 11 | import com.github.io.liweijie.base.BaseActivity; 12 | import com.github.io.liweijie.base.dao.UserInfo; 13 | import com.github.io.liweijie.base.moduleinterface.module.module1.Module1Service; 14 | import com.github.io.liweijie.base.moduleinterface.module.module2.Module2Service; 15 | import com.github.io.liweijie.base.moduleinterface.module.module3.Module3Service; 16 | import com.github.io.liweijie.base.moduleinterface.module.module5.Module5Intent; 17 | import com.github.io.liweijie.base.moduleinterface.provider.IHomeProvider; 18 | import com.github.io.liweijie.base.moduleinterface.provider.IModule1Provider; 19 | import com.github.io.liweijie.base.moduleinterface.provider.IModule2Provider; 20 | import com.github.io.liweijie.base.moduleinterface.provider.IModule3Provider; 21 | import com.github.io.liweijie.base.moduleinterface.provider.IModule5Provider; 22 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 23 | import com.github.io.liweijie.base.util.LG; 24 | 25 | import java.util.HashMap; 26 | import java.util.Map; 27 | 28 | @Route(path = IHomeProvider.HOME_ACT_HOME) 29 | public class HomeActivity extends BaseActivity { 30 | 31 | private int currentPosition = -1; 32 | private Map mFragments; 33 | 34 | @Override 35 | public void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | setContentView(R.layout.activity_home); 38 | mFragments = new HashMap<>(); 39 | selectedTab(getIntent().getIntExtra(IHomeProvider.HOME_TABTYPE, 0)); 40 | } 41 | 42 | 43 | public void onClickTab(View view) { 44 | int id = view.getId(); 45 | if (id == R.id.home_tab_module1) { 46 | selectedTab(0); 47 | } else if (id == R.id.home_tab_module2) { 48 | selectedTab(1); 49 | } else if (id == R.id.home_tab_module3) { 50 | selectedTab(2); 51 | } 52 | } 53 | 54 | public void selectedTab(int position) { 55 | if (currentPosition == position) 56 | return; 57 | switch (position) { 58 | case 0: 59 | selectFragment(IModule1Provider.MODULE1_KEY_FRAGMENT); 60 | break; 61 | case 1: 62 | selectFragment(IModule2Provider.MODULE2_KEY_FRAGMENT); 63 | break; 64 | case 2: 65 | // 66 | if (ModuleManager.getInstance().hasModule(IModule3Provider.MODULE3_MAIN_SERVICE)) { 67 | selectFragment(IModule3Provider.MODULE3_KEY_FRAGMENT); 68 | } else if (ModuleManager.getInstance().hasModule(IModule5Provider.MODULE5_MAIN_SERVICE)) { 69 | Module5Intent.launchModule5(new UserInfo("王五", 18)); 70 | } 71 | break; 72 | } 73 | currentPosition = position; 74 | } 75 | 76 | private void selectFragment(String key) { 77 | Fragment fragment; 78 | fragment = mFragments.get(key); 79 | String msg; 80 | FragmentTransaction beginTransaction = getSupportFragmentManager().beginTransaction(); 81 | hideFragment(beginTransaction); 82 | if (fragment == null) { 83 | if (IModule1Provider.MODULE1_KEY_FRAGMENT.equals(key)) { 84 | fragment = Module1Service.getModule1Frgment(); 85 | msg = "module1模块"; 86 | } else if (IModule2Provider.MODULE2_KEY_FRAGMENT.equals(key)) { 87 | fragment = Module2Service.getModule2Fragment(); 88 | msg = "modul2模块"; 89 | } else if (IModule3Provider.MODULE3_KEY_FRAGMENT.equals(key)) { 90 | fragment = Module3Service.getModule2Fragment(); 91 | msg = "module3模块"; 92 | } else { 93 | return; 94 | } 95 | if (fragment == null) { 96 | if (LG.isDebug) { 97 | Toast.makeText(this, "没有" + msg, Toast.LENGTH_SHORT).show(); 98 | } 99 | beginTransaction.commit(); 100 | return; 101 | } 102 | mFragments.put(key, fragment); 103 | beginTransaction.add(R.id.home_content_fragment, fragment); 104 | } else { 105 | beginTransaction.show(fragment); 106 | } 107 | beginTransaction.commit(); 108 | } 109 | 110 | private void hideFragment(FragmentTransaction beginTransaction) { 111 | for (Map.Entry item : mFragments.entrySet()) { 112 | beginTransaction.hide(item.getValue()); 113 | } 114 | } 115 | 116 | //一般而言需要这样子传递,Activity不涉及到具体逻辑处理,除非是全局性的 117 | @Override 118 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 119 | super.onActivityResult(requestCode, resultCode, data); 120 | for (Map.Entry item : mFragments.entrySet()) { 121 | Fragment fragment = item.getValue(); 122 | fragment.onActivityResult(requestCode, resultCode, data); 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /home/src/main/java/com/github/io/liweijie/home/HomeProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.home; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.widget.Toast; 6 | 7 | import com.alibaba.android.arouter.facade.annotation.Route; 8 | import com.github.io.liweijie.base.moduleinterface.provider.IHomeProvider; 9 | 10 | /** 11 | * 作者:黎伟杰-子然 on 2017/4/16. 12 | * 邮箱:liweijie@linghit.com 13 | * description: 14 | * update by: 15 | * update day: 16 | */ 17 | @Route(path = IHomeProvider.HOME_MAIN_SERVICE) 18 | public class HomeProvider implements IHomeProvider { 19 | private Context context; 20 | 21 | @Override 22 | public void init(Context context) { 23 | this.context = context; 24 | } 25 | 26 | @Override 27 | public void toast(String msg) { 28 | Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); 29 | } 30 | 31 | @Override 32 | public void selectedTab(Activity activity,int position) { 33 | if (activity instanceof HomeActivity) { 34 | ((HomeActivity) activity).selectedTab(position); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /home/src/main/java/com/github/io/liweijie/home/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.home; 2 | 3 | import android.os.Handler; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | 7 | import com.alibaba.android.arouter.facade.annotation.Route; 8 | import com.github.io.liweijie.base.moduleinterface.module.home.HomeIntent; 9 | import com.github.io.liweijie.base.moduleinterface.provider.IHomeProvider; 10 | 11 | @Route(path = IHomeProvider.HOME_ACT_SPLASH) 12 | public class SplashActivity extends AppCompatActivity { 13 | 14 | private Handler mHandler; 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_splash); 20 | mHandler = new Handler(getMainLooper()); 21 | } 22 | 23 | @Override 24 | protected void onResume() { 25 | super.onResume(); 26 | mHandler.postDelayed(new Runnable() { 27 | @Override 28 | public void run() { 29 | HomeIntent.launchHome(2); 30 | finish(); 31 | } 32 | }, 1500); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /home/src/main/res/drawable-xhdpi/home_splash_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liweijieok/ModularSample/61f52d5102d7715518847ffa2599fc1edeccb386/home/src/main/res/drawable-xhdpi/home_splash_bg.jpg -------------------------------------------------------------------------------- /home/src/main/res/layout/activity_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 24 | 25 | 34 | 35 | 44 | 45 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /home/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /home/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /home/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /home/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Home 3 | 4 | -------------------------------------------------------------------------------- /home/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | -------------------------------------------------------------------------------- /home/src/release/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /modulelib1/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /modulelib1/build.gradle: -------------------------------------------------------------------------------- 1 | if (rootProject.ext.isModule1Debug) { 2 | apply plugin: 'com.android.library' 3 | } else { 4 | apply plugin: 'com.android.application' 5 | } 6 | 7 | android { 8 | compileSdkVersion rootProject.ext.android.compileSdkVersion 9 | buildToolsVersion rootProject.ext.android.buildToolsVersion 10 | 11 | defaultConfig { 12 | minSdkVersion rootProject.ext.android.minSdkVersion 13 | targetSdkVersion rootProject.ext.android.targetSdkVersion 14 | versionCode 101 15 | versionName "1.0.1" 16 | if (!rootProject.ext.isModule1Debug) { 17 | applicationId "com.github.io.liweijie.lib1" 18 | } 19 | javaCompileOptions { 20 | annotationProcessorOptions { 21 | arguments = [moduleName: project.getName()] 22 | } 23 | } 24 | } 25 | 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_1_7 28 | targetCompatibility JavaVersion.VERSION_1_7 29 | } 30 | 31 | 32 | buildTypes { 33 | release { 34 | minifyEnabled false 35 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 36 | } 37 | 38 | } 39 | 40 | sourceSets { 41 | main { 42 | if (!rootProject.ext.isModule1Debug) { 43 | manifest.srcFile 'src/debug/AndroidManifest.xml' 44 | java.srcDir 'src/debug/java/' 45 | res.srcDirs=['src/debug/res'] 46 | } else { 47 | manifest.srcFile 'src/release/AndroidManifest.xml' 48 | java.srcDir 'src/release/java/' 49 | } 50 | 51 | } 52 | } 53 | } 54 | dependencies { 55 | compile fileTree(dir: 'libs', include: ['*.jar']) 56 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 57 | exclude group: 'com.android.support', module: 'support-annotations' 58 | }) 59 | compile project(':base') 60 | testCompile 'junit:junit:4.12' 61 | annotationProcessor rootProject.ext.dependencies["aroutercompiler"] 62 | } -------------------------------------------------------------------------------- /modulelib1/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/liweijie/Library/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 | -------------------------------------------------------------------------------- /modulelib1/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /modulelib1/src/debug/java/com/github/io/liweijie/lib1/debug/Module1DebugApplication.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.lib1.debug; 2 | 3 | import com.alibaba.android.arouter.launcher.ARouter; 4 | import com.github.io.liweijie.base.BaseApplication; 5 | import com.github.io.liweijie.base.moduleinterface.config.ModuleOptions; 6 | import com.github.io.liweijie.base.moduleinterface.provider.IHomeProvider; 7 | import com.github.io.liweijie.base.moduleinterface.provider.IModule1Provider; 8 | import com.github.io.liweijie.base.moduleinterface.router.ModuleManager; 9 | import com.github.io.liweijie.base.util.LG; 10 | 11 | /** 12 | * 作者:黎伟杰-子然 on 2017/4/19. 13 | * 邮箱:liweijie@linghit.com 14 | * description: 15 | * update by: 16 | * update day: 17 | */ 18 | public class Module1DebugApplication extends BaseApplication { 19 | @Override 20 | public void onCreate() { 21 | super.onCreate(); 22 | initARouter(); 23 | } 24 | 25 | private void initARouter() { 26 | if (LG.isDebug) { 27 | ARouter.openLog(); 28 | ARouter.openDebug(); 29 | ARouter.printStackTrace(); 30 | } 31 | ARouter.init(this); 32 | ModuleOptions.ModuleBuilder builder = new ModuleOptions.ModuleBuilder(this) 33 | .addModule(IHomeProvider.HOME_MAIN_SERVICE, IHomeProvider.HOME_MAIN_SERVICE) 34 | .addModule(IModule1Provider.MODULE1_MAIN_SERVICE, IModule1Provider.MODULE1_MAIN_SERVICE); 35 | ModuleManager.getInstance().init(builder.build()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /modulelib1/src/debug/java/com/github/io/liweijie/lib1/debug/activity/Module1DebugActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.lib1.debug.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | 6 | import com.github.io.liweijie.base.BaseActivity; 7 | import com.github.io.liweijie.base.moduleinterface.module.module1.Module1Service; 8 | import com.github.io.liweijie.lib1.R; 9 | 10 | /** 11 | * 作者:黎伟杰-子然 on 2017/4/19. 12 | * 邮箱:liweijie@linghit.com 13 | * description: 14 | * update by: 15 | * update day: 16 | */ 17 | public class Module1DebugActivity extends BaseActivity { 18 | @Override 19 | public void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.module1_debug_activity); 22 | Fragment module1 = Module1Service.getModule1Frgment(); 23 | getSupportFragmentManager().beginTransaction().add(R.id.moddule1_debug_content, module1) 24 | .commitAllowingStateLoss(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /modulelib1/src/debug/res/layout/module1_debug_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | -------------------------------------------------------------------------------- /modulelib1/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /modulelib1/src/main/java/com/github/io/liweijie/lib1/Module1Fragment.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.lib1; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.github.io.liweijie.base.BaseRecyclerFragment; 11 | import com.github.io.liweijie.lib1.adapter.Module1Adapter; 12 | import com.github.io.liweijie.lib1.bean.Books; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | /** 18 | * 作者:黎伟杰-子然 on 2017/4/16. 19 | * 邮箱:liweijie@linghit.com 20 | * description: 21 | * update by: 22 | * update day: 23 | */ 24 | public class Module1Fragment extends BaseRecyclerFragment { 25 | 26 | public static Module1Fragment newInstance(Object... args) { 27 | return new Module1Fragment(); 28 | } 29 | 30 | @Override 31 | public View getContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 32 | return inflater.inflate(R.layout.module1_fragment_main, container,false); 33 | } 34 | 35 | 36 | @Override 37 | protected RecyclerView.Adapter getAdapter() { 38 | return new Module1Adapter(initTestData()); 39 | } 40 | 41 | private List initTestData() { 42 | List mDatas = new ArrayList<>(); 43 | mDatas.add(new Books("书名A", "作者A")); 44 | mDatas.add(new Books("书名B", "作者B")); 45 | mDatas.add(new Books("书名C", "作者C")); 46 | mDatas.add(new Books("书名D", "作者D")); 47 | mDatas.add(new Books("书名E", "作者E")); 48 | mDatas.add(new Books("书名F", "作者F")); 49 | mDatas.add(new Books("书名G", "作者G")); 50 | mDatas.add(new Books("书名H", "作者H")); 51 | mDatas.add(new Books("书名I", "作者I")); 52 | mDatas.add(new Books("书名J", "作者J")); 53 | mDatas.add(new Books("书名K", "作者K")); 54 | return mDatas; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /modulelib1/src/main/java/com/github/io/liweijie/lib1/Mudule1Provider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.lib1; 2 | 3 | import android.content.Context; 4 | import android.support.v4.app.Fragment; 5 | 6 | import com.alibaba.android.arouter.facade.annotation.Route; 7 | import com.github.io.liweijie.base.moduleinterface.provider.IModule1Provider; 8 | 9 | import static com.github.io.liweijie.base.moduleinterface.provider.IModule1Provider.MODULE1_MAIN_SERVICE; 10 | 11 | /** 12 | * 作者:黎伟杰-子然 on 2017/4/16. 13 | * 邮箱:liweijie@linghit.com 14 | * description: 15 | * update by: 16 | * update day: 17 | */ 18 | @Route(path = MODULE1_MAIN_SERVICE) 19 | public class Mudule1Provider implements IModule1Provider { 20 | 21 | @Override 22 | public Fragment newInstance(Object... args) { 23 | return Module1Fragment.newInstance(args); 24 | } 25 | 26 | @Override 27 | public void init(Context context) { 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /modulelib1/src/main/java/com/github/io/liweijie/lib1/adapter/Module1Adapter.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.lib1.adapter; 2 | 3 | import android.view.LayoutInflater; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.TextView; 7 | 8 | import com.github.io.liweijie.base.view.adapter.BaseAdapter; 9 | import com.github.io.liweijie.base.view.adapter.VH; 10 | import com.github.io.liweijie.lib1.R; 11 | import com.github.io.liweijie.lib1.bean.Books; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * 作者:黎伟杰-子然 on 2017/4/17. 17 | * 邮箱:liweijie@linghit.com 18 | * description: 19 | * update by: 20 | * update day: 21 | */ 22 | public class Module1Adapter extends BaseAdapter { 23 | 24 | public Module1Adapter(List mDatas) { 25 | super(mDatas); 26 | } 27 | 28 | @Override 29 | protected Module1Holder getHolder(ViewGroup parent, int viewType) { 30 | return new Module1Holder(LayoutInflater.from(parent.getContext()).inflate(R.layout.module1_fragment_main_item, parent, false)); 31 | } 32 | 33 | class Module1Holder extends VH { 34 | 35 | private TextView name; 36 | private TextView author; 37 | 38 | public Module1Holder(View itemView) { 39 | super(itemView); 40 | name = findvViewById(R.id.module1_fragment_main_item_name); 41 | author = findvViewById(R.id.module1_fragment_main_item_author); 42 | } 43 | 44 | @Override 45 | protected void setData(Books data) { 46 | name.setText(data.getName()); 47 | author.setText(data.getAuthor()); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /modulelib1/src/main/java/com/github/io/liweijie/lib1/bean/Books.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.lib1.bean; 2 | 3 | /** 4 | * 作者:黎伟杰-子然 on 2017/4/17. 5 | * 邮箱:liweijie@linghit.com 6 | * description: 7 | * update by: 8 | * update day: 9 | */ 10 | public class Books { 11 | private String name; 12 | private String author; 13 | 14 | public Books() { 15 | } 16 | 17 | public Books(String name, String author) { 18 | this.name = name; 19 | this.author = author; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public String getAuthor() { 31 | return author; 32 | } 33 | 34 | public void setAuthor(String author) { 35 | this.author = author; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /modulelib1/src/main/res/layout/module1_fragment_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 17 | -------------------------------------------------------------------------------- /modulelib1/src/main/res/layout/module1_fragment_main_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 22 | -------------------------------------------------------------------------------- /modulelib1/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ModuleLib1 3 | 4 | -------------------------------------------------------------------------------- /modulelib1/src/release/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /modulelib2/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /modulelib2/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android.compileSdkVersion 5 | buildToolsVersion rootProject.ext.android.buildToolsVersion 6 | 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.android.minSdkVersion 9 | targetSdkVersion rootProject.ext.android.targetSdkVersion 10 | versionCode 101 11 | versionName "1.0.1" 12 | 13 | javaCompileOptions { 14 | annotationProcessorOptions { 15 | arguments = [moduleName: project.getName()] 16 | } 17 | } 18 | } 19 | 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_1_7 22 | targetCompatibility JavaVersion.VERSION_1_7 23 | } 24 | 25 | 26 | buildTypes { 27 | release { 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | } 31 | 32 | } 33 | 34 | dependencies { 35 | compile fileTree(dir: 'libs', include: ['*.jar']) 36 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 37 | exclude group: 'com.android.support', module: 'support-annotations' 38 | }) 39 | compile project(':base') 40 | testCompile 'junit:junit:4.12' 41 | annotationProcessor rootProject.ext.dependencies["aroutercompiler"] 42 | } 43 | } -------------------------------------------------------------------------------- /modulelib2/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/liweijie/Library/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 | -------------------------------------------------------------------------------- /modulelib2/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /modulelib2/src/main/java/com/github/io/liweijie/lib2/Module2Fragment.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.lib2; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.TextView; 10 | 11 | import com.github.io.liweijie.base.BaseFragment; 12 | import com.github.io.liweijie.base.dao.UserInfo; 13 | import com.github.io.liweijie.base.moduleinterface.module.module4.Module4Intent; 14 | 15 | /** 16 | * 作者:黎伟杰-子然 on 2017/3/26. 17 | * 邮箱:liweijie@linghit.com 18 | * description: 19 | * update by: 20 | * update day: 21 | */ 22 | public class Module2Fragment extends BaseFragment { 23 | 24 | private TextView name; 25 | private TextView age; 26 | private static final int REQUEST_CODE = 0x100; 27 | 28 | public static Module2Fragment newInstance(Object... args) { 29 | return new Module2Fragment(); 30 | } 31 | 32 | @Override 33 | public View getContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 34 | return inflater.inflate(R.layout.module2_fragment_main, null); 35 | } 36 | 37 | @Override 38 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 39 | super.onViewCreated(view, savedInstanceState); 40 | name = findViewById(R.id.module4_fragment_main_name); 41 | age = findViewById(R.id.module4_fragment_main_age); 42 | final UserInfo userInfo = new UserInfo(); 43 | userInfo.setAge(16); 44 | userInfo.setName("张三"); 45 | findViewById(R.id.module4_fragment_main_btn).setOnClickListener(new View.OnClickListener() { 46 | @Override 47 | public void onClick(View v) { 48 | Module4Intent.launchModule4(getActivity(), REQUEST_CODE, userInfo); 49 | } 50 | }); 51 | } 52 | 53 | @Override 54 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 55 | super.onActivityResult(requestCode, resultCode, data); 56 | if (requestCode == REQUEST_CODE && data != null) { 57 | UserInfo info = (UserInfo) data.getSerializableExtra("data"); 58 | name.setText(info.getName()); 59 | age.setText(info.getAge()+""); 60 | 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /modulelib2/src/main/java/com/github/io/liweijie/lib2/Module2Provider.java: -------------------------------------------------------------------------------- 1 | package com.github.io.liweijie.lib2; 2 | 3 | import android.content.Context; 4 | import android.support.v4.app.Fragment; 5 | 6 | import com.alibaba.android.arouter.facade.annotation.Route; 7 | import com.github.io.liweijie.base.moduleinterface.provider.IModule2Provider; 8 | 9 | import static com.github.io.liweijie.base.moduleinterface.provider.IModule2Provider.MODULE2_MAIN_SERVICE; 10 | 11 | /** 12 | * 作者:黎伟杰-子然 on 2017/4/17. 13 | * 邮箱:liweijie@linghit.com 14 | * description: 15 | * update by: 16 | * update day: 17 | */ 18 | @Route(path = MODULE2_MAIN_SERVICE) 19 | public class Module2Provider implements IModule2Provider { 20 | @Override 21 | public Fragment newInstance(Object... args) { 22 | return Module2Fragment.newInstance(args); 23 | } 24 | 25 | @Override 26 | public void init(Context context) { 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /modulelib2/src/main/res/layout/module2_fragment_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 |