├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── tenz │ │ └── tenzmoduledemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── tenz │ │ │ └── tenzmoduledemo │ │ │ └── app │ │ │ └── AppApplication.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── tenz │ └── tenzmoduledemo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── modulelib ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── tenz │ │ └── modulelib │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── tenz │ │ │ └── modulelib │ │ │ ├── base │ │ │ ├── BaseActivity.java │ │ │ ├── BaseApplication.java │ │ │ └── BaseFragment.java │ │ │ └── util │ │ │ └── ToastUtil.java │ └── res │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── tenz │ └── modulelib │ └── ExampleUnitTest.java ├── modulemain ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── tenz │ │ └── modulemain │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── tenz │ │ │ └── modulemain │ │ │ └── activity │ │ │ ├── MainActivity.java │ │ │ └── ShowFragmentActivity.java │ ├── module │ │ └── AndroidManifest.xml │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── activity_show_fragment.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── tenz │ └── modulemain │ └── ExampleUnitTest.java ├── moduleone ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── tenz │ │ └── moduleone │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── tenz │ │ │ └── moduleone │ │ │ ├── activity │ │ │ └── ModuleOneMainActivity.java │ │ │ └── fragment │ │ │ └── ModuleOneShowFragment.java │ ├── module │ │ └── AndroidManifest.xml │ └── res │ │ ├── layout │ │ ├── activity_module_one_main.xml │ │ └── fragment_module_one_show.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── tenz │ └── moduleone │ └── ExampleUnitTest.java ├── moduletwo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── tenz │ │ └── moduletwo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── tenz │ │ │ └── moduletwo │ │ │ ├── activity │ │ │ └── ModuleTwoMainActivity.java │ │ │ └── fragment │ │ │ └── ModuleTwoShowFragment.java │ ├── module │ │ └── AndroidManifest.xml │ └── res │ │ ├── layout │ │ ├── activity_module_two_main.xml │ │ └── fragment_module_two_show.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── tenz │ └── moduletwo │ └── ExampleUnitTest.java └── 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TenzModuleDemo 2 | android组件化demo 3 | 4 | 项目简书地址:https://www.jianshu.com/p/416ca689ebc2 5 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.tenz.tenzmoduledemo" 7 | minSdkVersion 15 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | buildscript { 20 | repositories { 21 | jcenter() 22 | } 23 | } 24 | allprojects { 25 | repositories { 26 | jcenter() 27 | } 28 | } 29 | } 30 | 31 | dependencies { 32 | implementation fileTree(include: ['*.jar'], dir: 'libs') 33 | 34 | implementation project(':modulelib') 35 | if (!isModule.toBoolean()) { 36 | implementation project(':modulemain') 37 | implementation project(':moduleone') 38 | implementation project(':moduletwo') 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/tenz/tenzmoduledemo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.tenz.tenzmoduledemo; 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 | * Instrumented 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.tenz.tenzmoduledemo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/tenz/tenzmoduledemo/app/AppApplication.java: -------------------------------------------------------------------------------- 1 | package com.tenz.tenzmoduledemo.app; 2 | 3 | import com.tenz.modulelib.base.BaseApplication; 4 | 5 | /** 6 | * Author: TenzLiu 7 | * Time: 2018/7/4 16:05 8 | * Desc: 9 | */ 10 | 11 | public class AppApplication extends BaseApplication { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TenzModuleDemo 3 | 4 | -------------------------------------------------------------------------------- /app/src/test/java/com/tenz/tenzmoduledemo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.tenz.tenzmoduledemo; 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 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | mavenCentral() 7 | google() 8 | jcenter() 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.0.1' 12 | classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1' 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | google() 22 | jcenter() 23 | } 24 | } 25 | 26 | task clean(type: Delete) { 27 | delete rootProject.buildDir 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TenzLiu/TenzModuleDemo/2a652a900a65a2d2f08a516511d56744db1e32bb/gradle.properties -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TenzLiu/TenzModuleDemo/2a652a900a65a2d2f08a516511d56744db1e32bb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jul 05 10:52:27 CST 2018 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-4.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 | -------------------------------------------------------------------------------- /modulelib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /modulelib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 26 5 | 6 | 7 | 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion 26 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | buildscript { 26 | repositories { 27 | jcenter() 28 | mavenCentral() 29 | } 30 | } 31 | allprojects { 32 | repositories { 33 | jcenter() 34 | } 35 | } 36 | 37 | } 38 | 39 | dependencies { 40 | implementation fileTree(dir: 'libs', include: ['*.jar']) 41 | 42 | testImplementation 'junit:junit:4.12' 43 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 44 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 45 | 46 | //Support libraries 47 | api 'com.android.support:appcompat-v7:26.1.0' 48 | 49 | //ARouter 50 | api 'com.alibaba:arouter-api:1.3.1' 51 | 52 | //butterknife 53 | api 'com.jakewharton:butterknife:8.5.1' 54 | } 55 | -------------------------------------------------------------------------------- /modulelib/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /modulelib/src/androidTest/java/com/tenz/modulelib/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.tenz.modulelib; 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 | * Instrumented 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.tenz.modulelib.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /modulelib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /modulelib/src/main/java/com/tenz/modulelib/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.tenz.modulelib.base; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v7.app.AppCompatActivity; 7 | 8 | import butterknife.ButterKnife; 9 | import butterknife.Unbinder; 10 | 11 | /** 12 | * Author: TenzLiu 13 | * Time: 2018/7/5 14:04 14 | * Desc: 15 | */ 16 | 17 | public abstract class BaseActivity extends AppCompatActivity { 18 | 19 | /** 20 | * 上下文对象 21 | */ 22 | protected Context mContext; 23 | /** 24 | * ButterKnife 25 | */ 26 | private Unbinder mUnbinder; 27 | 28 | @Override 29 | protected void onCreate(@Nullable Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | init(savedInstanceState); 32 | } 33 | 34 | /** 35 | * 36 | * @param savedInstanceState 37 | */ 38 | private void init(Bundle savedInstanceState){ 39 | //加载布局 40 | setContentView(getLayoutId()); 41 | //注册butterknife 42 | mUnbinder = ButterKnife.bind(this); 43 | mContext = this; 44 | initView(savedInstanceState); 45 | initData(); 46 | } 47 | 48 | /** 49 | * 获取当前layouty的布局ID,用于设置当前布局 50 | * 交由子类实现 51 | * @return 52 | */ 53 | protected abstract int getLayoutId(); 54 | 55 | /** 56 | * 初始化view 57 | * 子类实现 控件绑定、视图初始化等内容 58 | * @param savedInstanceState 59 | */ 60 | protected void initView(Bundle savedInstanceState) { 61 | } 62 | 63 | /** 64 | * 初始化数据 65 | * 子类可以复写此方法初始化子类数据 66 | */ 67 | protected void initData() { 68 | } 69 | 70 | @Override 71 | protected void onDestroy() { 72 | super.onDestroy(); 73 | mUnbinder.unbind(); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /modulelib/src/main/java/com/tenz/modulelib/base/BaseApplication.java: -------------------------------------------------------------------------------- 1 | package com.tenz.modulelib.base; 2 | 3 | import android.app.Application; 4 | 5 | import com.alibaba.android.arouter.launcher.ARouter; 6 | 7 | /** 8 | * Author: TenzLiu 9 | * Time: 2018/7/5 14:33 10 | * Desc: 11 | */ 12 | 13 | public class BaseApplication extends Application { 14 | 15 | private boolean isDebug = true; 16 | 17 | @Override 18 | public void onCreate() { 19 | super.onCreate(); 20 | if(isDebug){ 21 | ARouter.openLog(); 22 | ARouter.openDebug(); 23 | } 24 | ARouter.init(this); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /modulelib/src/main/java/com/tenz/modulelib/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.tenz.modulelib.base; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.support.v4.app.Fragment; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | 12 | import butterknife.ButterKnife; 13 | import butterknife.Unbinder; 14 | 15 | /** 16 | * Author: TenzLiu 17 | * Time: 2018/7/5 16:42 18 | * Desc: 19 | */ 20 | 21 | public abstract class BaseFragment extends Fragment { 22 | 23 | /** 24 | * 上下文对象 25 | */ 26 | protected Context mContext; 27 | /** 28 | * 所属activity 29 | */ 30 | protected Activity mActivity; 31 | /** 32 | * ButterKnife 33 | */ 34 | private Unbinder mUnbinder; 35 | 36 | @Nullable 37 | @Override 38 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, 39 | @Nullable Bundle savedInstanceState) { 40 | //加载布局 41 | View view = inflater.inflate(getLayoutId(),container,false); 42 | return view; 43 | } 44 | 45 | @Override 46 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 47 | //注册butterknife 48 | mUnbinder = ButterKnife.bind(this,view); 49 | mContext = getContext(); 50 | mActivity = (Activity) getContext(); 51 | initView(view,savedInstanceState); 52 | initData(); 53 | } 54 | 55 | /** 56 | * 获取当前layouty的布局ID,用于设置当前布局 57 | * 交由子类实现 58 | * @return 59 | */ 60 | protected abstract int getLayoutId(); 61 | 62 | /** 63 | * 初始化view 64 | * 子类实现 控件绑定、视图初始化等内容 65 | * @param savedInstanceState 66 | */ 67 | protected void initView(View view, Bundle savedInstanceState) { 68 | } 69 | 70 | /** 71 | * 初始化数据 72 | * 子类可以复写此方法初始化子类数据 73 | */ 74 | protected void initData() { 75 | } 76 | 77 | @Override 78 | public void onDestroyView() { 79 | super.onDestroyView(); 80 | mUnbinder.unbind(); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /modulelib/src/main/java/com/tenz/modulelib/util/ToastUtil.java: -------------------------------------------------------------------------------- 1 | package com.tenz.modulelib.util; 2 | 3 | import android.content.Context; 4 | import android.widget.Toast; 5 | 6 | /** 7 | * Author: TenzLiu 8 | * Time: 2018/7/4 11:05 9 | * Desc: 10 | */ 11 | 12 | public class ToastUtil { 13 | 14 | public static void showToast(Context context, String message){ 15 | Toast.makeText(context,message,Toast.LENGTH_SHORT).show(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /modulelib/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TenzLiu/TenzModuleDemo/2a652a900a65a2d2f08a516511d56744db1e32bb/modulelib/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /modulelib/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TenzLiu/TenzModuleDemo/2a652a900a65a2d2f08a516511d56744db1e32bb/modulelib/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /modulelib/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TenzLiu/TenzModuleDemo/2a652a900a65a2d2f08a516511d56744db1e32bb/modulelib/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /modulelib/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TenzLiu/TenzModuleDemo/2a652a900a65a2d2f08a516511d56744db1e32bb/modulelib/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /modulelib/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /modulelib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ModuleLib 3 | 4 | -------------------------------------------------------------------------------- /modulelib/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /modulelib/src/test/java/com/tenz/modulelib/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.tenz.modulelib; 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 | } -------------------------------------------------------------------------------- /modulemain/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /modulemain/build.gradle: -------------------------------------------------------------------------------- 1 | if(isModule.toBoolean()){ 2 | apply plugin: 'com.android.application' 3 | }else{ 4 | apply plugin: 'com.android.library' 5 | } 6 | //应用butterknife插件 7 | apply plugin: 'com.jakewharton.butterknife' 8 | 9 | android { 10 | compileSdkVersion 26 11 | 12 | 13 | 14 | defaultConfig { 15 | minSdkVersion 15 16 | targetSdkVersion 26 17 | versionCode 1 18 | versionName "1.0" 19 | 20 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 21 | 22 | javaCompileOptions { 23 | annotationProcessorOptions { 24 | arguments = [ moduleName : project.getName() ] 25 | } 26 | } 27 | 28 | } 29 | 30 | sourceSets { 31 | main { 32 | if(isModule.toBoolean()){ 33 | manifest.srcFile 'src/main/module/AndroidManifest.xml' 34 | }else{ 35 | manifest.srcFile 'src/main/AndroidManifest.xml' 36 | //集成开发模式下排除debug文件夹中的所有Java文件 37 | java { 38 | exclude 'debug/**' 39 | } 40 | } 41 | } 42 | } 43 | 44 | buildTypes { 45 | release { 46 | minifyEnabled false 47 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 48 | } 49 | } 50 | 51 | buildscript { 52 | repositories { 53 | jcenter() 54 | } 55 | } 56 | allprojects { 57 | repositories { 58 | jcenter() 59 | } 60 | } 61 | 62 | } 63 | 64 | dependencies { 65 | implementation fileTree(dir: 'libs', include: ['*.jar']) 66 | 67 | implementation project(':modulelib') 68 | //ARouter 69 | annotationProcessor 'com.alibaba:arouter-compiler:1.1.4' 70 | //butterknife 71 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 72 | } 73 | -------------------------------------------------------------------------------- /modulemain/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /modulemain/src/androidTest/java/com/tenz/modulemain/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.tenz.modulemain; 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 | * Instrumented 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.tenz.modulemain.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /modulemain/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /modulemain/src/main/java/com/tenz/modulemain/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.tenz.modulemain.activity; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | 7 | import com.alibaba.android.arouter.launcher.ARouter; 8 | import com.tenz.modulelib.base.BaseActivity; 9 | import com.tenz.modulemain.R; 10 | import com.tenz.modulemain.R2; 11 | 12 | import butterknife.OnClick; 13 | 14 | /** 15 | * Author: TenzLiu 16 | * Time: 2018/7/4 10:19 17 | * Desc: 18 | */ 19 | 20 | public class MainActivity extends BaseActivity { 21 | 22 | @Override 23 | protected int getLayoutId() { 24 | return R.layout.activity_main; 25 | } 26 | 27 | @Override 28 | protected void initView(Bundle savedInstanceState) { 29 | super.initView(savedInstanceState); 30 | 31 | } 32 | 33 | @Override 34 | protected void initData() { 35 | super.initData(); 36 | 37 | } 38 | 39 | @OnClick({R2.id.tv_module_one,R2.id.tv_module_two,R2.id.tv_module_fragment}) 40 | public void onClick(View view){ 41 | if(view.getId() == R.id.tv_module_one){ 42 | // 1. 应用内简单的activity跳转 43 | ARouter.getInstance().build("/moduleone/main") 44 | .navigation(); 45 | }else if(view.getId() == R.id.tv_module_two){ 46 | // 2. 应用内简带参数的activity跳转 47 | ARouter.getInstance().build("/moduletwo/main") 48 | .withString("name","TenzLiu") 49 | .navigation(); 50 | }else if(view.getId() == R.id.tv_module_fragment){ 51 | // 3. 应用内fragment的获取 52 | Intent intent = new Intent(this,ShowFragmentActivity.class); 53 | startActivity(intent); 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /modulemain/src/main/java/com/tenz/modulemain/activity/ShowFragmentActivity.java: -------------------------------------------------------------------------------- 1 | package com.tenz.modulemain.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v4.app.FragmentTransaction; 6 | import android.view.View; 7 | 8 | import com.alibaba.android.arouter.launcher.ARouter; 9 | import com.tenz.modulelib.base.BaseActivity; 10 | import com.tenz.modulelib.util.ToastUtil; 11 | import com.tenz.modulemain.R; 12 | import com.tenz.modulemain.R2; 13 | 14 | import butterknife.OnClick; 15 | 16 | /** 17 | * Author: TenzLiu 18 | * Time: 2018/7/5 17:06 19 | * Desc: 20 | */ 21 | 22 | public class ShowFragmentActivity extends BaseActivity { 23 | 24 | private Fragment fragmentModuleOneShow; 25 | private Fragment fragmentMmoduleTwoShow; 26 | 27 | @Override 28 | protected int getLayoutId() { 29 | return R.layout.activity_show_fragment; 30 | } 31 | 32 | @Override 33 | protected void initView(Bundle savedInstanceState) { 34 | super.initView(savedInstanceState); 35 | fragmentModuleOneShow = (Fragment) ARouter.getInstance() 36 | .build("/moduleone/showfragment") 37 | .navigation(); 38 | fragmentMmoduleTwoShow = (Fragment) ARouter.getInstance() 39 | .build("/moduletwo/showfragment") 40 | .navigation(); 41 | } 42 | 43 | @Override 44 | protected void initData() { 45 | super.initData(); 46 | FragmentTransaction beginTransaction = getSupportFragmentManager().beginTransaction(); 47 | beginTransaction.add(R.id.fl_fragment,fragmentModuleOneShow); 48 | beginTransaction.add(R.id.fl_fragment,fragmentMmoduleTwoShow); 49 | beginTransaction.show(fragmentModuleOneShow).hide(fragmentMmoduleTwoShow).commit(); 50 | } 51 | 52 | @OnClick({R2.id.tv_moduleone_fragment,R2.id.tv_moduletwo_fragment}) 53 | public void onClick(View view){ 54 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); 55 | if(view.getId() == R.id.tv_moduleone_fragment){ 56 | fragmentTransaction.show(fragmentModuleOneShow).hide(fragmentMmoduleTwoShow).commit(); 57 | }else if(view.getId() == R.id.tv_moduletwo_fragment){ 58 | fragmentTransaction.show(fragmentMmoduleTwoShow).hide(fragmentModuleOneShow).commit(); 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /modulemain/src/main/module/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /modulemain/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 22 | 23 | 30 | 31 | -------------------------------------------------------------------------------- /modulemain/src/main/res/layout/activity_show_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 17 | 24 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /modulemain/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /modulemain/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ModuleMain 3 | 4 | -------------------------------------------------------------------------------- /modulemain/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /modulemain/src/test/java/com/tenz/modulemain/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.tenz.modulemain; 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 | } -------------------------------------------------------------------------------- /moduleone/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /moduleone/build.gradle: -------------------------------------------------------------------------------- 1 | if(isModule.toBoolean()){ 2 | apply plugin: 'com.android.application' 3 | }else{ 4 | apply plugin: 'com.android.library' 5 | } 6 | //应用butterknife插件 7 | apply plugin: 'com.jakewharton.butterknife' 8 | 9 | android { 10 | compileSdkVersion 26 11 | 12 | 13 | 14 | defaultConfig { 15 | minSdkVersion 15 16 | targetSdkVersion 26 17 | versionCode 1 18 | versionName "1.0" 19 | 20 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 21 | 22 | javaCompileOptions { 23 | annotationProcessorOptions { 24 | arguments = [ moduleName : project.getName() ] 25 | } 26 | } 27 | 28 | } 29 | 30 | sourceSets { 31 | main { 32 | if(isModule.toBoolean()){ 33 | manifest.srcFile 'src/main/module/AndroidManifest.xml' 34 | }else{ 35 | manifest.srcFile 'src/main/AndroidManifest.xml' 36 | //集成开发模式下排除debug文件夹中的所有Java文件 37 | java { 38 | exclude 'debug/**' 39 | } 40 | } 41 | } 42 | } 43 | 44 | buildTypes { 45 | release { 46 | minifyEnabled false 47 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 48 | } 49 | } 50 | 51 | buildscript { 52 | repositories { 53 | jcenter() 54 | } 55 | } 56 | allprojects { 57 | repositories { 58 | jcenter() 59 | } 60 | } 61 | 62 | } 63 | 64 | dependencies { 65 | implementation fileTree(dir: 'libs', include: ['*.jar']) 66 | 67 | implementation project(':modulelib') 68 | //ARouter 69 | annotationProcessor 'com.alibaba:arouter-compiler:1.1.4' 70 | //butterknife 71 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 72 | } 73 | -------------------------------------------------------------------------------- /moduleone/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /moduleone/src/androidTest/java/com/tenz/moduleone/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.tenz.moduleone; 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 | * Instrumented 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.tenz.moduleone.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /moduleone/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /moduleone/src/main/java/com/tenz/moduleone/activity/ModuleOneMainActivity.java: -------------------------------------------------------------------------------- 1 | package com.tenz.moduleone.activity; 2 | 3 | import com.alibaba.android.arouter.facade.annotation.Route; 4 | import com.tenz.modulelib.base.BaseActivity; 5 | import com.tenz.moduleone.R; 6 | 7 | /** 8 | * Author: TenzLiu 9 | * Time: 2018/7/4 15:06 10 | * Desc: 11 | */ 12 | 13 | @Route(path = "/moduleone/main") 14 | public class ModuleOneMainActivity extends BaseActivity { 15 | 16 | @Override 17 | protected int getLayoutId() { 18 | return R.layout.activity_module_one_main; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /moduleone/src/main/java/com/tenz/moduleone/fragment/ModuleOneShowFragment.java: -------------------------------------------------------------------------------- 1 | package com.tenz.moduleone.fragment; 2 | 3 | import com.alibaba.android.arouter.facade.annotation.Route; 4 | import com.tenz.modulelib.base.BaseFragment; 5 | import com.tenz.moduleone.R; 6 | 7 | /** 8 | * Author: TenzLiu 9 | * Time: 2018/7/5 17:16 10 | * Desc: 11 | */ 12 | 13 | @Route(path = "/moduleone/showfragment") 14 | public class ModuleOneShowFragment extends BaseFragment { 15 | 16 | @Override 17 | protected int getLayoutId() { 18 | return R.layout.fragment_module_one_show; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /moduleone/src/main/module/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /moduleone/src/main/res/layout/activity_module_one_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /moduleone/src/main/res/layout/fragment_module_one_show.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /moduleone/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ModuleOne 3 | 4 | -------------------------------------------------------------------------------- /moduleone/src/test/java/com/tenz/moduleone/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.tenz.moduleone; 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 | } -------------------------------------------------------------------------------- /moduletwo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /moduletwo/build.gradle: -------------------------------------------------------------------------------- 1 | if(isModule.toBoolean()){ 2 | apply plugin: 'com.android.application' 3 | }else{ 4 | apply plugin: 'com.android.library' 5 | } 6 | //应用butterknife插件 7 | apply plugin: 'com.jakewharton.butterknife' 8 | 9 | android { 10 | compileSdkVersion 26 11 | 12 | 13 | 14 | defaultConfig { 15 | minSdkVersion 15 16 | targetSdkVersion 26 17 | versionCode 1 18 | versionName "1.0" 19 | 20 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 21 | 22 | javaCompileOptions { 23 | annotationProcessorOptions { 24 | arguments = [ moduleName : project.getName() ] 25 | } 26 | } 27 | 28 | } 29 | 30 | sourceSets { 31 | main { 32 | if(isModule.toBoolean()){ 33 | manifest.srcFile 'src/main/module/AndroidManifest.xml' 34 | }else{ 35 | manifest.srcFile 'src/main/AndroidManifest.xml' 36 | //集成开发模式下排除debug文件夹中的所有Java文件 37 | java { 38 | exclude 'debug/**' 39 | } 40 | } 41 | } 42 | } 43 | 44 | buildTypes { 45 | release { 46 | minifyEnabled false 47 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 48 | } 49 | } 50 | 51 | buildscript { 52 | repositories { 53 | jcenter() 54 | } 55 | } 56 | allprojects { 57 | repositories { 58 | jcenter() 59 | } 60 | } 61 | 62 | } 63 | 64 | dependencies { 65 | implementation fileTree(dir: 'libs', include: ['*.jar']) 66 | 67 | implementation project(':modulelib') 68 | //ARouter 69 | annotationProcessor 'com.alibaba:arouter-compiler:1.1.4' 70 | //butterknife 71 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 72 | } 73 | -------------------------------------------------------------------------------- /moduletwo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /moduletwo/src/androidTest/java/com/tenz/moduletwo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.tenz.moduletwo; 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 | * Instrumented 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.tenz.moduletwo.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /moduletwo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /moduletwo/src/main/java/com/tenz/moduletwo/activity/ModuleTwoMainActivity.java: -------------------------------------------------------------------------------- 1 | package com.tenz.moduletwo.activity; 2 | 3 | import android.os.Bundle; 4 | import android.widget.TextView; 5 | 6 | import com.alibaba.android.arouter.facade.annotation.Autowired; 7 | import com.alibaba.android.arouter.facade.annotation.Route; 8 | import com.alibaba.android.arouter.launcher.ARouter; 9 | import com.tenz.modulelib.base.BaseActivity; 10 | import com.tenz.modulelib.util.ToastUtil; 11 | import com.tenz.moduletwo.R; 12 | import com.tenz.moduletwo.R2; 13 | 14 | import butterknife.BindView; 15 | 16 | /** 17 | * Author: TenzLiu 18 | * Time: 2018/7/4 15:24 19 | * Desc: 20 | */ 21 | 22 | @Route(path = "/moduletwo/main") 23 | public class ModuleTwoMainActivity extends BaseActivity { 24 | 25 | @BindView(R2.id.tv_parameter) 26 | TextView tv_parameter; 27 | 28 | @Autowired 29 | String name; 30 | 31 | @Override 32 | protected int getLayoutId() { 33 | return R.layout.activity_module_two_main; 34 | } 35 | 36 | @Override 37 | protected void initView(Bundle savedInstanceState) { 38 | super.initView(savedInstanceState); 39 | ARouter.getInstance().inject(this); 40 | } 41 | 42 | @Override 43 | protected void initData() { 44 | super.initData(); 45 | tv_parameter.setText("我是接收到的参数name:"+name); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /moduletwo/src/main/java/com/tenz/moduletwo/fragment/ModuleTwoShowFragment.java: -------------------------------------------------------------------------------- 1 | package com.tenz.moduletwo.fragment; 2 | 3 | import com.alibaba.android.arouter.facade.annotation.Route; 4 | import com.tenz.modulelib.base.BaseFragment; 5 | import com.tenz.moduletwo.R; 6 | 7 | /** 8 | * Author: TenzLiu 9 | * Time: 2018/7/5 17:16 10 | * Desc: 11 | */ 12 | 13 | @Route(path = "/moduletwo/showfragment") 14 | public class ModuleTwoShowFragment extends BaseFragment { 15 | 16 | @Override 17 | protected int getLayoutId() { 18 | return R.layout.fragment_module_two_show; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /moduletwo/src/main/module/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /moduletwo/src/main/res/layout/activity_module_two_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /moduletwo/src/main/res/layout/fragment_module_two_show.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /moduletwo/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ModuleTwo 3 | 4 | -------------------------------------------------------------------------------- /moduletwo/src/test/java/com/tenz/moduletwo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.tenz.moduletwo; 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 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':modulelib', ':modulemain', ':moduleone', ':moduletwo' 2 | --------------------------------------------------------------------------------