├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── wuxiaolong
│ │ └── modularsample
│ │ ├── AndroidApplication.java
│ │ └── MainActivity.java
│ └── res
│ └── layout
│ └── app_activity_main.xml
├── build.gradle
├── common
├── .gitignore
├── aars
│ └── AndroidUtils1.0.7.aar
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── wuxiaolong
│ │ └── common
│ │ ├── activity
│ │ ├── BaseActivity.java
│ │ └── ButterKnifeActivity.java
│ │ ├── model
│ │ ├── UserModel.java
│ │ └── WeatherModel.java
│ │ └── retrofit
│ │ ├── ApiCallback.java
│ │ ├── ApiClient.java
│ │ └── ApiStores.java
│ └── res
│ └── layout
│ └── toolbar.xml
├── config.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── module1
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── wuxiaolong
│ │ └── module1
│ │ ├── MainActivity.java
│ │ ├── Module1Fragment.java
│ │ ├── Module1ServiceImpl.java
│ │ └── debug
│ │ └── Module1Application.java
│ ├── release
│ └── AndroidManifest.xml
│ └── res
│ └── layout
│ ├── module1_activity_main.xml
│ └── module1_fragment_module1.xml
├── module2
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── wuxiaolong
│ │ └── module2
│ │ └── MainActivity.java
│ ├── release
│ └── AndroidManifest.xml
│ └── res
│ └── layout
│ └── module2_activity_main.xml
├── resource
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── res
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── router
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── wuxiaolong
│ │ └── router
│ │ ├── Module1Service.java
│ │ ├── RouterConstants.java
│ │ └── RouterUtils.java
│ └── res
│ └── values
│ └── strings.xml
├── settings.gradle
└── versions.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
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # 效果预览
3 | 
4 |
5 | # 详情介绍
6 | [Android 组件化探索与思考](http://wuxiaolong.me/2017/08/01/ModularExploree/),来自我的博客,推荐
7 |
8 | [Android 组件化探索与思考](http://mp.weixin.qq.com/s/RGmzjIM4y7Yxz723Vp8uzA),来自我的公众号
9 |
10 |
11 | # 微信公众号
12 | 
13 |
14 | # 赞赏作者
15 | 
16 |
17 | # 更新记录
18 | * v0.03
19 | 1. 统一管理了build.gradle文件
20 | 2. 现在只要是'module'开头的module,都可以使用同一份build.gradle,配置参见'rootDir/config.gradle'
21 |
22 | * v0.02
23 |
24 | 1. 新增 resource,存放项目的所有资源,从 common 分出来
25 |
26 | 2. 新增 router,路由,所有页面请求都由它中转
27 |
28 | * v0.01
29 |
30 | 1. 组件化初步形成
31 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply from: config
2 |
3 | dependencies {
4 | compile fileTree(include: ['*.jar'], dir: 'libs')
5 |
6 | //arouter
7 | annotationProcessor arouterCompiler
8 |
9 | //butterknife
10 | annotationProcessor butterknifeCompiler
11 |
12 | //dagger2
13 | annotationProcessor dagger2Compiler
14 |
15 | if (isDebug.toBoolean()) {
16 | //当isDebug true,app得依赖基础库,保证app不报错
17 | compile project(':resource')
18 | } else {
19 | compile project(':module1')
20 | compile project(':module2')
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/wuxiaolong/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wuxiaolong/modularsample/AndroidApplication.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.modularsample;
2 |
3 | import android.app.Application;
4 |
5 | import com.alibaba.android.arouter.launcher.ARouter;
6 |
7 | /**
8 | * Created by WuXiaolong on 2017/7/24.
9 | * 个人博客:http://wuxiaolong.me
10 | */
11 | public class AndroidApplication extends Application {
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | if (BuildConfig.DEBUG) {
16 | // 这两行必须写在init之前,否则这些配置在init过程中将无效
17 | ARouter.openLog(); // 打印日志
18 | ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
19 | ARouter.printStackTrace(); // 打印日志的时候打印线程堆栈
20 | }
21 | ARouter.init(this); // 尽可能早,推荐在Application中初始化
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wuxiaolong/modularsample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.modularsample;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.View;
6 |
7 | import com.alibaba.android.arouter.launcher.ARouter;
8 | import com.wuxiaolong.common.activity.BaseActivity;
9 | import com.wuxiaolong.common.model.UserModel;
10 | import com.wuxiaolong.router.Module1Service;
11 | import com.wuxiaolong.router.RouterConstants;
12 | import com.wuxiaolong.router.RouterUtils;
13 |
14 | import butterknife.OnClick;
15 |
16 | /**
17 | * Created by WuXiaolong on 2017/7/24.
18 | * 个人博客:http://wuxiaolong.me
19 | */
20 | public class MainActivity extends BaseActivity {
21 |
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.app_activity_main);
26 | initToolBarAsHome(getString(R.string.app));
27 | }
28 |
29 | @OnClick({R.id.button1, R.id.button2, R.id.button3, R.id.button4})
30 | public void onViewClicked(View view) {
31 | switch (view.getId()) {
32 | case R.id.button1:
33 | RouterUtils.navigation(RouterConstants.MODULE1_MAIN_ACTIVITY);
34 | break;
35 | case R.id.button2:
36 | UserModel userModel = new UserModel();
37 | userModel.setName("WuXiaolong");
38 | userModel.setMessage("个人博客:http://wuxiaolong.me");
39 | Bundle bundle = new Bundle();
40 | bundle.putSerializable("obj", userModel);
41 | ARouter.getInstance()
42 | .build(RouterConstants.MODULE1_MAIN_ACTIVITY)
43 | .with(bundle)
44 | .navigation();
45 | break;
46 | case R.id.button3:
47 | showFragment();
48 | break;
49 | case R.id.button4:
50 | Module1Service module1Service = (Module1Service) RouterUtils.navigation(RouterConstants.MODULE1_SERVICE_IMPL);
51 | if (module1Service != null)
52 | toastShow("结果:" + module1Service.share());
53 | break;
54 | }
55 | }
56 |
57 | private void showFragment() {
58 | // 获取Fragment
59 | Fragment fragment = (Fragment) RouterUtils.navigation(RouterConstants.MODULE1_MODULE1_FRAGMENT);
60 | if (fragment != null)
61 | getSupportFragmentManager().beginTransaction().add(R.id.contentLayout, fragment).commit();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
34 |
35 |
50 |
51 |
66 |
67 |
81 |
82 |
94 |
95 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 |
4 | ext {
5 | versions = "${rootDir}/versions.gradle"
6 | config = "${rootDir}/config.gradle"
7 |
8 | is_debug = isDebug.toBoolean() //组件化每个模块是否可以独立编译
9 | }
10 |
11 | repositories {
12 | jcenter()
13 | mavenCentral()
14 | }
15 | dependencies {
16 | classpath 'com.android.tools.build:gradle:2.3.3'
17 | //butterknife
18 | classpath 'com.jakewharton:butterknife-gradle-plugin:8.7.0'
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | jcenter()
25 | }
26 | }
27 |
28 | task clean(type: Delete) {
29 | delete rootProject.buildDir
30 | }
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/common/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/common/aars/AndroidUtils1.0.7.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/common/aars/AndroidUtils1.0.7.aar
--------------------------------------------------------------------------------
/common/build.gradle:
--------------------------------------------------------------------------------
1 | apply from: config
2 |
3 | repositories {
4 | flatDir {
5 | dirs 'aars'
6 | }
7 | }
8 | dependencies {
9 | compile fileTree(dir: 'libs', include: ['*.jar'])
10 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
11 | exclude group: 'com.android.support', module: 'support-annotations'
12 | })
13 | //testCompile 'junit:junit:4.12'
14 | compile appcompatV7
15 | compile constraintLayout
16 | //compile 'com.wuxiaolong.androidutils:androidutils:1.0.6'
17 | // compile(name:'AndroidUtils1.0.7', ext:'aar')
18 |
19 | //butterknife
20 | compile butterknife
21 |
22 | //dagger
23 | compile dagger2
24 |
25 | //pullloadmorerecyclerview
26 | compile 'com.wuxiaolong.pullloadmorerecyclerview:library:1.1.2'
27 |
28 | //retrofit
29 | compile 'com.squareup.retrofit2:retrofit:2.0.2'
30 | compile 'com.squareup.okhttp3:logging-interceptor:3.1.2'
31 | compile 'com.squareup.retrofit2:converter-gson:2.0.2'
32 | compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
33 |
34 | //rxjava
35 | compile 'io.reactivex:rxandroid:1.1.0'
36 | compile 'io.reactivex:rxjava:1.1.0'
37 | }
38 |
--------------------------------------------------------------------------------
/common/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/wuxiaolong/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/common/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/common/src/main/java/com/wuxiaolong/common/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.common.activity;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 | import android.support.annotation.LayoutRes;
7 | import android.support.v7.app.ActionBar;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.Toolbar;
10 | import android.view.MenuItem;
11 | import android.widget.TextView;
12 | import android.widget.Toast;
13 |
14 | import com.wuxiaolong.common.R;
15 | import com.wuxiaolong.common.retrofit.ApiClient;
16 | import com.wuxiaolong.common.retrofit.ApiStores;
17 |
18 | import butterknife.ButterKnife;
19 | import butterknife.Unbinder;
20 | import rx.Observable;
21 | import rx.Subscriber;
22 | import rx.Subscription;
23 | import rx.android.schedulers.AndroidSchedulers;
24 | import rx.schedulers.Schedulers;
25 | import rx.subscriptions.CompositeSubscription;
26 |
27 | public class BaseActivity extends AppCompatActivity {
28 | public Context context;
29 | private Unbinder unbinder;
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | context = this;
34 | }
35 |
36 | @Override
37 | public void setContentView(@LayoutRes int layoutResID) {
38 | super.setContentView(layoutResID);
39 | unbinder = ButterKnife.bind(this);
40 | }
41 |
42 | public Toolbar initToolBar(String title) {
43 |
44 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
45 | if (toolbar != null) {
46 | setSupportActionBar(toolbar);
47 | TextView toolbaTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
48 | toolbaTitle.setText(title);
49 | }
50 | ActionBar actionBar = getSupportActionBar();
51 | if (actionBar != null) {
52 | actionBar.setDisplayHomeAsUpEnabled(true);
53 | actionBar.setDisplayShowTitleEnabled(false);
54 | }
55 | return toolbar;
56 | }
57 |
58 | public Toolbar initToolBarAsHome(String title) {
59 |
60 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
61 | if (toolbar != null) {
62 | setSupportActionBar(toolbar);
63 | TextView toolbaTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
64 | toolbaTitle.setText(title);
65 | }
66 | ActionBar actionBar = getSupportActionBar();
67 | if (actionBar != null) {
68 | actionBar.setDisplayHomeAsUpEnabled(false);
69 | actionBar.setDisplayShowTitleEnabled(false);
70 | }
71 | return toolbar;
72 | }
73 |
74 | @Override
75 | public boolean onOptionsItemSelected(MenuItem item) {
76 | switch (item.getItemId()) {
77 |
78 | case android.R.id.home:
79 | super.onBackPressed();//返回
80 | return true;
81 | default:
82 | return super.onOptionsItemSelected(item);
83 | }
84 |
85 | }
86 |
87 | @Override
88 | protected void onDestroy() {
89 | super.onDestroy();
90 | unbinder.unbind();
91 | onUnsubscribe();
92 | }
93 | public ApiStores apiStores() {
94 | return ApiClient.retrofit().create(ApiStores.class);
95 | }
96 |
97 | private CompositeSubscription mCompositeSubscription;
98 |
99 | public void addSubscription(Observable observable, Subscriber subscriber) {
100 | if (mCompositeSubscription == null) {
101 | mCompositeSubscription = new CompositeSubscription();
102 | }
103 | mCompositeSubscription.add(observable
104 | .subscribeOn(Schedulers.io())
105 | .unsubscribeOn(Schedulers.io())
106 | .observeOn(AndroidSchedulers.mainThread())
107 | .subscribe(subscriber));
108 | }
109 |
110 | public void addSubscription(Subscription subscription) {
111 | if (mCompositeSubscription == null) {
112 | mCompositeSubscription = new CompositeSubscription();
113 | }
114 | mCompositeSubscription.add(subscription);
115 | }
116 |
117 | public void onUnsubscribe() {
118 | //取消注册,以避免内存泄露
119 | if (mCompositeSubscription != null && mCompositeSubscription.hasSubscriptions())
120 | mCompositeSubscription.unsubscribe();
121 | }
122 |
123 | public void toastShow(int resId) {
124 | Toast.makeText(context, resId, Toast.LENGTH_SHORT).show();
125 | }
126 |
127 | public void toastShow(String resId) {
128 | Toast.makeText(context, resId, Toast.LENGTH_SHORT).show();
129 | }
130 | public ProgressDialog progressDialog;
131 |
132 | public ProgressDialog showProgressDialog() {
133 | progressDialog = new ProgressDialog(context);
134 | progressDialog.setMessage("加载中");
135 | progressDialog.show();
136 | return progressDialog;
137 | }
138 |
139 | public ProgressDialog showProgressDialog(CharSequence message) {
140 | progressDialog = new ProgressDialog(context);
141 | progressDialog.setMessage(message);
142 | progressDialog.show();
143 | return progressDialog;
144 | }
145 |
146 | public void dismissProgressDialog() {
147 | if (progressDialog != null && progressDialog.isShowing()) {
148 | // progressDialog.hide();会导致android.view.WindowLeaked
149 | progressDialog.dismiss();
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/common/src/main/java/com/wuxiaolong/common/activity/ButterKnifeActivity.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.common.activity;
2 |
3 | import android.support.annotation.LayoutRes;
4 |
5 | import butterknife.ButterKnife;
6 | import butterknife.Unbinder;
7 |
8 | public class ButterKnifeActivity extends BaseActivity {
9 |
10 | private Unbinder unbinder;
11 |
12 |
13 | @Override
14 | public void setContentView(@LayoutRes int layoutResID) {
15 | super.setContentView(layoutResID);
16 | unbinder = ButterKnife.bind(this);
17 | }
18 |
19 | @Override
20 | protected void onDestroy() {
21 | super.onDestroy();
22 | unbinder.unbind();
23 | }}
24 |
--------------------------------------------------------------------------------
/common/src/main/java/com/wuxiaolong/common/model/UserModel.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.common.model;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * Created by WuXiaolong on 2017/7/24.
7 | * 个人博客:http://wuxiaolong.me
8 | */
9 |
10 | public class UserModel implements Serializable{
11 | private String name;
12 | private String message;
13 |
14 | public String getName() {
15 | return name;
16 | }
17 |
18 | public void setName(String name) {
19 | this.name = name;
20 | }
21 |
22 | public String getMessage() {
23 | return message;
24 | }
25 |
26 | public void setMessage(String message) {
27 | this.message = message;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/common/src/main/java/com/wuxiaolong/common/model/WeatherModel.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.common.model;
2 |
3 | /**
4 | * Created by WuXiaolong on 2017/7/30.
5 | * 个人博客:http://wuxiaolong.me
6 | */
7 |
8 | public class WeatherModel {
9 | private WeatherinfoBean weatherinfo;
10 |
11 | public WeatherinfoBean getWeatherinfo() {
12 | return weatherinfo;
13 | }
14 |
15 | public void setWeatherinfo(WeatherinfoBean weatherinfo) {
16 | this.weatherinfo = weatherinfo;
17 | }
18 |
19 | public static class WeatherinfoBean {
20 | private String city;
21 | private String cityid;
22 | private String temp;
23 | private String WD;
24 | private String WS;
25 | private String SD;
26 | private String WSE;
27 | private String time;
28 | private String isRadar;
29 | private String Radar;
30 | private String njd;
31 | private String qy;
32 |
33 | public String getCity() {
34 | return city;
35 | }
36 |
37 | public void setCity(String city) {
38 | this.city = city;
39 | }
40 |
41 | public String getCityid() {
42 | return cityid;
43 | }
44 |
45 | public void setCityid(String cityid) {
46 | this.cityid = cityid;
47 | }
48 |
49 | public String getTemp() {
50 | return temp;
51 | }
52 |
53 | public void setTemp(String temp) {
54 | this.temp = temp;
55 | }
56 |
57 | public String getWD() {
58 | return WD;
59 | }
60 |
61 | public void setWD(String WD) {
62 | this.WD = WD;
63 | }
64 |
65 | public String getWS() {
66 | return WS;
67 | }
68 |
69 | public void setWS(String WS) {
70 | this.WS = WS;
71 | }
72 |
73 | public String getSD() {
74 | return SD;
75 | }
76 |
77 | public void setSD(String SD) {
78 | this.SD = SD;
79 | }
80 |
81 | public String getWSE() {
82 | return WSE;
83 | }
84 |
85 | public void setWSE(String WSE) {
86 | this.WSE = WSE;
87 | }
88 |
89 | public String getTime() {
90 | return time;
91 | }
92 |
93 | public void setTime(String time) {
94 | this.time = time;
95 | }
96 |
97 | public String getIsRadar() {
98 | return isRadar;
99 | }
100 |
101 | public void setIsRadar(String isRadar) {
102 | this.isRadar = isRadar;
103 | }
104 |
105 | public String getRadar() {
106 | return Radar;
107 | }
108 |
109 | public void setRadar(String Radar) {
110 | this.Radar = Radar;
111 | }
112 |
113 | public String getNjd() {
114 | return njd;
115 | }
116 |
117 | public void setNjd(String njd) {
118 | this.njd = njd;
119 | }
120 |
121 | public String getQy() {
122 | return qy;
123 | }
124 |
125 | public void setQy(String qy) {
126 | this.qy = qy;
127 | }
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/common/src/main/java/com/wuxiaolong/common/retrofit/ApiCallback.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.common.retrofit;
2 |
3 |
4 |
5 | import retrofit2.adapter.rxjava.HttpException;
6 | import rx.Subscriber;
7 |
8 | /**
9 | * Created by WuXiaolong on 2016/9/22.
10 | * github:https://github.com/WuXiaolong/
11 | * 微信公众号:吴小龙同学
12 | * 个人博客:http://wuxiaolong.me/
13 | */
14 | public abstract class ApiCallback extends Subscriber {
15 |
16 | public abstract void onSuccess(M model);
17 |
18 | public abstract void onFailure(String msg);
19 |
20 | public abstract void onFinish();
21 |
22 |
23 | @Override
24 | public void onError(Throwable e) {
25 | e.printStackTrace();
26 | if (e instanceof HttpException) {
27 | HttpException httpException = (HttpException) e;
28 | //httpException.response().errorBody().string()
29 | int code = httpException.code();
30 | String msg = httpException.getMessage();
31 | if (code == 504) {
32 | msg = "网络不给力";
33 | }
34 | if (code == 502 || code == 404) {
35 | msg = "服务器异常,请稍后再试";
36 | }
37 | onFailure(msg);
38 | } else {
39 | onFailure(e.getMessage());
40 | }
41 | onFinish();
42 | }
43 |
44 | @Override
45 | public void onNext(M model) {
46 | onSuccess(model);
47 |
48 | }
49 |
50 | @Override
51 | public void onCompleted() {
52 | onFinish();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/common/src/main/java/com/wuxiaolong/common/retrofit/ApiClient.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.common.retrofit;
2 |
3 |
4 | import com.wuxiaolong.common.BuildConfig;
5 |
6 | import okhttp3.OkHttpClient;
7 | import okhttp3.logging.HttpLoggingInterceptor;
8 | import retrofit2.Retrofit;
9 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
10 | import retrofit2.converter.gson.GsonConverterFactory;
11 |
12 | /**
13 | * Created by WuXiaolong on 2016/3/24.
14 | * github:https://github.com/WuXiaolong/
15 | * 微信公众号:吴小龙同学
16 | * 个人博客:http://wuxiaolong.me/
17 | */
18 | public class ApiClient {
19 | public static Retrofit mRetrofit;
20 |
21 | public static Retrofit retrofit() {
22 | if (mRetrofit == null) {
23 | OkHttpClient.Builder builder = new OkHttpClient.Builder();
24 |
25 |
26 | if (BuildConfig.DEBUG) {
27 | // Log信息拦截器
28 | HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
29 | loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
30 | //设置 Debug Log 模式
31 | builder.addInterceptor(loggingInterceptor);
32 | }
33 | OkHttpClient okHttpClient = builder.build();
34 | mRetrofit = new Retrofit.Builder()
35 | .baseUrl(ApiStores.API_SERVER_URL)
36 | .addConverterFactory(GsonConverterFactory.create())
37 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
38 | .client(okHttpClient)
39 | .build();
40 | }
41 | return mRetrofit;
42 | }
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/common/src/main/java/com/wuxiaolong/common/retrofit/ApiStores.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.common.retrofit;
2 |
3 | import com.wuxiaolong.common.model.WeatherModel;
4 |
5 | import retrofit2.http.GET;
6 | import retrofit2.http.Path;
7 | import rx.Observable;
8 |
9 | /**
10 | * Created by WuXiaolong on 2016/3/24.
11 | * github:https://github.com/WuXiaolong/
12 | * 微信公众号:吴小龙同学
13 | * 个人博客:http://wuxiaolong.me/
14 | */
15 | public interface ApiStores {
16 | //baseUrl
17 | String API_SERVER_URL = "http://www.weather.com.cn/";
18 |
19 |
20 | //加载天气
21 | @GET("adat/sk/{cityId}.html")
22 | Observable loadWeatherData(@Path("cityId") String cityId);
23 | }
24 |
--------------------------------------------------------------------------------
/common/src/main/res/layout/toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
19 |
--------------------------------------------------------------------------------
/config.gradle:
--------------------------------------------------------------------------------
1 | apply from: versions
2 | if (isIndependent()) {
3 | apply plugin: 'com.android.application'
4 | } else {
5 | apply plugin: 'com.android.library'
6 | }
7 |
8 | android {
9 | compileSdkVersion compile_sdk_version
10 | buildToolsVersion build_tools_version
11 |
12 | defaultConfig {
13 |
14 | minSdkVersion min_sdk_version
15 | targetSdkVersion target_sdk_version
16 |
17 | versionCode version_code
18 | versionName version_name
19 |
20 | resourcePrefix "${project.name}_"
21 |
22 | if (isIndependent()) {
23 | applicationId "com.wuxiaolong.${this.name}"
24 | println("this == ${this.name} , applicationId")
25 | }
26 |
27 | //arouter
28 | javaCompileOptions {
29 | annotationProcessorOptions {
30 | arguments = [moduleName: project.getName()]
31 | }
32 | }
33 |
34 | multiDexEnabled true
35 | }
36 |
37 |
38 |
39 |
40 | sourceSets {
41 | main {
42 | //未开启独立编译 并且是独立的module,才会使用总是使用 library/AndroidManifest.xml
43 | if (!is_debug && this.name.startsWith("module")) {
44 | manifest.srcFile 'src/main/release/AndroidManifest.xml'
45 | } else {
46 | manifest.srcFile 'src/main/AndroidManifest.xml'
47 | java {
48 | //release 时 debug 目录下文件不需要合并到主工程
49 | exclude 'library/**'
50 | }
51 | }
52 | }
53 | }
54 | }
55 |
56 | /**
57 | * 通过修改 project - build.gradle的 is_debug 值来控制module 是否可以独立编译
58 | * @return true :module 是 app ,is_debug = true 并且 module 命名为 `module_` 开头
59 | */
60 | def isIndependent() {
61 | //是app module ,独立编译
62 | if (this.name.startsWith("app")) {
63 | println("this module's name is not startsWith [module] , this.name = ${this.name}")
64 | return true
65 | }
66 |
67 | //没有开启独立编译选项,所以为library
68 | if (!is_debug) {
69 | println("not independent!")
70 | return false
71 | }
72 |
73 | //开启了独立编译选项,但是模块名称不是module_ 开头,所以为 library
74 | if (!this.name.startsWith("module")) {
75 | println("this module's name is not startsWith [module] , this.name = ${this.name}")
76 | return false
77 | }
78 | println("this module is independent!")
79 | return true
80 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
19 | # 组件单独调试开关,true 可以,false 不可以
20 | isDebug=false
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jul 23 12:26:27 CST 2017
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-3.3-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 |
--------------------------------------------------------------------------------
/module1/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module1/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.jakewharton.butterknife'
2 | apply from: config
3 |
4 | dependencies {
5 | compile fileTree(include: ['*.jar'], dir: 'libs')
6 |
7 | //arouter
8 | annotationProcessor arouterCompiler
9 |
10 | compile project(':resource')
11 |
12 | //dagger2
13 | annotationProcessor dagger2Compiler
14 |
15 | //butterknife
16 | annotationProcessor butterknifeCompiler
17 | }
18 |
--------------------------------------------------------------------------------
/module1/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/wuxiaolong/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/module1/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/module1/src/main/java/com/wuxiaolong/module1/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.module1;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | import com.alibaba.android.arouter.facade.annotation.Route;
8 | import com.wuxiaolong.common.activity.BaseActivity;
9 | import com.wuxiaolong.common.model.UserModel;
10 | import com.wuxiaolong.router.RouterConstants;
11 | import com.wuxiaolong.router.RouterUtils;
12 |
13 | import butterknife.BindView;
14 | import butterknife.OnClick;
15 |
16 | @Route(path = RouterConstants.MODULE1_MAIN_ACTIVITY)
17 | public class MainActivity extends BaseActivity {
18 |
19 |
20 | @BindView(R2.id.module1_text)
21 | TextView module1Text;
22 |
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.module1_activity_main);
28 | initToolBar(getString(R.string.module1));
29 |
30 | if (this.getIntent() != null) {
31 | UserModel userModel = (UserModel) this.getIntent().getSerializableExtra("obj");
32 | if (userModel != null)
33 | module1Text.setText("带参数:"+userModel.getName() + "," + userModel.getMessage());
34 | }
35 | }
36 |
37 | /**
38 | * click方法中同样使用R2,但是找id的时候使用R,
39 | * ibrary中是不能使用 switch- case 找id的,原因:http://www.jianshu.com/p/89687f618837
40 | */
41 | @OnClick({R2.id.module1_button})
42 | public void onViewClicked(View view) {
43 | int id = view.getId();
44 | if (id == R.id.module1_button) {
45 | RouterUtils.navigation(RouterConstants.MODULE2_MAIN_ACTIVITY);
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/module1/src/main/java/com/wuxiaolong/module1/Module1Fragment.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.module1;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import com.alibaba.android.arouter.facade.annotation.Route;
11 | import com.wuxiaolong.router.RouterConstants;
12 |
13 |
14 | @Route(path = RouterConstants.MODULE1_MODULE1_FRAGMENT)
15 | public class Module1Fragment extends Fragment {
16 |
17 |
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
20 | Bundle savedInstanceState) {
21 | // Inflate the layout for this fragment
22 | return inflater.inflate(R.layout.module1_fragment_module1, container, false);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/module1/src/main/java/com/wuxiaolong/module1/Module1ServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.module1;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 |
6 | import com.alibaba.android.arouter.facade.annotation.Route;
7 | import com.wuxiaolong.router.Module1Service;
8 | import com.wuxiaolong.router.RouterConstants;
9 |
10 | /**
11 | * Created by WuXiaolong on 2017/7/24.
12 | * 个人博客:http://wuxiaolong.me
13 | */
14 | @Route(path = RouterConstants.MODULE1_SERVICE_IMPL)
15 | public class Module1ServiceImpl implements Module1Service {
16 | @Override
17 | public boolean share() {
18 | Log.d("wxl","share");
19 | return true;
20 | }
21 |
22 | @Override
23 | public void init(Context context) {
24 | Log.d("wxl","init="+context);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/module1/src/main/java/com/wuxiaolong/module1/debug/Module1Application.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.module1.debug;
2 |
3 | import android.app.Application;
4 |
5 | import com.alibaba.android.arouter.launcher.ARouter;
6 | import com.wuxiaolong.module1.BuildConfig;
7 |
8 | /**
9 | * Created by WuXiaolong on 2017/8/1.
10 | * 个人博客:http://wuxiaolong.me
11 | */
12 |
13 | public class Module1Application extends Application {
14 | @Override
15 | public void onCreate() {
16 | super.onCreate();
17 | if (BuildConfig.DEBUG) {
18 | // 这两行必须写在init之前,否则这些配置在init过程中将无效
19 | ARouter.openLog(); // 打印日志
20 | ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
21 | ARouter.printStackTrace(); // 打印日志的时候打印线程堆栈
22 | }
23 | ARouter.init(this); // 尽可能早,推荐在Application中初始化
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/module1/src/main/release/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/module1/src/main/res/layout/module1_activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
33 |
34 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/module1/src/main/res/layout/module1_fragment_module1.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/module2/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module2/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.jakewharton.butterknife'
2 | apply from: config
3 |
4 | dependencies {
5 | compile fileTree(dir: 'libs', include: ['*.jar'])
6 |
7 | //arouter
8 | annotationProcessor arouterCompiler
9 |
10 | compile project(':resource')
11 |
12 | //dagger2
13 | annotationProcessor dagger2Compiler
14 |
15 | //butterknife
16 | annotationProcessor butterknifeCompiler
17 | }
18 |
--------------------------------------------------------------------------------
/module2/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/wuxiaolong/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/module2/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/module2/src/main/java/com/wuxiaolong/module2/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.module2;
2 |
3 | import android.os.Bundle;
4 | import android.widget.TextView;
5 |
6 | import com.alibaba.android.arouter.facade.annotation.Route;
7 | import com.wuxiaolong.common.activity.ButterKnifeActivity;
8 | import com.wuxiaolong.common.model.WeatherModel;
9 | import com.wuxiaolong.common.retrofit.ApiCallback;
10 | import com.wuxiaolong.router.RouterConstants;
11 |
12 | import butterknife.BindView;
13 | import butterknife.ButterKnife;
14 | import butterknife.OnClick;
15 |
16 | @Route(path = RouterConstants.MODULE2_MAIN_ACTIVITY)
17 | public class MainActivity extends ButterKnifeActivity {
18 |
19 |
20 | @BindView(R2.id.module2_textview)
21 | TextView module2Textview;
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.module2_activity_main);
27 | ButterKnife.bind(this);
28 | initToolBar(getString(R.string.module2));
29 | }
30 |
31 | //全国+国外主要城市代码http://mobile.weather.com.cn/js/citylist.xml
32 | private void loadWeatherData() {
33 | showProgressDialog();
34 | addSubscription(apiStores().loadWeatherData("101190201"),
35 | new ApiCallback() {
36 | @Override
37 | public void onSuccess(WeatherModel model) {
38 | WeatherModel.WeatherinfoBean weatherinfo = model.getWeatherinfo();
39 | String showData = getResources().getString(R.string.city) + weatherinfo.getCity()
40 | + getResources().getString(R.string.wd) + weatherinfo.getWD()
41 | + getResources().getString(R.string.ws) + weatherinfo.getWS()
42 | + getResources().getString(R.string.time) + weatherinfo.getTime();
43 | module2Textview.setText(showData);
44 | }
45 |
46 | @Override
47 | public void onFailure(String msg) {
48 | toastShow(msg);
49 |
50 | }
51 |
52 | @Override
53 | public void onFinish() {
54 | dismissProgressDialog();
55 | }
56 | });
57 | }
58 |
59 | @OnClick(R2.id.module2_button)
60 | public void onViewClicked() {
61 | loadWeatherData();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/module2/src/main/release/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/module2/src/main/res/layout/module2_activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
32 |
33 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/resource/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/resource/build.gradle:
--------------------------------------------------------------------------------
1 | apply from: config
2 |
3 | dependencies {
4 | compile fileTree(dir: 'libs', include: ['*.jar'])
5 | compile project(':router')
6 | }
7 |
--------------------------------------------------------------------------------
/resource/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/wuxiaolong/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/resource/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/resource/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/resource/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/resource/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/resource/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/resource/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/resource/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/resource/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/resource/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/resource/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WuXiaolong/ModularSample/455bd390e29fbd43ed2c9a4ffbf18e7b39073896/resource/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resource/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ModularSample
3 | module2
4 | 城市:
5 | \n风向:
6 | \n风级:
7 | \n发布时间:
8 | module1
9 | 来自Module1Fragment
10 | app壳
11 | 跳转mudule2
12 |
13 |
--------------------------------------------------------------------------------
/resource/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/router/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/router/build.gradle:
--------------------------------------------------------------------------------
1 | apply from: config
2 |
3 | dependencies {
4 | compile fileTree(dir: 'libs', include: ['*.jar'])
5 | compile project(':common')
6 | //arouter
7 | compile arouterApi
8 | }
9 |
--------------------------------------------------------------------------------
/router/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/wuxiaolong/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/router/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/router/src/main/java/com/wuxiaolong/router/Module1Service.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.router;
2 |
3 | import com.alibaba.android.arouter.facade.template.IProvider;
4 |
5 | /**
6 | * Created by WuXiaolong on 2017/7/24.
7 | * 个人博客:http://wuxiaolong.me
8 | */
9 |
10 | public interface Module1Service extends IProvider {
11 | boolean share();
12 | }
13 |
--------------------------------------------------------------------------------
/router/src/main/java/com/wuxiaolong/router/RouterConstants.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.router;
2 |
3 | /**
4 | * Created by WuXiaolong on 2017/7/24.
5 | * 个人博客:http://wuxiaolong.me
6 | */
7 |
8 | public final class RouterConstants {
9 |
10 | /**
11 | * module1
12 | */
13 | public static final String MODULE1_MAIN_ACTIVITY = "/module1/MainActivity";
14 | public static final String MODULE1_SERVICE_IMPL = "/module1/Module1ServiceImpl";
15 | public static final String MODULE1_MODULE1_FRAGMENT = "/module1/Module1Fragment";
16 |
17 | /**
18 | * module2
19 | */
20 | public static final String MODULE2_MAIN_ACTIVITY = "/module2/MainActivity";
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/router/src/main/java/com/wuxiaolong/router/RouterUtils.java:
--------------------------------------------------------------------------------
1 | package com.wuxiaolong.router;
2 |
3 | import com.alibaba.android.arouter.launcher.ARouter;
4 |
5 | /**
6 | * Created by WuXiaolong on 2017/7/31.
7 | * 个人博客:http://wuxiaolong.me
8 | */
9 |
10 | public class RouterUtils {
11 | public static Object navigation(String path) {
12 | // 构建标准的路由请求
13 | return ARouter.getInstance().build(path).navigation();
14 | }
15 | public void startActivityForResult() {
16 | // 构建标准的路由请求,startActivityForResult
17 | // navigation的第一个参数必须是Activity,第二个参数则是RequestCode
18 | // ARouter.getInstance().build("/home/main").navigation(this, 5);
19 |
20 | }
21 |
22 | public void startActivityForCallback() {
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/router/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | router
3 |
4 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':module1', ':module2', ':common', ':resource', ':router'
2 |
--------------------------------------------------------------------------------
/versions.gradle:
--------------------------------------------------------------------------------
1 | ext{
2 | androidSupportVersion = '25.3.1'
3 | butterknifeVersion = '8.7.0'
4 |
5 |
6 | compile_sdk_version = 25
7 | build_tools_version = "26.0.0"
8 |
9 | min_sdk_version = 14 //兼容的最低 SDK 版本
10 | target_sdk_version = 22 //向前兼容,保存新旧两种逻辑,并通过 if-else 方法来判断执行哪种逻辑
11 |
12 | version_code = 3
13 | version_name = "0.03"
14 |
15 | appcompatV7 = "com.android.support:appcompat-v7:$androidSupportVersion"
16 | constraintLayout = 'com.android.support.constraint:constraint-layout:1.0.2'
17 |
18 | //arouter
19 | arouterApi = 'com.alibaba:arouter-api:1.2.1.1'
20 | arouterCompiler = 'com.alibaba:arouter-compiler:1.1.2.1'
21 | alibabaFastjson = 'com.alibaba:fastjson:1.2.9'
22 |
23 | //dagger2
24 | dagger2 = 'com.google.dagger:dagger:2.11'
25 | dagger2Compiler = 'com.google.dagger:dagger-compiler:2.11'
26 |
27 | //butterknife
28 | butterknife = "com.jakewharton:butterknife:$butterknifeVersion"
29 | butterknifeCompiler = "com.jakewharton:butterknife-compiler:$butterknifeVersion"
30 | }
--------------------------------------------------------------------------------