├── .gitignore
├── .idea
├── caches
│ └── build_file_checksums.ser
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── res
│ ├── drawable
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── baselibrary
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── arouter
│ │ └── baselibrary
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── arouter
│ │ │ └── baselibrary
│ │ │ ├── DegradeServiceImpl.java
│ │ │ ├── IUserInfo.java
│ │ │ ├── MyApplication.java
│ │ │ ├── RoutePath.java
│ │ │ ├── activity
│ │ │ ├── AuthTipActivity.java
│ │ │ └── DegradeTipActivity.java
│ │ │ ├── base
│ │ │ ├── BaseActivity.java
│ │ │ └── BaseFragment.java
│ │ │ └── interceptor
│ │ │ └── AuthInterceptor.java
│ └── res
│ │ ├── layout
│ │ ├── activity_auth_tip.xml
│ │ └── activity_degrade_tip.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── arouter
│ └── baselibrary
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── module_home
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── arouter
│ │ └── module_home
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── buildApp
│ │ └── AndroidManifest.xml
│ ├── buildModule
│ │ └── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── arouter
│ │ │ └── module_home
│ │ │ ├── HomeActivity.java
│ │ │ └── HomeFragment.java
│ └── res
│ │ ├── drawable
│ │ └── ic_launcher_round.png
│ │ ├── layout
│ │ └── activity_home.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── arouter
│ └── module_home
│ └── ExampleUnitTest.java
├── module_main
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── buildApp
│ └── AndroidManifest.xml
│ ├── buildModule
│ └── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── arouter
│ │ └── module_main
│ │ ├── LoginActivity.java
│ │ ├── MainActivity.java
│ │ ├── SplashActivity.java
│ │ └── TabSpec.java
│ └── res
│ ├── color
│ └── selector_tab_text.xml
│ ├── drawable-hdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_round.png
│ └── splash.jpg
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable-xhdpi
│ ├── ic_home_black.png
│ ├── ic_home_red.png
│ ├── ic_launcher.png
│ ├── ic_launcher_round.png
│ ├── ic_mine_black.png
│ ├── ic_mine_red.png
│ ├── ic_video_black.png
│ └── ic_video_red.png
│ ├── drawable
│ ├── ic_launcher_background.xml
│ └── selector_tab_text.xml
│ ├── layout
│ ├── activity_login.xml
│ ├── activity_main.xml
│ ├── activity_splash.xml
│ └── tabcontent.xml
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── module_mine
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── arouter
│ │ └── module_mine
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── buildApp
│ │ └── AndroidManifest.xml
│ ├── buildModule
│ │ └── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── arouter
│ │ │ └── module_mine
│ │ │ ├── MineFragment.java
│ │ │ └── UserInfoImpl.java
│ └── res
│ │ ├── drawable
│ │ └── ic_launcher_round.png
│ │ ├── layout
│ │ └── activity_mine.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── arouter
│ └── module_mine
│ └── ExampleUnitTest.java
├── module_route
├── .gitignore
├── build.gradle
└── src
│ └── main
│ └── java
│ └── com
│ └── aroute
│ └── module_route
│ ├── HomeRoutePath.java
│ ├── MainRoutePath.java
│ ├── MineRoutePath.java
│ └── VideoRoutePath.java
├── module_video
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── arouter
│ │ └── module_video
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── buildApp
│ │ └── AndroidManifest.xml
│ ├── buildModule
│ │ └── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── arouter
│ │ │ └── module_video
│ │ │ ├── VideoActivity.java
│ │ │ └── VideoFragment.java
│ └── res
│ │ ├── drawable
│ │ └── ic_launcher_round.png
│ │ ├── layout
│ │ └── activity_video.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── arouter
│ └── module_video
│ └── 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 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
23 |
24 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AppModuleDemo
2 | Module通讯采用阿里ARouter
3 |
4 | Android 模块化开发
5 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 | defaultConfig {
6 | applicationId "com.arouter.arouterdemo"
7 | minSdkVersion 21
8 | targetSdkVersion 27
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | javaCompileOptions {
13 | annotationProcessorOptions {
14 | arguments = [AROUTER_MODULE_NAME: project.getName()]
15 | }
16 | }
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 |
27 |
28 |
29 | dependencies {
30 |
31 | if (!isModule.toBoolean()) {
32 | implementation project(':module_home')
33 | implementation project(':module_video')
34 | implementation project(':module_main')
35 | implementation project(':module_mine')
36 | implementation project(':module_route')
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/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/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/app/src/main/res/drawable/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Arouter
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/baselibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/baselibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 27
5 |
6 | defaultConfig {
7 | minSdkVersion 19
8 | targetSdkVersion 27
9 | versionCode 1
10 | versionName "1.0"
11 |
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | javaCompileOptions {
14 | annotationProcessorOptions {
15 | arguments = [AROUTER_MODULE_NAME: project.getName()]
16 | }
17 | }
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 |
31 | implementation fileTree(include: ['*.jar'], dir: 'libs')
32 | implementation 'com.android.support:appcompat-v7:27.1.1'
33 | implementation 'com.android.support:design:27.1.1'
34 | testImplementation 'junit:junit:4.12'
35 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
36 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
37 | compile 'com.android.support:support-v4:27.1.1'
38 | compile 'com.alibaba:arouter-api:1.4.1'
39 | annotationProcessor 'com.alibaba:arouter-compiler:1.2.2'
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/baselibrary/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 |
--------------------------------------------------------------------------------
/baselibrary/src/androidTest/java/com/arouter/baselibrary/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.arouter.baselibrary;
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.arouter.baselibrary.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/baselibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/baselibrary/src/main/java/com/arouter/baselibrary/DegradeServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.arouter.baselibrary;
2 |
3 | import android.content.Context;
4 |
5 | import com.alibaba.android.arouter.facade.Postcard;
6 | import com.alibaba.android.arouter.facade.annotation.Route;
7 | import com.alibaba.android.arouter.facade.service.DegradeService;
8 | import com.alibaba.android.arouter.launcher.ARouter;
9 |
10 | /**
11 | *
12 | * 要用ARouter跳转才能拦截到,用Intent隐式或显示跳转无法拦截,出错还是会crash
13 | */
14 | @Route(path = RoutePath.DEGRADE)
15 | public class DegradeServiceImpl implements DegradeService {
16 | @Override
17 | public void onLost(Context context, Postcard postcard) {
18 | ARouter.getInstance().build(RoutePath.DEGRADE_TIP).greenChannel().navigation();
19 | }
20 |
21 | @Override
22 | public void init(Context context) {
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/baselibrary/src/main/java/com/arouter/baselibrary/IUserInfo.java:
--------------------------------------------------------------------------------
1 | package com.arouter.baselibrary;
2 |
3 | import com.alibaba.android.arouter.facade.template.IProvider;
4 |
5 | /**
6 | * 服务管理: 用于模块之间进行数据的传递,例如:首页模块没依赖我的模块,但是需要获取我的模块的数据,就是用这个
7 | */
8 | public interface IUserInfo extends IProvider {
9 | String getName();
10 | }
11 |
--------------------------------------------------------------------------------
/baselibrary/src/main/java/com/arouter/baselibrary/MyApplication.java:
--------------------------------------------------------------------------------
1 | package com.arouter.baselibrary;
2 |
3 | import android.app.Application;
4 |
5 | import com.alibaba.android.arouter.launcher.ARouter;
6 |
7 | /**
8 | * Application
9 | */
10 | public class MyApplication extends Application {
11 |
12 | private static MyApplication instance;
13 |
14 | /**
15 | * 权限token 登录后获得
16 | */
17 | private String authToken;
18 |
19 | public static MyApplication getInstance() {
20 | return instance;
21 | }
22 |
23 |
24 | @Override
25 | public void onCreate() {
26 | super.onCreate();
27 | instance = this;
28 | initRouter(this);
29 | }
30 |
31 | private void initRouter(MyApplication myApplication) {
32 | if (BuildConfig.DEBUG) {
33 | ARouter.openLog(); // 打印日志
34 | ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
35 | }
36 | ARouter.init(myApplication);
37 | }
38 |
39 | @Override
40 | public void onTerminate() {
41 | super.onTerminate();
42 | ARouter.getInstance().destroy();
43 | }
44 |
45 | public String getAuthToken() {
46 | return authToken;
47 | }
48 |
49 | public void setAuthToken(String authToken) {
50 | this.authToken = authToken;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/baselibrary/src/main/java/com/arouter/baselibrary/RoutePath.java:
--------------------------------------------------------------------------------
1 | package com.arouter.baselibrary;
2 |
3 | public class RoutePath {
4 |
5 | private static final String PREFIX = "/base/";
6 |
7 | public static final String AUTH_TIP_ACTIVITY = PREFIX+"AuthTipActivity";
8 | public static final String DEGRADE = PREFIX+"DegradeService";
9 | public static final String DEGRADE_TIP = PREFIX+"DegradeTipActivity";
10 | }
11 |
--------------------------------------------------------------------------------
/baselibrary/src/main/java/com/arouter/baselibrary/activity/AuthTipActivity.java:
--------------------------------------------------------------------------------
1 | package com.arouter.baselibrary.activity;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.Button;
6 |
7 | import com.alibaba.android.arouter.facade.annotation.Route;
8 | import com.alibaba.android.arouter.launcher.ARouter;
9 | import com.arouter.baselibrary.R;
10 | import com.arouter.baselibrary.RoutePath;
11 | import com.arouter.baselibrary.base.BaseActivity;
12 |
13 | /**
14 | * 无权限访问提示页面
15 | */
16 | @Route(path = RoutePath.AUTH_TIP_ACTIVITY)
17 | public class AuthTipActivity extends BaseActivity {
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_auth_tip);
23 |
24 | final Button btnBack = findViewById(R.id.btn_back);
25 | btnBack.setOnClickListener(new View.OnClickListener() {
26 | @Override
27 | public void onClick(View v) {
28 | onBackPressed();
29 | }
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/baselibrary/src/main/java/com/arouter/baselibrary/activity/DegradeTipActivity.java:
--------------------------------------------------------------------------------
1 | package com.arouter.baselibrary.activity;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.Button;
6 |
7 | import com.alibaba.android.arouter.facade.annotation.Route;
8 | import com.arouter.baselibrary.R;
9 | import com.arouter.baselibrary.RoutePath;
10 | import com.arouter.baselibrary.base.BaseActivity;
11 |
12 | /**
13 | * 策略降级提示页面
14 | */
15 | @Route(path = RoutePath.DEGRADE_TIP)
16 | public class DegradeTipActivity extends BaseActivity {
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_degrade_tip);
22 |
23 | final Button btnBack = findViewById(R.id.btn_back);
24 | btnBack.setOnClickListener(new View.OnClickListener() {
25 | @Override
26 | public void onClick(View v) {
27 | onBackPressed();
28 | }
29 | });
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/baselibrary/src/main/java/com/arouter/baselibrary/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.arouter.baselibrary.base;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | import com.alibaba.android.arouter.launcher.ARouter;
7 |
8 | /**
9 | * 所有Actvity都继承BaseActivity
10 | */
11 | public class BaseActivity extends AppCompatActivity {
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | ARouter.getInstance().inject(this);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/baselibrary/src/main/java/com/arouter/baselibrary/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.arouter.baselibrary.base;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.app.Fragment;
7 |
8 | import com.alibaba.android.arouter.launcher.ARouter;
9 |
10 | /**
11 | * 所有Fragment都继承BaseFragment
12 | */
13 | public class BaseFragment extends Fragment{
14 |
15 | @Override
16 | public void onCreate(@Nullable Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | ARouter.getInstance().inject(this);
19 | }
20 |
21 | @Override
22 | public void onAttach(Context context) {
23 | super.onAttach(context);
24 | ARouter.getInstance().inject(context);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/baselibrary/src/main/java/com/arouter/baselibrary/interceptor/AuthInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.arouter.baselibrary.interceptor;
2 |
3 | import android.content.Context;
4 |
5 | import com.alibaba.android.arouter.facade.Postcard;
6 | import com.alibaba.android.arouter.facade.annotation.Interceptor;
7 | import com.alibaba.android.arouter.facade.callback.InterceptorCallback;
8 | import com.alibaba.android.arouter.facade.template.IInterceptor;
9 | import com.alibaba.android.arouter.launcher.ARouter;
10 | import com.arouter.baselibrary.MyApplication;
11 | import com.arouter.baselibrary.RoutePath;
12 |
13 | /**
14 | *
15 | * 权限校验拦截器
16 | */
17 | @Interceptor(priority = 1)
18 | public class AuthInterceptor implements IInterceptor {
19 |
20 | @Override
21 | public void process(Postcard postcard, InterceptorCallback callback) {
22 | /**
23 | * 是否有登录判断
24 | */
25 | if (MyApplication.getInstance().getAuthToken()!=null) {
26 | callback.onContinue(postcard);
27 | } else {
28 | callback.onInterrupt(new RuntimeException("未登录的非法访问"));
29 | ARouter.getInstance().build(RoutePath.AUTH_TIP_ACTIVITY).greenChannel().navigation();
30 | }
31 | }
32 |
33 | @Override
34 | public void init(Context context) {
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/baselibrary/src/main/res/layout/activity_auth_tip.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/baselibrary/src/main/res/layout/activity_degrade_tip.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/baselibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/baselibrary/src/test/java/com/arouter/baselibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.arouter.baselibrary;
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 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.0'
11 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | subprojects {
26 | project.configurations.all {
27 | resolutionStrategy.eachDependency { details ->
28 | if (details.requested.group == 'com.android.support'
29 | && !details.requested.name.contains('multidex') ) {
30 | //统一版本号
31 | details.useVersion "27.1.1"
32 | }
33 | }
34 | }
35 | }
36 |
37 | task clean(type: Delete) {
38 | delete rootProject.buildDir
39 | }
40 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 |
16 | isModule=false
17 |
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jul 04 14:11:41 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 |
--------------------------------------------------------------------------------
/module_home/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module_home/build.gradle:
--------------------------------------------------------------------------------
1 | if (isModule.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 |
7 | android {
8 | compileSdkVersion 27
9 | defaultConfig {
10 | if (isModule.toBoolean()) {
11 | applicationId "com.arouter.module_home"
12 | }
13 | minSdkVersion 21
14 | targetSdkVersion 27
15 | versionCode 1
16 | versionName "1.0"
17 |
18 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
19 | sourceSets {
20 | main {
21 | if (isModule.toBoolean()) {
22 | manifest.srcFile 'src/main/buildModule/AndroidManifest.xml'
23 | } else {
24 | manifest.srcFile 'src/main/buildApp/AndroidManifest.xml'
25 | }
26 | }
27 | }
28 | javaCompileOptions {
29 | annotationProcessorOptions {
30 | arguments = [AROUTER_MODULE_NAME: project.getName()]
31 | }
32 | }
33 | }
34 |
35 | buildTypes {
36 | release {
37 | minifyEnabled false
38 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
39 | }
40 | }
41 |
42 | }
43 |
44 | dependencies {
45 |
46 | implementation fileTree(include: ['*.jar'], dir: 'libs')
47 | implementation 'com.android.support:appcompat-v7:27.1.1'
48 | implementation 'com.android.support:design:27.1.1'
49 | testImplementation 'junit:junit:4.12'
50 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
51 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
52 | compile 'com.android.support:support-v4:27.1.1'
53 | compile 'com.alibaba:arouter-api:1.4.1'
54 | annotationProcessor 'com.alibaba:arouter-compiler:1.2.2'
55 |
56 | implementation project(':baselibrary')
57 | implementation project(':module_route')
58 | }
59 |
--------------------------------------------------------------------------------
/module_home/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 |
--------------------------------------------------------------------------------
/module_home/src/androidTest/java/com/arouter/module_home/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_home;
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.arouter.module_home", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/module_home/src/main/buildApp/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/module_home/src/main/buildModule/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/module_home/src/main/java/com/arouter/module_home/HomeActivity.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_home;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.arouter.baselibrary.base.BaseActivity;
6 |
7 |
8 | /**
9 | * 独编译运行时调用
10 | */
11 | public class HomeActivity extends BaseActivity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_home);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/module_home/src/main/java/com/arouter/module_home/HomeFragment.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_home;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import com.alibaba.android.arouter.facade.annotation.Route;
10 | import com.alibaba.android.arouter.launcher.ARouter;
11 | import com.aroute.module_route.HomeRoutePath;
12 | import com.arouter.baselibrary.IUserInfo;
13 | import com.arouter.baselibrary.base.BaseFragment;
14 |
15 | /**
16 | * 主页tab Home
17 | */
18 | @Route(path = HomeRoutePath.HOME_FRAGMENT)
19 | public class HomeFragment extends BaseFragment {
20 |
21 | @Override
22 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
23 | View view = inflater.inflate(R.layout.activity_home, null);
24 | TextView tv_text = view.findViewById(R.id.tv_text);
25 | String name = ARouter.getInstance().navigation(IUserInfo.class).getName();
26 | tv_text.setText("欢迎 " +name +"~~");
27 | return view;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/module_home/src/main/res/drawable/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_home/src/main/res/drawable/ic_launcher_round.png
--------------------------------------------------------------------------------
/module_home/src/main/res/layout/activity_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/module_home/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/module_home/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/module_home/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | module_home
3 | HomeActivity
4 |
5 |
--------------------------------------------------------------------------------
/module_home/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/module_home/src/test/java/com/arouter/module_home/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_home;
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 | }
--------------------------------------------------------------------------------
/module_main/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module_main/build.gradle:
--------------------------------------------------------------------------------
1 | if (isModule.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 |
7 | android {
8 | compileSdkVersion 27
9 | defaultConfig {
10 | if (isModule.toBoolean()) {
11 | applicationId "com.arouter.module_main"
12 | }
13 | minSdkVersion 21
14 | targetSdkVersion 27
15 | versionCode 1
16 | versionName "1.0"
17 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
18 | sourceSets {
19 | main {
20 | if (isModule.toBoolean()) {
21 | manifest.srcFile 'src/main/buildModule/AndroidManifest.xml'
22 | } else {
23 | manifest.srcFile 'src/main/buildApp/AndroidManifest.xml'
24 | }
25 | }
26 | }
27 | javaCompileOptions {
28 | annotationProcessorOptions {
29 | arguments = [AROUTER_MODULE_NAME: project.getName(),AROUTER_GENERATE_DOC: "enable"]
30 | }
31 | }
32 | }
33 |
34 | buildTypes {
35 | release {
36 | minifyEnabled false
37 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
38 | }
39 | }
40 |
41 | }
42 |
43 | dependencies {
44 |
45 | implementation fileTree(include: ['*.jar'], dir: 'libs')
46 | implementation 'com.android.support:appcompat-v7:27.1.1'
47 | implementation 'com.android.support:design:27.1.1'
48 | testImplementation 'junit:junit:4.12'
49 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
50 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
51 | compile 'com.android.support:support-v4:27.1.1'
52 | compile 'com.alibaba:arouter-api:1.4.1'
53 | annotationProcessor 'com.alibaba:arouter-compiler:1.2.2'
54 |
55 | implementation project(':baselibrary')
56 | implementation project(':module_route')
57 | }
58 |
--------------------------------------------------------------------------------
/module_main/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/module_main/src/main/buildApp/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/module_main/src/main/buildModule/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/arouter/module_main/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_main;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.Button;
6 | import android.widget.EditText;
7 |
8 | import com.alibaba.android.arouter.facade.annotation.Route;
9 | import com.alibaba.android.arouter.launcher.ARouter;
10 | import com.aroute.module_route.MainRoutePath;
11 | import com.arouter.baselibrary.MyApplication;
12 | import com.arouter.baselibrary.base.BaseActivity;
13 |
14 | /**
15 | * 登录界面
16 | */
17 | @Route(path = MainRoutePath.LOGIN_ACTIVITY)
18 | public class LoginActivity extends BaseActivity {
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_login);
24 |
25 | final Button btnLogin = findViewById(R.id.btn_login);
26 | final EditText et_login = findViewById(R.id.et_login);
27 |
28 | final String name = et_login.getText().toString();
29 |
30 | /**
31 | * 正常登录进入
32 | */
33 | btnLogin.setOnClickListener(new View.OnClickListener() {
34 | @Override
35 | public void onClick(View view) {
36 |
37 | if (verifyLogin(name)) {
38 | ARouter.getInstance().build(MainRoutePath.MAIN_ACTIVITY)
39 | .withString("name", name)
40 | .withInt("age", 28)
41 | .navigation();
42 | }
43 | }
44 | });
45 |
46 |
47 | /**
48 | * 尝试不登录进入 会被拦截器拦截
49 | */
50 | final Button btnForward = findViewById(R.id.btn_forward);
51 |
52 | btnForward.setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(View v) {
55 | ARouter.getInstance().build(MainRoutePath.MAIN_ACTIVITY).navigation();
56 | }
57 | });
58 |
59 |
60 | /**
61 | * 跳转目标页面不存在,触发降级策略 避免crash
62 | */
63 | final Button btnDegrade = findViewById(R.id.btn_degrade);
64 |
65 | btnDegrade.setOnClickListener(new View.OnClickListener() {
66 | @Override
67 | public void onClick(View v) {
68 | ARouter.getInstance().build("/test/test").navigation();
69 | }
70 | });
71 | }
72 |
73 |
74 | /**
75 | * 登录账号校验 正常应该访问服务器校验
76 | *
77 | * @param name
78 | * @return
79 | */
80 | private boolean verifyLogin(String name) {
81 | MyApplication.getInstance().setAuthToken("@A4sn2243434er");
82 | return true;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/arouter/module_main/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_main;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentTabHost;
6 | import android.widget.TabHost;
7 |
8 | import com.alibaba.android.arouter.facade.annotation.Autowired;
9 | import com.alibaba.android.arouter.facade.annotation.Route;
10 | import com.alibaba.android.arouter.launcher.ARouter;
11 | import com.aroute.module_route.MainRoutePath;
12 | import com.aroute.module_route.HomeRoutePath;
13 | import com.aroute.module_route.MineRoutePath;
14 | import com.aroute.module_route.VideoRoutePath;
15 | import com.arouter.baselibrary.base.BaseActivity;
16 |
17 | /**
18 | * 登录后的主页
19 | */
20 | @Route(path = MainRoutePath.MAIN_ACTIVITY)
21 | public class MainActivity extends BaseActivity {
22 |
23 | /**
24 | * 接收参数
25 | */
26 | @Autowired(name = "name")
27 | public String name;
28 | @Autowired(name = "age")
29 | public int age;
30 |
31 | private int[] tabIcon = {R.drawable.ic_home_red, R.drawable.ic_video_black, R.drawable.ic_mine_black};
32 | private String[] tabText = {"首页", "视频", "我的"};
33 | private TabSpec mTabSpec1;
34 | private TabSpec mTabSpec2;
35 | private TabSpec mTabSpec3;
36 |
37 | @Override
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.activity_main);
41 |
42 | Fragment fragmentHome = (Fragment) ARouter.getInstance().build(HomeRoutePath.HOME_FRAGMENT).navigation();
43 | Fragment fragmentVideo = (Fragment) ARouter.getInstance().build(VideoRoutePath.VIDEO_FRAGMENT).navigation();
44 | Fragment fragmentMime = (Fragment) ARouter.getInstance().build(MineRoutePath.MINE_FRAGMENT).navigation();
45 |
46 |
47 | final FragmentTabHost tabHost = findViewById(R.id.tabhost);
48 | tabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
49 |
50 | mTabSpec1 = new TabSpec(tabHost, tabText[0], tabIcon[0]);
51 | mTabSpec2 = new TabSpec(tabHost, tabText[1], tabIcon[1]);
52 | mTabSpec3 = new TabSpec(tabHost, tabText[2], tabIcon[2]);
53 |
54 | tabHost.addTab(mTabSpec1.getTabSpec(), fragmentHome.getClass(), null);
55 | tabHost.addTab(mTabSpec2.getTabSpec(), fragmentVideo.getClass(), null);
56 |
57 | Bundle params = new Bundle();
58 | params.putString("name",name);
59 | params.putInt("age",age);
60 | tabHost.addTab(mTabSpec3.getTabSpec(), fragmentMime.getClass(), params);
61 |
62 | tabHost.setCurrentTab(0);
63 |
64 | tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
65 | @Override
66 | public void onTabChanged(String s) {
67 | setSelectImage(s);
68 | }
69 | });
70 | }
71 |
72 | /**
73 | * 选中时候的背景图片设置
74 | * @param tagID
75 | */
76 | public void setSelectImage(String tagID){
77 | if (tagID.equals(mTabSpec1.name)) {
78 | mTabSpec1.imageView.setImageResource(R.drawable.ic_home_red);
79 | mTabSpec2.imageView.setImageResource(R.drawable.ic_video_black);
80 | mTabSpec3.imageView.setImageResource(R.drawable.ic_mine_black);
81 | } else if (tagID.equals(mTabSpec2.name)) {
82 | mTabSpec1.imageView.setImageResource(R.drawable.ic_home_black);
83 | mTabSpec2.imageView.setImageResource(R.drawable.ic_video_red);
84 | mTabSpec3.imageView.setImageResource(R.drawable.ic_mine_black);
85 | } else if (tagID.equals(mTabSpec3.name)) {
86 | mTabSpec1.imageView.setImageResource(R.drawable.ic_home_black);
87 | mTabSpec2.imageView.setImageResource(R.drawable.ic_video_black);
88 | mTabSpec3.imageView.setImageResource(R.drawable.ic_mine_red);
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/arouter/module_main/SplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_main;
2 |
3 | import android.animation.Animator;
4 | import android.os.Bundle;
5 | import android.view.ViewAnimationUtils;
6 | import android.widget.ImageView;
7 |
8 | import com.alibaba.android.arouter.launcher.ARouter;
9 | import com.aroute.module_route.MainRoutePath;
10 | import com.arouter.baselibrary.base.BaseActivity;
11 |
12 |
13 | /**
14 | * 闪屏页面
15 | */
16 | public class SplashActivity extends BaseActivity {
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_splash);
22 | final ImageView ivImage = findViewById(R.id.iv_image);
23 | ivImage.post(new Runnable() {
24 | @Override
25 | public void run() {
26 | Animator circularReveal = ViewAnimationUtils.createCircularReveal(ivImage, ivImage.getWidth() / 2,
27 | ivImage.getHeight() / 2, 0, ivImage.getWidth());
28 | circularReveal.setDuration(2000);
29 | circularReveal.addListener(new Animator.AnimatorListener() {
30 | @Override
31 | public void onAnimationStart(Animator animator) {
32 |
33 | }
34 |
35 | @Override
36 | public void onAnimationEnd(Animator animator) {
37 | //greenChannel表示跳过拦截器验证
38 | ARouter.getInstance().build(MainRoutePath.LOGIN_ACTIVITY).greenChannel().navigation();
39 | finish();
40 | }
41 |
42 | @Override
43 | public void onAnimationCancel(Animator animator) {
44 |
45 | }
46 |
47 | @Override
48 | public void onAnimationRepeat(Animator animator) {
49 |
50 | }
51 | });
52 | circularReveal.start();
53 | }
54 | });
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/arouter/module_main/TabSpec.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_main;
2 |
3 | import android.support.v4.app.FragmentTabHost;
4 | import android.view.View;
5 | import android.widget.ImageView;
6 | import android.widget.TabHost;
7 | import android.widget.TextView;
8 |
9 | /**
10 | * 首页tab信息
11 | */
12 | public class TabSpec {
13 |
14 | public int icon;
15 | public String name;
16 | public FragmentTabHost tabHost;
17 | public View view;
18 | public ImageView imageView;
19 | public TextView textView;
20 |
21 | public TabSpec(FragmentTabHost tabHost, String name, int icon) {
22 | this.tabHost = tabHost;
23 | this.icon = icon;
24 | this.name = name;
25 | initTabView();
26 | }
27 |
28 | public TabHost.TabSpec getTabSpec() {
29 | imageView.setImageResource(icon);
30 | textView.setText(name);
31 | return tabHost.newTabSpec(name).setIndicator(view);
32 | }
33 |
34 | private void initTabView() {
35 | view = View.inflate(tabHost.getContext(), R.layout.tabcontent, null);
36 | imageView = view.findViewById(R.id.image);
37 | textView = view.findViewById(R.id.text);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/module_main/src/main/res/color/selector_tab_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_main/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_main/src/main/res/drawable-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-hdpi/splash.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_main/src/main/res/drawable-hdpi/splash.jpg
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xhdpi/ic_home_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_main/src/main/res/drawable-xhdpi/ic_home_black.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xhdpi/ic_home_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_main/src/main/res/drawable-xhdpi/ic_home_red.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_main/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_main/src/main/res/drawable-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xhdpi/ic_mine_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_main/src/main/res/drawable-xhdpi/ic_mine_black.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xhdpi/ic_mine_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_main/src/main/res/drawable-xhdpi/ic_mine_red.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xhdpi/ic_video_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_main/src/main/res/drawable-xhdpi/ic_video_black.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xhdpi/ic_video_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_main/src/main/res/drawable-xhdpi/ic_video_red.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
16 |
21 |
26 |
31 |
36 |
41 |
46 |
51 |
56 |
61 |
66 |
71 |
76 |
81 |
86 |
91 |
96 |
101 |
106 |
111 |
116 |
121 |
126 |
131 |
136 |
141 |
146 |
151 |
156 |
161 |
166 |
171 |
172 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable/selector_tab_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
17 |
18 |
25 |
26 |
27 |
34 |
35 |
36 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
18 |
19 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/tabcontent.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
12 |
13 |
21 |
--------------------------------------------------------------------------------
/module_main/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/module_main/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | module_begin
3 |
4 |
--------------------------------------------------------------------------------
/module_main/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/module_mine/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module_mine/build.gradle:
--------------------------------------------------------------------------------
1 | if (isModule.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 |
7 | dependencies {
8 | implementation 'com.android.support.constraint:constraint-layout:+'
9 | }
10 | android {
11 | compileSdkVersion 27
12 | defaultConfig {
13 | defaultConfig {
14 | if (isModule.toBoolean()) {
15 | applicationId "com.arouter.module_mine"
16 | }
17 | minSdkVersion 21
18 | targetSdkVersion 27
19 | versionCode 1
20 | versionName "1.0"
21 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
22 | sourceSets {
23 | main {
24 | if (isModule.toBoolean()) {
25 | manifest.srcFile 'src/main/buildModule/AndroidManifest.xml'
26 | } else {
27 | manifest.srcFile 'src/main/buildApp/AndroidManifest.xml'
28 | }
29 | }
30 | }
31 | javaCompileOptions {
32 | annotationProcessorOptions {
33 | arguments = [AROUTER_MODULE_NAME: project.getName()]
34 | }
35 | }
36 | }
37 |
38 | buildTypes {
39 | release {
40 | minifyEnabled false
41 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
42 | }
43 | }
44 |
45 | }
46 |
47 | dependencies {
48 | implementation fileTree(include: ['*.jar'], dir: 'libs')
49 | implementation 'com.android.support:appcompat-v7:27.1.1'
50 | implementation 'com.android.support:design:27.1.1'
51 | testImplementation 'junit:junit:4.12'
52 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
53 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
54 | compile 'com.android.support:support-v4:27.1.1'
55 | compile 'com.alibaba:arouter-api:1.4.1'
56 | annotationProcessor 'com.alibaba:arouter-compiler:1.2.2'
57 |
58 |
59 | implementation project(':baselibrary')
60 | implementation project(':module_route')
61 | }
62 | }
--------------------------------------------------------------------------------
/module_mine/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 |
--------------------------------------------------------------------------------
/module_mine/src/androidTest/java/com/arouter/module_mine/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_mine;
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.arouter.module_mine", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/module_mine/src/main/buildApp/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/module_mine/src/main/buildModule/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/module_mine/src/main/java/com/arouter/module_mine/MineFragment.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_mine;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import com.alibaba.android.arouter.facade.annotation.Route;
10 | import com.aroute.module_route.MineRoutePath;
11 | import com.arouter.baselibrary.base.BaseFragment;
12 |
13 | /**
14 | * 主页tab mine
15 | */
16 | @Route(path = MineRoutePath.MINE_FRAGMENT)
17 | public class MineFragment extends BaseFragment {
18 |
19 | private String name;
20 | private int age;
21 |
22 | @Override
23 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
24 | View view = inflater.inflate(R.layout.activity_mine, null);
25 | TextView tv_username = view.findViewById(R.id.tv_username);
26 |
27 | name = getArguments().getString("name");
28 | age = getArguments().getInt("age");
29 | tv_username.setText("用户:"+name +" 年龄:"+age);
30 | return view;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/module_mine/src/main/java/com/arouter/module_mine/UserInfoImpl.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_mine;
2 |
3 | import android.content.Context;
4 |
5 | import com.alibaba.android.arouter.facade.annotation.Route;
6 | import com.aroute.module_route.MineRoutePath;
7 | import com.arouter.baselibrary.IUserInfo;
8 |
9 | /**
10 | * date:2018/7/9 on 14:41
11 | * description:
12 | */
13 | @Route(path = MineRoutePath.USER_SERVICE)
14 | public class UserInfoImpl implements IUserInfo {
15 | @Override
16 | public String getName() {
17 | return "Alan Chen";
18 | }
19 |
20 | @Override
21 | public void init(Context context) {
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/module_mine/src/main/res/drawable/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_mine/src/main/res/drawable/ic_launcher_round.png
--------------------------------------------------------------------------------
/module_mine/src/main/res/layout/activity_mine.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/module_mine/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/module_mine/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | module_mine
3 |
4 |
--------------------------------------------------------------------------------
/module_mine/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/module_mine/src/test/java/com/arouter/module_mine/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_mine;
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 | }
--------------------------------------------------------------------------------
/module_route/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module_route/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 |
3 | dependencies {
4 | implementation fileTree(dir: 'libs', include: ['*.jar'])
5 | }
6 |
7 | sourceCompatibility = "1.6"
8 | targetCompatibility = "1.6"
9 |
--------------------------------------------------------------------------------
/module_route/src/main/java/com/aroute/module_route/HomeRoutePath.java:
--------------------------------------------------------------------------------
1 | package com.aroute.module_route;
2 |
3 | public class HomeRoutePath {
4 |
5 | private static final String PREFIX = "/home/";
6 |
7 | public static final String HOME_FRAGMENT = PREFIX+"HomeFragment";
8 | }
9 |
--------------------------------------------------------------------------------
/module_route/src/main/java/com/aroute/module_route/MainRoutePath.java:
--------------------------------------------------------------------------------
1 | package com.aroute.module_route;
2 |
3 | public class MainRoutePath {
4 |
5 | private static final String PREFIX = "/main/";
6 |
7 | public static final String MAIN_ACTIVITY = PREFIX+"MainActivity";
8 |
9 | public static final String LOGIN_ACTIVITY = PREFIX+"LoginActivity";
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/module_route/src/main/java/com/aroute/module_route/MineRoutePath.java:
--------------------------------------------------------------------------------
1 | package com.aroute.module_route;
2 |
3 | public class MineRoutePath {
4 |
5 | private static final String PREFIX = "/mine/";
6 |
7 | public static final String LOGIN_RESULT_ACTIVITY = PREFIX+"LonginResultActivity";
8 | public static final String USER_SERVICE = PREFIX+"UserInfoImpl";
9 | public static final String MINE_FRAGMENT = PREFIX+"MineFragment";
10 | }
11 |
--------------------------------------------------------------------------------
/module_route/src/main/java/com/aroute/module_route/VideoRoutePath.java:
--------------------------------------------------------------------------------
1 | package com.aroute.module_route;
2 |
3 | public class VideoRoutePath {
4 |
5 | public static final String VIDEO_FRAGMENT = "/video/VIDEO_FRAGMENT";
6 | }
7 |
--------------------------------------------------------------------------------
/module_video/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module_video/build.gradle:
--------------------------------------------------------------------------------
1 | if (isModule.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 |
7 | android {
8 | compileSdkVersion 27
9 | defaultConfig {
10 | if (isModule.toBoolean()) {
11 | applicationId "com.arouter.module_video"
12 | }
13 | minSdkVersion 21
14 | targetSdkVersion 27
15 | versionCode 1
16 | versionName "1.0"
17 |
18 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
19 | sourceSets {
20 | main {
21 | if (isModule.toBoolean()) {
22 | manifest.srcFile 'src/main/buildModule/AndroidManifest.xml'
23 | } else {
24 | manifest.srcFile 'src/main/buildApp/AndroidManifest.xml'
25 | }
26 | }
27 | }
28 | javaCompileOptions {
29 | annotationProcessorOptions {
30 | arguments = [AROUTER_MODULE_NAME: project.getName()]
31 | }
32 | }
33 | }
34 |
35 | buildTypes {
36 | release {
37 | minifyEnabled false
38 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
39 | }
40 | }
41 |
42 | }
43 |
44 | dependencies {
45 |
46 | implementation fileTree(include: ['*.jar'], dir: 'libs')
47 | implementation 'com.android.support:appcompat-v7:27.1.1'
48 | implementation 'com.android.support:design:27.1.1'
49 | testImplementation 'junit:junit:4.12'
50 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
51 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
52 | compile 'com.android.support:support-v4:27.1.1'
53 | compile 'com.alibaba:arouter-api:1.4.1'
54 | annotationProcessor 'com.alibaba:arouter-compiler:1.2.2'
55 |
56 | implementation project(':baselibrary')
57 | implementation project(':module_route')
58 | }
59 |
--------------------------------------------------------------------------------
/module_video/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 |
--------------------------------------------------------------------------------
/module_video/src/androidTest/java/com/arouter/module_video/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_video;
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.arouter.module_video", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/module_video/src/main/buildApp/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/module_video/src/main/buildModule/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/module_video/src/main/java/com/arouter/module_video/VideoActivity.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_video;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.arouter.baselibrary.base.BaseActivity;
6 |
7 | /**
8 | * 独编译运行时调用
9 | */
10 | public class VideoActivity extends BaseActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_video);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/module_video/src/main/java/com/arouter/module_video/VideoFragment.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_video;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import com.alibaba.android.arouter.facade.annotation.Route;
8 | import com.aroute.module_route.VideoRoutePath;
9 | import com.arouter.baselibrary.base.BaseFragment;
10 |
11 | /**
12 | * 主页 video
13 | */
14 | @Route(path = VideoRoutePath.VIDEO_FRAGMENT)
15 | public class VideoFragment extends BaseFragment {
16 |
17 | @Override
18 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
19 | View view = inflater.inflate(R.layout.activity_video, null);
20 | return view;
21 | }
22 | }
23 |
24 |
25 |
--------------------------------------------------------------------------------
/module_video/src/main/res/drawable/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alanchenyan/AppModuleDemo/f49edf091ca1da32a396d6e0dea7d63d3b5a38fa/module_video/src/main/res/drawable/ic_launcher_round.png
--------------------------------------------------------------------------------
/module_video/src/main/res/layout/activity_video.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/module_video/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/module_video/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | module_video
3 |
4 |
--------------------------------------------------------------------------------
/module_video/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/module_video/src/test/java/com/arouter/module_video/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.arouter.module_video;
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', ':baselibrary', ':module_main', ':module_mine', ':module_home', ':module_video', ':module_route'
2 |
--------------------------------------------------------------------------------