diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..916b245
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+*.iml
+.gradle
+/local.properties
+/.idea
+.DS_Store
+/build
+/captures
\ No newline at end of file
diff --git a/AndroidComponent.iml b/AndroidComponent.iml
deleted file mode 100644
index cdd69fd..0000000
--- a/AndroidComponent.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/AndroidComponentnew.iml b/AndroidComponentnew.iml
deleted file mode 100644
index ef51b06..0000000
--- a/AndroidComponentnew.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ComponentDemo.iml b/ComponentDemo.iml
deleted file mode 100644
index b84e3c9..0000000
--- a/ComponentDemo.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DDComponentForAndroid.iml b/DDComponentForAndroid.iml
deleted file mode 100644
index 8db4d4e..0000000
--- a/DDComponentForAndroid.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 6fa2be8..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright 2017 luoJiSiWei
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..4ca4dc2
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,7 @@
+Copyright (c) 2018 Beijing logicreation Information & Technology Co., Ltd
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/MyApplication.iml b/MyApplication.iml
deleted file mode 100644
index 6ffdfe3..0000000
--- a/MyApplication.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/README.md b/README.md
index 8358e9a..c6283a4 100644
--- a/README.md
+++ b/README.md
@@ -1,76 +1,88 @@
-## AndroidComponent
-原理解释请参考文章[Android彻底组件化方案实践](http://www.jianshu.com/p/1b1d77f58e84)
+## DDComponent
-demo解读请参考文章[Android彻底组件化demo发布](http://www.jianshu.com/p/59822a7b2fad)
+[](https://github.com/luojilab/DDComponentForAndroid/pulls)
+[](https://github.com/luojilab/DDComponentForAndroid/blob/master/LICENSE)
### 实现功能:
- 组件可以单独调试
+- 杜绝组件之前相互耦合,代码完全隔离,彻底解耦
- 组件之间通过接口+实现的方式进行数据传输
-- 使用schme和host路由的方式进行activity之间的跳转
+- 使用scheme和host路由的方式进行activity之间的跳转
+- 自动生成路由跳转路由表
- 任意组件可以充当host,集成其他组件进行集成调试
- 可以动态对已集成的组件进行加载和卸载
-- 杜绝组件之前相互耦合,代码完全隔离,彻底解耦
+- 支持kotlin组件
### 使用指南
#### 1、主项目引用编译脚本
在根目录的gradle.properties文件中,增加属性:
+
```ini
mainmodulename=app
```
其中mainmodulename是项目中的host工程,一般为app
在根目录的build.gradle中增加配置
+
```gradle
buildscript {
- repositories {
- maven {
- url uri('./repo')
- }
- }
dependencies {
- classpath 'com.mrzhang.andcomponent:build-gradle:0.0.1'
+ classpath 'com.luojilab.ddcomponent:build-gradle:1.2.0'
}
}
```
-注意:demo中使用本地的repo文件夹来充当maven库地址,请更换为自己的公司maven库
+
+为每个组件引入依赖库,如果项目中存在basiclib等基础库,可以统一交给basiclib引入
+
+```gradle
+compile 'com.luojilab.ddcomponent:componentlib:1.3.0'
+```
#### 2、拆分组件为module工程
在每个组件的工程目录下新建文件gradle.properties文件,增加以下配置:
+
```ini
isRunAlone=true
debugComponent=sharecomponent
-compileComponent=com.mrzhang.share:sharecomponent
+compileComponent=sharecomponent
```
上面三个属性分别对应是否单独调试、debug模式下依赖的组件,release模式下依赖的组件。具体使用方式请解释请参见上文第二篇文章
#### 3、应用组件化编译脚本
在组件和host的build.gradle都增加配置:
+
```gradle
apply plugin: 'com.dd.comgradle'
```
-不需要在引用com.android.application或者com.android.library
+
+注意:不需要在引用com.android.application或者com.android.library
同时增加以下extension配置:
+
```gradle
combuild {
- applicatonName = 'com.mrzhang.reader.runalone.application.ReaderApplication'
- isRegisterCompoAuto = false
+ applicationName = 'com.luojilab.reader.runalone.application.ReaderApplication'
+ isRegisterCompoAuto = true
}
```
-有关isRegisterCompoAuto的解释请参见上文第二篇文章
+组件注册还支持反射的方式,有关isRegisterCompoAuto的解释请参见上文第二篇文章
-### License
+#### 4、混淆
+在混淆文件中增加如下配置
+```
+-keep interface * {
+ ;
+}
+-keep class com.luojilab.component.componentlib.** {*;}
+-keep class com.luojilab.router.** {*;}
+-keep class com.luojilab.gen.** {*;}
+-keep class * implements com.luojilab.component.componentlib.router.ISyringe {*;}
+-keep class * implements com.luojilab.component.componentlib.applicationlike.IApplicationLike {*;}
+```
- Copyright 2017 luoJiSiWei
+关于如何进行组件之间数据交互和UI跳转,请参看 [Wiki](https://github.com/luojilab/DDComponentForAndroid/wiki)
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+### License
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+DDComponentForAndroid 使用的 MIT 协议,详细请参考 [LICENSE](https://github.com/luojilab/DDComponentForAndroid/blob/master/LICENSE.md)。
diff --git a/UIRouterTable/AppRouterTable.txt b/UIRouterTable/AppRouterTable.txt
new file mode 100644
index 0000000..c8bce69
--- /dev/null
+++ b/UIRouterTable/AppRouterTable.txt
@@ -0,0 +1,7 @@
+auto generated, do not change !!!!
+
+HOST : app
+
+首页
+/main
+
diff --git a/UIRouterTable/KotlinRouterTable.txt b/UIRouterTable/KotlinRouterTable.txt
new file mode 100644
index 0000000..35cca0e
--- /dev/null
+++ b/UIRouterTable/KotlinRouterTable.txt
@@ -0,0 +1,9 @@
+auto generated, do not change !!!!
+
+HOST : kotlin
+
+分享杂志页面
+/shareMagazine
+author:com.luojilab.componentservice.share.bean.AuthorKt
+bookName:String
+
diff --git a/UIRouterTable/ShareRouterTable.txt b/UIRouterTable/ShareRouterTable.txt
new file mode 100644
index 0000000..2a1176c
--- /dev/null
+++ b/UIRouterTable/ShareRouterTable.txt
@@ -0,0 +1,9 @@
+auto generated, do not change !!!!
+
+HOST : share
+
+分享书籍页面
+/shareBook
+author:com.luojilab.componentservice.share.bean.Author
+bookName:String
+
diff --git a/app/app.iml b/app/app.iml
deleted file mode 100644
index 9ad8818..0000000
--- a/app/app.iml
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index ee009a6..a5731d2 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,15 +1,22 @@
apply plugin: 'com.dd.comgradle'
android {
- compileSdkVersion 25
- buildToolsVersion "25.0.2"
+ compileSdkVersion 26
+ buildToolsVersion "26.0.1"
defaultConfig {
- applicationId "com.mrzhang.androidcomponent"
+ applicationId "com.luojilab.androidcomponent"
minSdkVersion 15
targetSdkVersion 14
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ javaCompileOptions {
+ annotationProcessorOptions {
+ arguments = [host: "app"]
+ }
+ }
+
}
buildTypes {
release {
@@ -18,18 +25,28 @@ android {
}
debug {
+ signingConfig signingConfigs.debug
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
+
+ lintOptions {
+ checkReleaseBuilds false
+ // Or, if you prefer, you can continue to check for errors in release builds,
+ // but continue the build even when errors are found:
+ abortOnError false
+ }
+
}
dependencies {
compile project(':componentservice')
+ annotationProcessor project(':router-anno-compiler')
}
combuild {
- applicatonName = 'com.mrzhang.component.application.AppApplication'
+ applicationName = 'com.luojilab.componentdemo.application.AppApplication'
isRegisterCompoAuto = true
}
diff --git a/app/gradle.properties b/app/gradle.properties
index 95a5887..d9730a6 100644
--- a/app/gradle.properties
+++ b/app/gradle.properties
@@ -12,7 +12,7 @@ org.gradle.jvmargs=-Xmx1536m
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
isRunAlone=true
-debugComponent=readercomponent,com.mrzhang.share:sharecomponent
-compileComponent=readercomponent,sharecomponent
+debugComponent=readercomponent,sharecomponent,sharecomponentkotlin
+compileComponent=readercomponent,sharecomponent,sharecomponentkotlin
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
index 8415401..db62c18 100644
--- a/app/proguard-rules.pro
+++ b/app/proguard-rules.pro
@@ -23,6 +23,34 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
--keep class com.mrzhang.component.componentlib.** {*;}
--keep class * implements com.mrzhang.component.componentlib.applicationlike.IApplicationLike {*;}
+-ignorewarnings
+-dontoptimize
+-keep class !android.support.v7.view.menu.*MenuBuilder*, android.support.v7.** { *; }
+-keep class android.support.v4.** { *; }
+-keep interface android.support.** { *; }
+-keepattributes Signature
+-keepattributes SourceFile,LineNumberTable
+-keep public class * extends android.support.**
+-keep public class * extends android.app.Fragment
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class * extends com.netease.ntespmmvp.** {*;}
+-keep enum * { *;}
+
+-keep interface * {
+ ;
+}
+-keep class com.luojilab.component.componentlib.** {*;}
+-keep class com.luojilab.router.** {*;}
+-keep class com.luojilab.gen.** {*;}
+-keep class * implements com.luojilab.component.componentlib.router.ISyringe {*;}
+-keep class * implements com.luojilab.component.componentlib.applicationlike.IApplicationLike {*;}
+-dontwarn okio.**
+-dontwarn okhttp3.**
+-dontwarn com.squareup.**
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index eceebb8..99b06f4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,10 +1,10 @@
+ xmlns:tools="http://schemas.android.com/tools"
+ package="com.luojilab.componentdemo">
-
+
-
+
-
+
diff --git a/app/src/main/java/com/mrzhang/component/MainActivity.java b/app/src/main/java/com/luojilab/componentdemo/MainActivity.java
similarity index 52%
rename from app/src/main/java/com/mrzhang/component/MainActivity.java
rename to app/src/main/java/com/luojilab/componentdemo/MainActivity.java
index 16d052e..2f598e4 100644
--- a/app/src/main/java/com/mrzhang/component/MainActivity.java
+++ b/app/src/main/java/com/luojilab/componentdemo/MainActivity.java
@@ -1,16 +1,21 @@
-package com.mrzhang.component;
+package com.luojilab.componentdemo;
+import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
-import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
-import com.mrzhang.component.componentlib.router.Router;
-import com.mrzhang.componentservice.readerbook.ReadBookService;
+import com.luojilab.component.basiclib.ToastManager;
+import com.luojilab.component.basicres.BaseActivity;
+import com.luojilab.component.basicres.BaseApplication;
+import com.luojilab.component.componentlib.router.Router;
+import com.luojilab.componentservice.readerbook.ReadBookService;
+import com.luojilab.router.facade.annotation.RouteNode;
-public class MainActivity extends AppCompatActivity implements View.OnClickListener {
+@RouteNode(path = "/main", desc = "首页")
+public class MainActivity extends BaseActivity implements View.OnClickListener {
Fragment fragment;
FragmentTransaction ft;
@@ -23,13 +28,14 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- installReadBookBtn = (Button) findViewById(R.id.install_share);
- uninstallReadBtn = (Button) findViewById(R.id.uninstall_share);
+ installReadBookBtn = findViewById(R.id.install_share);
+ uninstallReadBtn = findViewById(R.id.uninstall_share);
installReadBookBtn.setOnClickListener(this);
uninstallReadBtn.setOnClickListener(this);
showFragment();
}
+
private void showFragment() {
if (fragment != null) {
ft = getSupportFragmentManager().beginTransaction();
@@ -49,11 +55,22 @@ private void showFragment() {
public void onClick(View v) {
switch (v.getId()) {
case R.id.install_share:
- Router.registerComponent("com.mrzhang.share.applike.ShareApplike");
+ Router.registerComponent("com.luojilab.share.applike.ShareApplike");
+ Router.registerComponent("com.luojilab.share.kotlin.applike.KotlinApplike");
break;
case R.id.uninstall_share:
- Router.unregisterComponent("com.mrzhang.share.applike.ShareApplike");
+ Router.unregisterComponent("com.luojilab.share.applike.ShareApplike");
+ Router.unregisterComponent("com.luojilab.share.kotlin.applike.KotlinApplike");
break;
}
}
+
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (data != null) {
+ ToastManager.show(BaseApplication.getAppContext(), data.getStringExtra("result"));
+ }
+ }
}
diff --git a/app/src/main/java/com/luojilab/componentdemo/application/AppApplication.java b/app/src/main/java/com/luojilab/componentdemo/application/AppApplication.java
new file mode 100644
index 0000000..3e3860d
--- /dev/null
+++ b/app/src/main/java/com/luojilab/componentdemo/application/AppApplication.java
@@ -0,0 +1,24 @@
+package com.luojilab.componentdemo.application;
+
+import com.luojilab.component.basicres.BaseApplication;
+import com.luojilab.component.componentlib.router.ui.UIRouter;
+
+/**
+ * Created by mrzhang on 2017/6/15.
+ */
+
+public class AppApplication extends BaseApplication {
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ UIRouter.getInstance().registerUI("app");
+
+ //如果isRegisterCompoAuto为false,则需要通过反射加载组件
+// Router.registerComponent("com.luojilab.reader.applike.ReaderAppLike");
+// Router.registerComponent("com.luojilab.share.applike.ShareApplike");
+ }
+
+
+}
diff --git a/app/src/main/java/com/mrzhang/component/utils/Utils.java b/app/src/main/java/com/luojilab/componentdemo/utils/Utils.java
similarity index 91%
rename from app/src/main/java/com/mrzhang/component/utils/Utils.java
rename to app/src/main/java/com/luojilab/componentdemo/utils/Utils.java
index 790977a..9127034 100644
--- a/app/src/main/java/com/mrzhang/component/utils/Utils.java
+++ b/app/src/main/java/com/luojilab/componentdemo/utils/Utils.java
@@ -1,4 +1,4 @@
-package com.mrzhang.component.utils;
+package com.luojilab.componentdemo.utils;
import android.content.res.Resources;
diff --git a/app/src/main/java/com/mrzhang/component/application/AppApplication.java b/app/src/main/java/com/mrzhang/component/application/AppApplication.java
deleted file mode 100644
index 2fc73df..0000000
--- a/app/src/main/java/com/mrzhang/component/application/AppApplication.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.mrzhang.component.application;
-
-import android.app.Application;
-
-/**
- * Created by mrzhang on 2017/6/15.
- */
-
-public class AppApplication extends Application {
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- //如果isRegisterCompoAuto为false,则需要通过反射加载组件
-// Router.registerComponent("com.mrzhang.reader.applike.ReaderAppLike");
-// Router.registerComponent("com.mrzhang.share.applike.ShareApplike");
-
- }
-
-
-}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index fb57783..5497e93 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,4 +1,5 @@
+
+
diff --git a/basiclib/basiclib.iml b/basiclib/basiclib.iml
deleted file mode 100644
index 12cec8e..0000000
--- a/basiclib/basiclib.iml
+++ /dev/null
@@ -1,126 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/basiclib/build.gradle b/basiclib/build.gradle
index d92c552..2ff7c58 100644
--- a/basiclib/build.gradle
+++ b/basiclib/build.gradle
@@ -28,6 +28,8 @@ dependencies {
})
compile 'com.android.support:appcompat-v7:26.+'
testCompile 'junit:junit:4.12'
- compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.picasso:picasso:2.5.2'
+// compile 'com.luojilab.ddcomponent:componentlib:1.0.0'
+ compile project(":componentlib")
}
+
diff --git a/basiclib/src/androidTest/java/com/mrzhang/component/componentlib/ExampleInstrumentedTest.java b/basiclib/src/androidTest/java/com/mrzhang/component/componentlib/ExampleInstrumentedTest.java
deleted file mode 100644
index 9fcffdb..0000000
--- a/basiclib/src/androidTest/java/com/mrzhang/component/componentlib/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.mrzhang.component.componentlib;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("com.mrzhang.component.basiclib.test", appContext.getPackageName());
- }
-}
diff --git a/basiclib/src/main/AndroidManifest.xml b/basiclib/src/main/AndroidManifest.xml
index 2e65992..255ff44 100644
--- a/basiclib/src/main/AndroidManifest.xml
+++ b/basiclib/src/main/AndroidManifest.xml
@@ -1,11 +1,11 @@
+ package="com.luojilab.component.basiclib">
diff --git a/basiclib/src/main/java/com.luojilab.component.basiclib/ToastManager.java b/basiclib/src/main/java/com.luojilab.component.basiclib/ToastManager.java
new file mode 100644
index 0000000..a404b5b
--- /dev/null
+++ b/basiclib/src/main/java/com.luojilab.component.basiclib/ToastManager.java
@@ -0,0 +1,31 @@
+package com.luojilab.component.basiclib;
+
+import android.content.Context;
+import android.widget.Toast;
+
+/**
+ * Created by mrzhang on 2018/1/16.
+ */
+
+public class ToastManager {
+
+ private ToastManager() {
+ }
+
+ public static void show(Context context, String message) {
+ Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
+ }
+
+ public static void show(Context context, int resId) {
+ show(context, context.getString(resId));
+ }
+
+ public static void show(Context context, int resId, Object... args) {
+ show(context, String.format(context.getString(resId), args));
+ }
+
+ public static void show(Context context, String message, int duration) {
+ Toast.makeText(context, message, duration).show();
+ }
+
+}
diff --git a/basiclib/src/main/res/values/strings.xml b/basiclib/src/main/res/values/strings.xml
index 5c8e5a1..0d51c39 100644
--- a/basiclib/src/main/res/values/strings.xml
+++ b/basiclib/src/main/res/values/strings.xml
@@ -1,3 +1,3 @@
- basiclib
+ basiclib
diff --git a/basiclib/src/test/java/com/mrzhang/component/componentlib/ExampleUnitTest.java b/basiclib/src/test/java/com/mrzhang/component/componentlib/ExampleUnitTest.java
deleted file mode 100644
index d4197d1..0000000
--- a/basiclib/src/test/java/com/mrzhang/component/componentlib/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.mrzhang.component.componentlib;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/basicres/basicres.iml b/basicres/basicres.iml
deleted file mode 100644
index 48f6b01..0000000
--- a/basicres/basicres.iml
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/basicres/build.gradle b/basicres/build.gradle
index 4f4949d..7d78e9a 100644
--- a/basicres/build.gradle
+++ b/basicres/build.gradle
@@ -6,7 +6,7 @@ android {
defaultConfig {
minSdkVersion 15
- targetSdkVersion 26
+ targetSdkVersion 14
versionCode 1
versionName "1.0"
@@ -25,4 +25,8 @@ android {
dependencies {
compile project(':basiclib')
+ testCompile 'junit:junit:4.12'
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
}
diff --git a/basicres/src/androidTest/java/com/mrzhang/component/basicres/ExampleInstrumentedTest.java b/basicres/src/androidTest/java/com/mrzhang/component/basicres/ExampleInstrumentedTest.java
deleted file mode 100644
index c3fa77f..0000000
--- a/basicres/src/androidTest/java/com/mrzhang/component/basicres/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.mrzhang.component.basicres;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("com.mrzhang.component.basicres.test", appContext.getPackageName());
- }
-}
diff --git a/basicres/src/main/AndroidManifest.xml b/basicres/src/main/AndroidManifest.xml
index 859d449..f8da273 100644
--- a/basicres/src/main/AndroidManifest.xml
+++ b/basicres/src/main/AndroidManifest.xml
@@ -1,8 +1,8 @@
+ package="com.luojilab.component.basicres">
-
diff --git a/basicres/src/main/java/com/luojilab/component/basicres/BaseActivity.java b/basicres/src/main/java/com/luojilab/component/basicres/BaseActivity.java
new file mode 100644
index 0000000..99ba726
--- /dev/null
+++ b/basicres/src/main/java/com/luojilab/component/basicres/BaseActivity.java
@@ -0,0 +1,20 @@
+package com.luojilab.component.basicres;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+
+import com.luojilab.component.componentlib.service.AutowiredService;
+
+/**
+ * Created by mrzhang on 2018/1/16.
+ */
+
+public class BaseActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ AutowiredService.Factory.getInstance().create().autowire(this);
+ }
+}
diff --git a/basicres/src/main/java/com/luojilab/component/basicres/BaseApplication.java b/basicres/src/main/java/com/luojilab/component/basicres/BaseApplication.java
new file mode 100644
index 0000000..4033507
--- /dev/null
+++ b/basicres/src/main/java/com/luojilab/component/basicres/BaseApplication.java
@@ -0,0 +1,24 @@
+package com.luojilab.component.basicres;
+
+import android.app.Application;
+import android.support.annotation.Nullable;
+
+/**
+ * Created by mrzhang on 2018/1/16.
+ */
+
+public class BaseApplication extends Application {
+
+ private static BaseApplication mAppCotext;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ mAppCotext = this;
+ }
+
+ @Nullable
+ public static Application getAppContext() {
+ return mAppCotext;
+ }
+}
diff --git a/basicres/src/test/java/com/mrzhang/component/basicres/ExampleUnitTest.java b/basicres/src/test/java/com/mrzhang/component/basicres/ExampleUnitTest.java
deleted file mode 100644
index 8454a35..0000000
--- a/basicres/src/test/java/com/mrzhang/component/basicres/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.mrzhang.component.basicres;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/build-gradle/.gitignore b/build-gradle/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/build-gradle/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/build-gradle/build-gradle.iml b/build-gradle/build-gradle.iml
deleted file mode 100644
index 2820ec7..0000000
--- a/build-gradle/build-gradle.iml
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build-gradle/build.gradle b/build-gradle/build.gradle
index 3c7e919..7b6a424 100644
--- a/build-gradle/build.gradle
+++ b/build-gradle/build.gradle
@@ -1,5 +1,17 @@
apply plugin: 'groovy'
-apply plugin: 'maven'
+
+ext {
+ bintrayName = 'build-gradle'
+ artifact = bintrayName
+ libraryName = 'component build'
+ libraryDescription = 'gradle plugin for buid component'
+ libraryVersion = "1.2.0"
+ licenseName = 'The Apache Software License, Version 2.0'
+ licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ allLicenses = ["Apache-2.0"]
+}
+apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
+apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
dependencies {
compile 'com.android.tools.build:gradle:2.3.2'
@@ -10,17 +22,3 @@ dependencies {
compile localGroovy()
}
-repositories {
- mavenCentral()
-}
-
-group = 'com.mrzhang.andcomponent'
-version = '0.0.1'
-
-uploadArchives {
- repositories {
- mavenDeployer {
- repository(url: uri('../repo'))
- }
- }
-}
\ No newline at end of file
diff --git a/build-gradle/src/main/groovy/com.dd.buildgradle/ComBuild.groovy b/build-gradle/src/main/groovy/com.dd.buildgradle/ComBuild.groovy
index 98c76b1..b29ea9b 100644
--- a/build-gradle/src/main/groovy/com.dd.buildgradle/ComBuild.groovy
+++ b/build-gradle/src/main/groovy/com.dd.buildgradle/ComBuild.groovy
@@ -3,9 +3,8 @@ package com.dd.buildgradle
import com.dd.buildgradle.exten.ComExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
-import org.gradle.api.Task
-public class ComBuild implements Plugin {
+class ComBuild implements Plugin {
//默认是app,直接运行assembleRelease的时候,等同于运行app:assembleRelease
String compilemodule = "app"
@@ -14,14 +13,14 @@ public class ComBuild implements Plugin {
project.extensions.create('combuild', ComExtension)
String taskNames = project.gradle.startParameter.taskNames.toString()
- System.out.println("taskNames is " + taskNames);
+ System.out.println("taskNames is " + taskNames)
String module = project.path.replace(":", "")
- System.out.println("current module is " + module);
+ System.out.println("current module is " + module)
AssembleTask assembleTask = getTaskInfo(project.gradle.startParameter.taskNames)
if (assembleTask.isAssemble) {
- fetchMainmodulename(project, assembleTask);
- System.out.println("compilemodule is " + compilemodule);
+ fetchMainModulename(project, assembleTask)
+ System.out.println("compilemodule is " + compilemodule)
}
if (!project.hasProperty("isRunAlone")) {
@@ -29,16 +28,16 @@ public class ComBuild implements Plugin {
}
//对于isRunAlone==true的情况需要根据实际情况修改其值,
- // 但如果是false,则不用修改,该module作为一个lib,运行module:assembleRelease则发布aar到中央仓库
+ // 但如果是false,则不用修改
boolean isRunAlone = Boolean.parseBoolean((project.properties.get("isRunAlone")))
+ String mainmodulename = project.rootProject.property("mainmodulename")
if (isRunAlone && assembleTask.isAssemble) {
- String mainmodulename = project.rootProject.property("mainmodulename")
//对于要编译的组件和主项目,isRunAlone修改为true,其他组件都强制修改为false
//这就意味着组件不能引用主项目,这在层级结构里面也是这么规定的
if (module.equals(compilemodule) || module.equals(mainmodulename)) {
- isRunAlone = true;
+ isRunAlone = true
} else {
- isRunAlone = false;
+ isRunAlone = false
}
}
project.setProperty("isRunAlone", isRunAlone)
@@ -46,32 +45,25 @@ public class ComBuild implements Plugin {
//根据配置添加各种组件依赖,并且自动化生成组件加载代码
if (isRunAlone) {
project.apply plugin: 'com.android.application'
- System.out.println("apply plugin is " + 'com.android.application');
+ if (!module.equals(mainmodulename)) {
+ project.android.sourceSets {
+ main {
+ manifest.srcFile 'src/main/runalone/AndroidManifest.xml'
+ java.srcDirs = ['src/main/java', 'src/main/runalone/java']
+ res.srcDirs = ['src/main/res', 'src/main/runalone/res']
+ assets.srcDirs = ['src/main/assets', 'src/main/runalone/assets']
+ jniLibs.srcDirs = ['src/main/jniLibs', 'src/main/runalone/jniLibs']
+ }
+ }
+ }
+ System.out.println("apply plugin is " + 'com.android.application')
if (assembleTask.isAssemble && module.equals(compilemodule)) {
compileComponents(assembleTask, project)
project.android.registerTransform(new ComCodeTransform(project))
}
} else {
project.apply plugin: 'com.android.library'
- System.out.println("apply plugin is " + 'com.android.library');
- project.afterEvaluate {
- Task assembleReleaseTask = project.tasks.findByPath("assembleRelease")
- if (assembleReleaseTask != null) {
- assembleReleaseTask.doLast {
- File infile = project.file("build/outputs/aar/$module-release.aar")
- File outfile = project.file("../componentrelease")
- File desFile = project.file("$module-release.aar");
- project.copy {
- from infile
- into outfile
- rename {
- String fileName -> desFile.name
- }
- }
- System.out.println("$module-release.aar copy success ");
- }
- }
- }
+ System.out.println("apply plugin is " + 'com.android.library')
}
}
@@ -83,14 +75,14 @@ public class ComBuild implements Plugin {
* sharecomponent:assembleRelease :sharecomponent:assembleRelease ---sharecomponent
* @param assembleTask
*/
- private void fetchMainmodulename(Project project, AssembleTask assembleTask) {
+ private void fetchMainModulename(Project project, AssembleTask assembleTask) {
if (!project.rootProject.hasProperty("mainmodulename")) {
throw new RuntimeException("you should set compilemodule in rootproject's gradle.properties")
}
if (assembleTask.modules.size() > 0 && assembleTask.modules.get(0) != null
&& assembleTask.modules.get(0).trim().length() > 0
&& !assembleTask.modules.get(0).equals("all")) {
- compilemodule = assembleTask.modules.get(0);
+ compilemodule = assembleTask.modules.get(0)
} else {
compilemodule = project.rootProject.property("mainmodulename")
}
@@ -100,16 +92,20 @@ public class ComBuild implements Plugin {
}
private AssembleTask getTaskInfo(List taskNames) {
- AssembleTask assembleTask = new AssembleTask();
+ AssembleTask assembleTask = new AssembleTask()
for (String task : taskNames) {
- if (task.toUpperCase().contains("ASSEMBLE") || task.toUpperCase().contains("RESGUARD")) {
+ if (task.toUpperCase().contains("ASSEMBLE")
+ || task.contains("aR")
+ || task.toUpperCase().contains("TINKER")
+ || task.toUpperCase().contains("INSTALL")
+ || task.toUpperCase().contains("RESGUARD")) {
if (task.toUpperCase().contains("DEBUG")) {
- assembleTask.isDebug = true;
+ assembleTask.isDebug = true
}
- assembleTask.isAssemble = true;
+ assembleTask.isAssemble = true
String[] strs = task.split(":")
- assembleTask.modules.add(strs.length > 1 ? strs[strs.length - 2] : "all");
- break;
+ assembleTask.modules.add(strs.length > 1 ? strs[strs.length - 2] : "all")
+ break
}
}
return assembleTask
@@ -117,12 +113,12 @@ public class ComBuild implements Plugin {
/**
* 自动添加依赖,只在运行assemble任务的才会添加依赖,因此在开发期间组件之间是完全感知不到的,这是做到完全隔离的关键
- * 支持两种语法:module或者modulePackage:module,前者之间引用module工程,后者使用componentrelease中已经发布的aar
+ * 支持两种语法:module或者groupId:artifactId:version(@aar),前者之间引用module工程,后者使用maven中已经发布的aar
* @param assembleTask
* @param project
*/
private void compileComponents(AssembleTask assembleTask, Project project) {
- String components;
+ String components
if (assembleTask.isDebug) {
components = (String) project.properties.get("debugComponent")
} else {
@@ -130,35 +126,39 @@ public class ComBuild implements Plugin {
}
if (components == null || components.length() == 0) {
- System.out.println("there is no add dependencies ");
- return;
+ System.out.println("there is no add dependencies ")
+ return
}
String[] compileComponents = components.split(",")
if (compileComponents == null || compileComponents.length == 0) {
- System.out.println("there is no add dependencies ");
- return;
+ System.out.println("there is no add dependencies ")
+ return
}
for (String str : compileComponents) {
- System.out.println("comp is " + str);
+ System.out.println("comp is " + str)
if (str.contains(":")) {
- File file = project.file("../componentrelease/" + str.split(":")[1] + "-release.aar")
- if (file.exists()) {
- project.dependencies.add("compile", str + "-release@aar")
- System.out.println("add dependencies : " + str + "-release@aar");
- } else {
- throw new RuntimeException(str + " not found ! maybe you should generate a new one ")
- }
+ /**
+ * 示例语法:groupId:artifactId:version(@aar)
+ * compileComponent=com.luojilab.reader:readercomponent:1.0.0
+ * 注意,前提是已经将组件aar文件发布到maven上,并配置了相应的repositories
+ */
+ project.dependencies.add("compile", str)
+ System.out.println("add dependencies lib : " + str)
} else {
+ /**
+ * 示例语法:module
+ * compileComponent=readercomponent,sharecomponent
+ */
project.dependencies.add("compile", project.project(':' + str))
- System.out.println("add dependencies project : " + str);
+ System.out.println("add dependencies project : " + str)
}
}
}
private class AssembleTask {
- boolean isAssemble = false;
- boolean isDebug = false;
- List modules = new ArrayList<>();
+ boolean isAssemble = false
+ boolean isDebug = false
+ List modules = new ArrayList<>()
}
}
\ No newline at end of file
diff --git a/build-gradle/src/main/groovy/com.dd.buildgradle/ComCodeTransform.groovy b/build-gradle/src/main/groovy/com.dd.buildgradle/ComCodeTransform.groovy
index 8997ccc..d0e9607 100644
--- a/build-gradle/src/main/groovy/com.dd.buildgradle/ComCodeTransform.groovy
+++ b/build-gradle/src/main/groovy/com.dd.buildgradle/ComCodeTransform.groovy
@@ -7,11 +7,11 @@ import org.apache.commons.codec.digest.DigestUtils
import org.apache.commons.io.FileUtils
import org.gradle.api.Project
-public class ComCodeTransform extends Transform {
+class ComCodeTransform extends Transform {
private Project project
ClassPool classPool
- String applicationName;
+ String applicationName
ComCodeTransform(Project project) {
this.project = project
@@ -19,7 +19,7 @@ public class ComCodeTransform extends Transform {
@Override
void transform(TransformInvocation transformInvocation) throws TransformException, InterruptedException, IOException {
- getRealApplicationName(transformInvocation.getInputs());
+ getRealApplicationName(transformInvocation.getInputs())
classPool = new ClassPool()
project.android.bootClasspath.each {
classPool.appendClassPath((String) it.absolutePath)
@@ -27,24 +27,24 @@ public class ComCodeTransform extends Transform {
def box = ConvertUtils.toCtClasses(transformInvocation.getInputs(), classPool)
//要收集的application,一般情况下只有一个
- List applications = new ArrayList<>();
+ List applications = new ArrayList<>()
//要收集的applicationlikes,一般情况下有几个组件就有几个applicationlike
- List activators = new ArrayList<>();
+ List activators = new ArrayList<>()
for (CtClass ctClass : box) {
if (isApplication(ctClass)) {
applications.add(ctClass)
- continue;
+ continue
}
if (isActivator(ctClass)) {
activators.add(ctClass)
}
}
for (CtClass ctClass : applications) {
- System.out.println("application is " + ctClass.getName());
+ System.out.println("application is " + ctClass.getName())
}
for (CtClass ctClass : activators) {
- System.out.println("applicationlike is " + ctClass.getName());
+ System.out.println("applicationlike is " + ctClass.getName())
}
transformInvocation.inputs.each { TransformInput input ->
@@ -72,11 +72,13 @@ public class ComCodeTransform extends Transform {
File dir = new File(fileName)
dir.eachFileRecurse { File file ->
String filePath = file.absolutePath
- String classNameTemp = filePath.replace(fileName, "").replace("\\", ".").replace("/", ".")
+ String classNameTemp = filePath.replace(fileName, "")
+ .replace("\\", ".")
+ .replace("/", ".")
if (classNameTemp.endsWith(".class")) {
String className = classNameTemp.substring(1, classNameTemp.length() - 6)
if (className.equals(applicationName)) {
- injectApplicationCode(applications.get(0), activators, fileName);
+ injectApplicationCode(applications.get(0), activators, fileName)
}
}
}
@@ -92,7 +94,7 @@ public class ComCodeTransform extends Transform {
private void getRealApplicationName(Collection inputs) {
- applicationName = project.extensions.combuild.applicatonName
+ applicationName = project.extensions.combuild.applicationName
if (applicationName == null || applicationName.isEmpty()) {
throw new RuntimeException("you should set applicationName in combuild")
}
@@ -100,30 +102,30 @@ public class ComCodeTransform extends Transform {
private void injectApplicationCode(CtClass ctClassApplication, List activators, String patch) {
- System.out.println("injectApplicationCode begin");
- ctClassApplication.defrost();
+ System.out.println("injectApplicationCode begin")
+ ctClassApplication.defrost()
try {
CtMethod attachBaseContextMethod = ctClassApplication.getDeclaredMethod("onCreate", null)
attachBaseContextMethod.insertAfter(getAutoLoadComCode(activators))
} catch (CannotCompileException | NotFoundException e) {
- StringBuilder methodBody = new StringBuilder();
- methodBody.append("protected void onCreate() {");
- methodBody.append("super.onCreate();");
+ StringBuilder methodBody = new StringBuilder()
+ methodBody.append("protected void onCreate() {")
+ methodBody.append("super.onCreate();")
methodBody.
- append(getAutoLoadComCode(activators));
- methodBody.append("}");
- ctClassApplication.addMethod(CtMethod.make(methodBody.toString(), ctClassApplication));
+ append(getAutoLoadComCode(activators))
+ methodBody.append("}")
+ ctClassApplication.addMethod(CtMethod.make(methodBody.toString(), ctClassApplication))
} catch (Exception e) {
}
ctClassApplication.writeFile(patch)
ctClassApplication.detach()
- System.out.println("injectApplicationCode success ");
+ System.out.println("injectApplicationCode success ")
}
private String getAutoLoadComCode(List activators) {
- StringBuilder autoLoadComCode = new StringBuilder();
+ StringBuilder autoLoadComCode = new StringBuilder()
for (CtClass ctClass : activators) {
autoLoadComCode.append("new " + ctClass.getName() + "()" + ".onCreate();")
}
@@ -135,26 +137,26 @@ public class ComCodeTransform extends Transform {
private boolean isApplication(CtClass ctClass) {
try {
if (applicationName != null && applicationName.equals(ctClass.getName())) {
- return true;
+ return true
}
} catch (Exception e) {
println "class not found exception class name: " + ctClass.getName()
}
- return false;
+ return false
}
private boolean isActivator(CtClass ctClass) {
try {
for (CtClass ctClassInter : ctClass.getInterfaces()) {
- if ("com.mrzhang.component.componentlib.applicationlike.IApplicationLike".equals(ctClassInter.name)) {
- return true;
+ if ("com.luojilab.component.componentlib.applicationlike.IApplicationLike".equals(ctClassInter.name)) {
+ return true
}
}
} catch (Exception e) {
println "class not found exception class name: " + ctClass.getName()
}
- return false;
+ return false
}
@Override
diff --git a/build-gradle/src/main/groovy/com.dd.buildgradle/ConvertUtils.groovy b/build-gradle/src/main/groovy/com.dd.buildgradle/ConvertUtils.groovy
index 038db6b..cd06dbe 100644
--- a/build-gradle/src/main/groovy/com.dd.buildgradle/ConvertUtils.groovy
+++ b/build-gradle/src/main/groovy/com.dd.buildgradle/ConvertUtils.groovy
@@ -12,7 +12,7 @@ import java.util.regex.Matcher
class ConvertUtils {
static List toCtClasses(Collection inputs, ClassPool classPool) {
List classNames = new ArrayList<>()
- List allClass = new ArrayList<>();
+ List allClass = new ArrayList<>()
inputs.each {
it.directoryInputs.each {
def dirPath = it.file.absolutePath
@@ -31,10 +31,10 @@ class ConvertUtils {
it.jarInputs.each {
classPool.insertClassPath(it.file.absolutePath)
def jarFile = new JarFile(it.file)
- Enumeration classes = jarFile.entries();
+ Enumeration classes = jarFile.entries()
while (classes.hasMoreElements()) {
- JarEntry libClass = classes.nextElement();
- String className = libClass.getName();
+ JarEntry libClass = classes.nextElement()
+ String className = libClass.getName()
if (className.endsWith(SdkConstants.DOT_CLASS)) {
className = className.substring(0, className.length() - SdkConstants.DOT_CLASS.length()).replaceAll('/', '.')
if (classNames.contains(className)) {
@@ -47,12 +47,12 @@ class ConvertUtils {
}
classNames.each {
try {
- allClass.add(classPool.get(it));
+ allClass.add(classPool.get(it))
} catch (javassist.NotFoundException e) {
println "class not found exception class name: $it "
}
}
- return allClass;
+ return allClass
}
diff --git a/build-gradle/src/main/groovy/com.dd.buildgradle/exten/ComExtension.groovy b/build-gradle/src/main/groovy/com.dd.buildgradle/exten/ComExtension.groovy
index f96025d..d92ee1c 100644
--- a/build-gradle/src/main/groovy/com.dd.buildgradle/exten/ComExtension.groovy
+++ b/build-gradle/src/main/groovy/com.dd.buildgradle/exten/ComExtension.groovy
@@ -9,10 +9,10 @@ public class ComExtension {
boolean isRegisterCompoAuto = false;
/**
- * 当前组件的applicatonName,用于字节码插入。
+ * 当前组件的applicationName,用于字节码插入。
* 当isRegisterCompoAuto==true的时候是必须的
*/
- String applicatonName
+ String applicationName
}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 90cc5d4..5e7241d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,28 +1,31 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
+ ext.kotlin_version = '1.2.21'
repositories {
jcenter()
maven { url "https://jitpack.io/" }
maven {
- url uri('./repo')
+ url 'https://maven.google.com/'
+ name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
- classpath 'com.mrzhang.andcomponent:build-gradle:0.0.1'
+ classpath 'com.luojilab.ddcomponent:build-gradle:1.1.0'
+ classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
+ classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
- flatDir {
- dirs '../componentrelease' //this way we can find the .aar file in folder
- }
maven { url "https://jitpack.io/" }
maven {
- url uri('./repo')
+ url 'https://maven.google.com/'
+ name 'Google'
}
}
}
\ No newline at end of file
diff --git a/componentlib/build.gradle b/componentlib/build.gradle
index 9f41ee4..c4fe279 100644
--- a/componentlib/build.gradle
+++ b/componentlib/build.gradle
@@ -3,12 +3,24 @@ apply plugin: 'com.android.library'
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
+
+ext {
+ bintrayName = 'componentlib'
+ artifact = bintrayName
+ libraryName = 'component build lib '
+ libraryDescription = 'component build lib '
+ libraryVersion = "1.3.0"
+ licenseName = 'The Apache Software License, Version 2.0'
+ licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ allLicenses = ["Apache-2.0"]
+}
+
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
- minSdkVersion 14
+ minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
@@ -25,39 +37,17 @@ android {
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
+ compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:26.+'
-}
-
-
-def sdk_appendix = "baselib"
-def sdk_baseName = "component"
-def sdk_version = "0.0.2"
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ testCompile 'junit:junit:4.12'
+ compile project(':router-annotation')
+ compile 'com.google.code.gson:gson:2.8.2'
-task buildJar(dependsOn: ['compileReleaseJavaWithJavac'], type: Jar) {
-
- appendix = sdk_appendix
- baseName = sdk_baseName
- version = sdk_version
- //classifier = "release"
- //后缀名
- extension = "jar"
- //最终的Jar 包名 , 如果没设置 , 默认为[baseName] - [appendix] - [version] - [classifier].[extension]
-
- // 需打包的资源所在的路径集
- def srcClassDir = [project.buildDir.absolutePath + "/intermediates/classes/release"];
- //初始化资源路径集
- from srcClassDir
-
- //排除这两个文件
- include("com/mrzhang/**/*.class")
- exclude("com/mrzhang/component/componentlib/BuildConfig.class",
- "com/mrzhang/component/componentlib/R.class",
- "com/mrzhang/component/componentlib/R\$*.class")
}
-task buildJarAndCopy(dependsOn: "buildJar", type: Copy) {
- from(project.buildDir.absolutePath + "/libs")
- include(sdk_baseName + "-" + sdk_appendix + "-" + sdk_version + ".jar")
- into("release")
-}
+
+apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
+apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
\ No newline at end of file
diff --git a/componentlib/componentlib.iml b/componentlib/componentlib.iml
deleted file mode 100644
index 2be6506..0000000
--- a/componentlib/componentlib.iml
+++ /dev/null
@@ -1,116 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/componentlib/src/main/AndroidManifest.xml b/componentlib/src/main/AndroidManifest.xml
index bbdb208..594addb 100644
--- a/componentlib/src/main/AndroidManifest.xml
+++ b/componentlib/src/main/AndroidManifest.xml
@@ -1,10 +1,4 @@
-
-
-
-
+ package="com.luojilab.component.componentlib">
diff --git a/componentlib/src/main/java/com/mrzhang/component/componentlib/applicationlike/IApplicationLike.java b/componentlib/src/main/java/com/luojilab/component/componentlib/applicationlike/IApplicationLike.java
similarity index 67%
rename from componentlib/src/main/java/com/mrzhang/component/componentlib/applicationlike/IApplicationLike.java
rename to componentlib/src/main/java/com/luojilab/component/componentlib/applicationlike/IApplicationLike.java
index 191caca..fd3774d 100644
--- a/componentlib/src/main/java/com/mrzhang/component/componentlib/applicationlike/IApplicationLike.java
+++ b/componentlib/src/main/java/com/luojilab/component/componentlib/applicationlike/IApplicationLike.java
@@ -1,4 +1,4 @@
-package com.mrzhang.component.componentlib.applicationlike;
+package com.luojilab.component.componentlib.applicationlike;
/**
* Created by mrzhang on 2017/6/15.
diff --git a/componentlib/src/main/java/com/luojilab/component/componentlib/router/ISyringe.java b/componentlib/src/main/java/com/luojilab/component/componentlib/router/ISyringe.java
new file mode 100644
index 0000000..4ed090d
--- /dev/null
+++ b/componentlib/src/main/java/com/luojilab/component/componentlib/router/ISyringe.java
@@ -0,0 +1,18 @@
+package com.luojilab.component.componentlib.router;
+
+/**
+ *
Description: implement of {@link AutowiredService},used to fetch
+ * data from bundles in the intent
+ * Created by leobert on 2017/9/18.
+ */
+
+public class AutowiredServiceImpl implements AutowiredService {
+
+ private LruCache classCache = new LruCache<>(50);
+ private List blackList = new ArrayList<>();
+
+ //attention! make sure this keeps same with the one in AutowiredProcessor
+ private static final String SUFFIX_AUTOWIRED = "$$Router$$Autowired";
+
+ @Override
+ public void autowire(Object instance) {
+ String className = instance.getClass().getName();
+ try {
+ if (!blackList.contains(className)) {
+ ISyringe autowiredHelper = classCache.get(className);
+ if (null == autowiredHelper) { // No cache.
+ autowiredHelper = (ISyringe) Class.forName(instance.getClass().getName() + SUFFIX_AUTOWIRED)
+ .getConstructor().newInstance();
+ }
+ autowiredHelper.inject(instance);
+ classCache.put(className, autowiredHelper);
+ } else {
+ // TODO: 2017/12/21 change to specific log system
+ Log.d("[DDComponent]", "[autowire] " + className + "is in blacklist, ignore data inject");
+ }
+ } catch (Exception ex) {
+ if (ex instanceof NullPointerException) { // may define custom exception better
+ throw new NullPointerException(ex.getMessage());
+ }
+ ex.printStackTrace();
+ blackList.add(className); // This instance need not autowired.
+ }
+ }
+}
diff --git a/componentlib/src/main/java/com/luojilab/component/componentlib/service/JsonService.java b/componentlib/src/main/java/com/luojilab/component/componentlib/service/JsonService.java
new file mode 100644
index 0000000..70c7e49
--- /dev/null
+++ b/componentlib/src/main/java/com/luojilab/component/componentlib/service/JsonService.java
@@ -0,0 +1,42 @@
+package com.luojilab.component.componentlib.service;
+
+
+import java.util.List;
+
+/**
+ *
Package: com.luojilab.component.json
+ *
Project: DDComponentForAndroid
+ *
Classname: JsonService
+ *
Description: APIs provided by the JsonComponent.
+ * you can implement it via fast-json,gson,jackson etc.
+ *
+ * currently only basic functions contains!
+ *
+ * Created by leobert on 2017/9/18.
+ */
+
+public interface JsonService {
+
+ T parseObject(String text, Class clazz);
+
+ List parseArray(String text, Class clazz);
+
+ String toJsonString(Object instance);
+
+ class Factory {
+ private static Factory instance;
+
+ public static Factory getInstance() {
+ if (instance == null) {
+ instance = new Factory();
+ }
+ return instance;
+ }
+
+ public JsonService create() {
+ return new JsonServiceImpl();
+ }
+ }
+
+
+}
diff --git a/componentlib/src/main/java/com/luojilab/component/componentlib/service/JsonServiceImpl.java b/componentlib/src/main/java/com/luojilab/component/componentlib/service/JsonServiceImpl.java
new file mode 100644
index 0000000..0659171
--- /dev/null
+++ b/componentlib/src/main/java/com/luojilab/component/componentlib/service/JsonServiceImpl.java
@@ -0,0 +1,41 @@
+package com.luojilab.component.componentlib.service;
+
+/**
+ * Created by mrzhang on 2017/12/14.
+ */
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+import java.util.List;
+
+/**
+ *
Package: com.luojilab.component.json.serviceimpl
+ *
Project: DDComponentForAndroid
+ *
Classname: JsonServiceImpl
+ *
Description: implement of {@link JsonService}, in this,
+ * base on fast-json
+ *
+ * Created by leobert on 2017/9/18.
+ */
+
+class JsonServiceImpl implements JsonService {
+ @Override
+ public T parseObject(String text, Class clazz) {
+ Gson gson = new Gson();
+ return gson.fromJson(text, clazz);
+ }
+
+ @Override
+ public List parseArray(String text, Class clazz) {
+ Gson gson = new Gson();
+ return gson.fromJson(text, new TypeToken>() {
+ }.getType());
+ }
+
+ @Override
+ public String toJsonString(Object instance) {
+ Gson gson = new Gson();
+ return gson.toJson(instance);
+ }
+}
\ No newline at end of file
diff --git a/componentlib/src/main/java/com/luojilab/component/componentlib/utils/UriUtils.java b/componentlib/src/main/java/com/luojilab/component/componentlib/utils/UriUtils.java
new file mode 100644
index 0000000..47c9525
--- /dev/null
+++ b/componentlib/src/main/java/com/luojilab/component/componentlib/utils/UriUtils.java
@@ -0,0 +1,133 @@
+package com.luojilab.component.componentlib.utils;
+
+import android.net.Uri;
+import android.os.Bundle;
+import android.text.TextUtils;
+
+import com.luojilab.router.facade.enums.Type;
+
+import java.net.URLDecoder;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Created by mrzhang on 2017/8/28.
+ * 负责解析URI的参数
+ */
+
+public class UriUtils {
+
+ public static HashMap parseParams(Uri uri) {
+ if (uri == null) {
+ return new HashMap();
+ }
+ HashMap temp = new HashMap();
+ Set keys = getQueryParameterNames(uri);
+ for (String key : keys) {
+ temp.put(key, uri.getQueryParameter(key));
+ }
+ return temp;
+ }
+
+ public static Set getQueryParameterNames(Uri uri) {
+ String query = uri.getEncodedQuery();
+ if (query == null) {
+ return Collections.emptySet();
+ }
+
+ Set names = new LinkedHashSet();
+ int start = 0;
+ do {
+ int next = query.indexOf('&', start);
+ int end = (next == -1) ? query.length() : next;
+
+ int separator = query.indexOf('=', start);
+ if (separator > end || separator == -1) {
+ separator = end;
+ }
+
+ String name = query.substring(start, separator);
+ try {
+ names.add(URLDecoder.decode(name, "UTF-8"));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ start = end + 1;
+ } while (start < query.length());
+
+ return Collections.unmodifiableSet(names);
+ }
+
+
+ public static int parseInt(String src) {
+ return parseInt(src, 0);
+ }
+
+ public static int parseInt(String src, int defaultValue) {
+ if (TextUtils.isEmpty(src)) {
+ return defaultValue;
+ }
+ int index = src.indexOf(".");
+ if (index > 0) {
+ src = src.substring(0, index);
+ }
+ try {
+ return Integer.parseInt(src);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+ public static void setBundleValue(Bundle bundle, Map params, Map paramsType) {
+ if (paramsType != null && params != null && !paramsType.isEmpty() && !params.isEmpty()) {
+ for (Map.Entry param : paramsType.entrySet()) {
+ UriUtils.setBundleValue(bundle, param.getValue(), param.getKey(), params.get(param.getKey()));
+ }
+ }
+ }
+
+ /**
+ * @param typeDef type
+ * @param key key
+ * @param value value
+ */
+ public static void setBundleValue(Bundle bundle, Integer typeDef, String key, String value) {
+ if (TextUtils.isEmpty(key) || TextUtils.isEmpty(value)) {
+ return;
+ }
+
+ try {
+ if (null != typeDef) {
+ if (typeDef == Type.BOOLEAN.ordinal()) {
+ bundle.putBoolean(key, Boolean.parseBoolean(value));
+ } else if (typeDef == Type.BYTE.ordinal()) {
+ bundle.putByte(key, Byte.valueOf(value));
+ } else if (typeDef == Type.SHORT.ordinal()) {
+ bundle.putShort(key, Short.valueOf(value));
+ } else if (typeDef == Type.INT.ordinal()) {
+ bundle.putInt(key, Integer.valueOf(value));
+ } else if (typeDef == Type.LONG.ordinal()) {
+ bundle.putLong(key, Long.valueOf(value));
+ } else if (typeDef == Type.FLOAT.ordinal()) {
+ bundle.putFloat(key, Float.valueOf(value));
+ } else if (typeDef == Type.DOUBLE.ordinal()) {
+ bundle.putDouble(key, Double.valueOf(value));
+ } else if (typeDef == Type.STRING.ordinal()) {
+ bundle.putString(key, value);
+ } else if (typeDef == Type.PARCELABLE.ordinal()) {
+ } else if (typeDef == Type.OBJECT.ordinal()) {
+ bundle.putString(key, value);
+ } else {
+ bundle.putString(key, value);
+ }
+ } else {
+ bundle.putString(key, value);
+ }
+ } catch (Throwable ex) {
+ }
+ }
+}
diff --git a/componentlib/src/main/java/com/mrzhang/component/componentlib/router/ui/IComponentRouter.java b/componentlib/src/main/java/com/mrzhang/component/componentlib/router/ui/IComponentRouter.java
deleted file mode 100644
index e87da69..0000000
--- a/componentlib/src/main/java/com/mrzhang/component/componentlib/router/ui/IComponentRouter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.mrzhang.component.componentlib.router.ui;
-
-import android.content.Context;
-import android.net.Uri;
-import android.os.Bundle;
-
-/**
- * Created by mrzhang on 2017/6/20.
- */
-
-public interface IComponentRouter {
-
- /**
- * 打开一个链接
- *
- * @param url
- * 目标url可以是http 或者 自定义scheme
- * @param bundle
- * 打开目录activity时要传入的参数。建议只传基本类型参数。
- * @return 是否正常打开
- */
- public boolean openUri(Context context, String url, Bundle bundle);
-
- public boolean openUri(Context context,Uri uri, Bundle bundle);
-
- public boolean verifyUri(Uri uri);
-}
diff --git a/componentrelease/readercomponent-release.aar b/componentrelease/readercomponent-release.aar
deleted file mode 100644
index 5ba3073..0000000
Binary files a/componentrelease/readercomponent-release.aar and /dev/null differ
diff --git a/componentrelease/sharecomponent-release.aar b/componentrelease/sharecomponent-release.aar
deleted file mode 100644
index 11e8d53..0000000
Binary files a/componentrelease/sharecomponent-release.aar and /dev/null differ
diff --git a/componentservice/build.gradle b/componentservice/build.gradle
index d6a5170..74e2470 100644
--- a/componentservice/build.gradle
+++ b/componentservice/build.gradle
@@ -1,8 +1,9 @@
apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
android {
compileSdkVersion 26
- buildToolsVersion "26.0.0"
+ buildToolsVersion "26.0.1"
defaultConfig {
minSdkVersion 15
@@ -22,7 +23,15 @@ android {
}
dependencies {
- compile project(':componentlib')
+// compile project(':componentlib')
compile project(':basicres')
- compile fileTree(dir: 'libs', include: ['*.jar'])
+ compile fileTree(include: ['*.jar'], dir: 'libs')
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ testCompile 'junit:junit:4.12'
+ compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
+}
+repositories {
+ mavenCentral()
}
diff --git a/componentservice/componentservice.iml b/componentservice/componentservice.iml
deleted file mode 100644
index 69f3f3a..0000000
--- a/componentservice/componentservice.iml
+++ /dev/null
@@ -1,129 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/componentservice/src/androidTest/java/com/mrzhang/componentservice/ExampleInstrumentedTest.java b/componentservice/src/androidTest/java/com/luojilab/componentservice/ExampleInstrumentedTest.java
similarity index 94%
rename from componentservice/src/androidTest/java/com/mrzhang/componentservice/ExampleInstrumentedTest.java
rename to componentservice/src/androidTest/java/com/luojilab/componentservice/ExampleInstrumentedTest.java
index 3c04d02..3487f44 100644
--- a/componentservice/src/androidTest/java/com/mrzhang/componentservice/ExampleInstrumentedTest.java
+++ b/componentservice/src/androidTest/java/com/luojilab/componentservice/ExampleInstrumentedTest.java
@@ -1,4 +1,4 @@
-package com.mrzhang.componentservice;
+package com.luojilab.componentservice;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
diff --git a/componentservice/src/main/AndroidManifest.xml b/componentservice/src/main/AndroidManifest.xml
index 86d9d6d..7ed4bcc 100644
--- a/componentservice/src/main/AndroidManifest.xml
+++ b/componentservice/src/main/AndroidManifest.xml
@@ -1,7 +1,7 @@
+ package="com.luojilab.componentservice">
diff --git a/componentservice/src/main/java/com/mrzhang/componentservice/readerbook/ReadBookService.java b/componentservice/src/main/java/com/luojilab/componentservice/readerbook/ReadBookService.java
similarity index 67%
rename from componentservice/src/main/java/com/mrzhang/componentservice/readerbook/ReadBookService.java
rename to componentservice/src/main/java/com/luojilab/componentservice/readerbook/ReadBookService.java
index b818822..0d7953c 100644
--- a/componentservice/src/main/java/com/mrzhang/componentservice/readerbook/ReadBookService.java
+++ b/componentservice/src/main/java/com/luojilab/componentservice/readerbook/ReadBookService.java
@@ -1,8 +1,9 @@
-package com.mrzhang.componentservice.readerbook;
+package com.luojilab.componentservice.readerbook;
import android.support.v4.app.Fragment;
/**
+ * export module services
* Created by mrzhang on 2017/6/15.
*/
diff --git a/componentservice/src/main/java/com/luojilab/componentservice/share/bean/Author.java b/componentservice/src/main/java/com/luojilab/componentservice/share/bean/Author.java
new file mode 100644
index 0000000..b7bc5da
--- /dev/null
+++ b/componentservice/src/main/java/com/luojilab/componentservice/share/bean/Author.java
@@ -0,0 +1,35 @@
+package com.luojilab.componentservice.share.bean;
+
+/**
+ * Created by mrzhang on 2017/12/14.
+ */
+
+public class Author {
+ private String name;
+ private int age;
+ private String county;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getCounty() {
+ return county;
+ }
+
+ public void setCounty(String county) {
+ this.county = county;
+ }
+}
diff --git a/componentservice/src/main/java/com/luojilab/componentservice/share/bean/AuthorKt.kt b/componentservice/src/main/java/com/luojilab/componentservice/share/bean/AuthorKt.kt
new file mode 100644
index 0000000..39da046
--- /dev/null
+++ b/componentservice/src/main/java/com/luojilab/componentservice/share/bean/AuthorKt.kt
@@ -0,0 +1,6 @@
+package com.luojilab.componentservice.share.bean
+
+/**
+ * Created by mrzhang on 2018/2/26.
+ */
+data class AuthorKt(var name: String, var age: Int, var county: String)
\ No newline at end of file
diff --git a/componentservice/src/test/java/com/mrzhang/componentservice/ExampleUnitTest.java b/componentservice/src/test/java/com/luojilab/componentservice/ExampleUnitTest.java
similarity index 90%
rename from componentservice/src/test/java/com/mrzhang/componentservice/ExampleUnitTest.java
rename to componentservice/src/test/java/com/luojilab/componentservice/ExampleUnitTest.java
index fcba030..2b8e927 100644
--- a/componentservice/src/test/java/com/mrzhang/componentservice/ExampleUnitTest.java
+++ b/componentservice/src/test/java/com/luojilab/componentservice/ExampleUnitTest.java
@@ -1,4 +1,4 @@
-package com.mrzhang.componentservice;
+package com.luojilab.componentservice;
import org.junit.Test;
diff --git a/gradle.properties b/gradle.properties
index 8c5c255..b29ebad 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,18 +1,21 @@
# Project-wide Gradle settings.
-
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
-
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
-
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
-
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
mainmodulename=app
+bintrayRepo=compbuild
+publishedGroupId=com.luojilab.ddcomponent
+siteUrl=
+gitUrl=
+developerId=
+developerName=
+developerEmail=
diff --git a/local.properties b/local.properties
deleted file mode 100644
index e443f8d..0000000
--- a/local.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-## This file is automatically generated by Android Studio.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must *NOT* be checked into Version Control Systems,
-# as it contains information specific to your local configuration.
-#
-# Location of the SDK. This is only used by Gradle.
-# For customization when using a Version Control System, please read the
-# header note.
-#Mon Aug 21 11:21:44 CST 2017
-sdk.dir=/Users/mrzhang/Library/Android/sdk
diff --git a/readercomponent/build.gradle b/readercomponent/build.gradle
index c17ce1b..882bd1f 100644
--- a/readercomponent/build.gradle
+++ b/readercomponent/build.gradle
@@ -1,8 +1,9 @@
apply plugin: 'com.dd.comgradle'
+apply plugin: 'kotlin-android'
android {
- compileSdkVersion 25
- buildToolsVersion "25.0.2"
+ compileSdkVersion 26
+ buildToolsVersion "26.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 14
@@ -11,6 +12,12 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ javaCompileOptions {
+ annotationProcessorOptions {
+ arguments = [host: "reader"]
+ }
+ }
+
}
buildTypes {
@@ -27,26 +34,23 @@ android {
resourcePrefix "readerbook_"
- sourceSets {
- main {
- if (isRunAlone.toBoolean()) {
- manifest.srcFile 'src/main/runalone/AndroidManifest.xml'
- java.srcDirs = ['src/main/java', 'src/main/runalone/java']
- res.srcDirs = ['src/main/res', 'src/main/runalone/res']
- } else {
- manifest.srcFile 'src/main/AndroidManifest.xml'
- }
- }
- }
-
}
dependencies {
compile project(':componentservice')
- compile fileTree(dir: 'libs', include: ['*.jar'])
+ compile fileTree(include: ['*.jar'], dir: 'libs')
+ annotationProcessor 'com.luojilab.ddcomponent:router-anno-compiler:1.0.0'
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ testCompile 'junit:junit:4.12'
+ compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
combuild {
- applicatonName = 'com.mrzhang.reader.runalone.application.ReaderApplication'
+ applicationName = 'com.luojilab.reader.runalone.application.ReaderApplication'
isRegisterCompoAuto = false
+}
+repositories {
+ mavenCentral()
}
\ No newline at end of file
diff --git a/readercomponent/gradle.properties b/readercomponent/gradle.properties
index a783fe1..79c4ac9 100644
--- a/readercomponent/gradle.properties
+++ b/readercomponent/gradle.properties
@@ -12,5 +12,5 @@ org.gradle.jvmargs=-Xmx1536m
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
isRunAlone=true
-debugComponent=sharecomponent
-compileComponent=com.mrzhang.share:sharecomponent
+debugComponent=sharecomponent,sharecomponentkotlin
+compileComponent=sharecomponent,sharecomponentkotlin
diff --git a/readercomponent/readercomponent.iml b/readercomponent/readercomponent.iml
deleted file mode 100644
index 5c41cea..0000000
--- a/readercomponent/readercomponent.iml
+++ /dev/null
@@ -1,131 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/readercomponent/src/androidTest/java/com/mrzhang/comp_reader/ExampleInstrumentedTest.java b/readercomponent/src/androidTest/java/com/mrzhang/comp_reader/ExampleInstrumentedTest.java
deleted file mode 100644
index c8b2321..0000000
--- a/readercomponent/src/androidTest/java/com/mrzhang/comp_reader/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.mrzhang.comp_reader;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("com.example.comp_reader.test", appContext.getPackageName());
- }
-}
diff --git a/readercomponent/src/main/AndroidManifest.xml b/readercomponent/src/main/AndroidManifest.xml
index 860cc7c..d3f7293 100644
--- a/readercomponent/src/main/AndroidManifest.xml
+++ b/readercomponent/src/main/AndroidManifest.xml
@@ -1,7 +1,7 @@
+ package="com.luojilab.reader">
-
+ android:layout_marginTop="50dp"
+ android:gravity="center"
+ android:text="欢迎每天听本书,点击下面按钮分享"
+ android:textSize="18sp" />
+
+
+
+
+
+
diff --git a/readercomponent/src/main/runalone/AndroidManifest.xml b/readercomponent/src/main/runalone/AndroidManifest.xml
index 262f347..5566df4 100644
--- a/readercomponent/src/main/runalone/AndroidManifest.xml
+++ b/readercomponent/src/main/runalone/AndroidManifest.xml
@@ -1,20 +1,20 @@
+ xmlns:tools="http://schemas.android.com/tools"
+ package="com.luojilab.reader">
-
+
-
+
-
+
diff --git a/readercomponent/src/main/runalone/java/com/mrzhang/reader/runalone/ReaderTestActivity.java b/readercomponent/src/main/runalone/java/com/luojilab/reader/runalone/ReaderTestActivity.java
similarity index 77%
rename from readercomponent/src/main/runalone/java/com/mrzhang/reader/runalone/ReaderTestActivity.java
rename to readercomponent/src/main/runalone/java/com/luojilab/reader/runalone/ReaderTestActivity.java
index 2b60a77..ea58943 100644
--- a/readercomponent/src/main/runalone/java/com/mrzhang/reader/runalone/ReaderTestActivity.java
+++ b/readercomponent/src/main/runalone/java/com/luojilab/reader/runalone/ReaderTestActivity.java
@@ -1,12 +1,12 @@
-package com.mrzhang.reader.runalone;
+package com.luojilab.reader.runalone;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
-import com.mrzhang.reader.R;
-import com.mrzhang.reader.ReaderFragment;
+import com.luojilab.reader.R;
+import com.luojilab.reader.ReaderFragment;
/**
* Created by mrzhang on 2017/6/15.
@@ -14,13 +14,13 @@
public class ReaderTestActivity extends AppCompatActivity {
- ReaderFragment fragment;
+ ReaderFragment fragment;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.readerbook_activity_test);
- fragment= new ReaderFragment();
+ fragment = new ReaderFragment();
final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.tab_content, fragment).commitAllowingStateLoss();
}
diff --git a/readercomponent/src/main/runalone/java/com/luojilab/reader/runalone/application/ReaderApplication.java b/readercomponent/src/main/runalone/java/com/luojilab/reader/runalone/application/ReaderApplication.java
new file mode 100644
index 0000000..9929914
--- /dev/null
+++ b/readercomponent/src/main/runalone/java/com/luojilab/reader/runalone/application/ReaderApplication.java
@@ -0,0 +1,21 @@
+package com.luojilab.reader.runalone.application;
+
+import com.luojilab.component.basicres.BaseApplication;
+import com.luojilab.component.componentlib.router.Router;
+
+/**
+ * Created by mrzhang on 2017/6/20.
+ */
+
+public class ReaderApplication extends BaseApplication {
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ //如果isRegisterCompoAuto为false,则需要通过反射加载组件
+ Router.registerComponent("com.luojilab.share.applike.ShareApplike");
+ Router.registerComponent("com.luojilab.share.kotlin.applike.KotlinApplike");
+ }
+
+}
diff --git a/readercomponent/src/main/runalone/java/com/mrzhang/reader/runalone/application/ReaderApplication.java b/readercomponent/src/main/runalone/java/com/mrzhang/reader/runalone/application/ReaderApplication.java
deleted file mode 100644
index 550fa93..0000000
--- a/readercomponent/src/main/runalone/java/com/mrzhang/reader/runalone/application/ReaderApplication.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.mrzhang.reader.runalone.application;
-
-import android.app.Application;
-
-import com.mrzhang.component.componentlib.router.Router;
-
-/**
- * Created by mrzhang on 2017/6/20.
- */
-
-public class ReaderApplication extends Application {
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- //如果isRegisterCompoAuto为false,则需要通过反射加载组件
- Router.registerComponent("com.mrzhang.share.applike.ShareApplike");
- }
-
-}
diff --git a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.jar b/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.jar
deleted file mode 100644
index 35c0e9d..0000000
Binary files a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.jar and /dev/null differ
diff --git a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.jar.md5 b/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.jar.md5
deleted file mode 100644
index 70138df..0000000
--- a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-8b68c15766ff045fbe90313aa5a5ae9a
\ No newline at end of file
diff --git a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.jar.sha1 b/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.jar.sha1
deleted file mode 100644
index cc1bfb8..0000000
--- a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-607dd8b657c187ec6e54dcabe800cf1551aaf6b9
\ No newline at end of file
diff --git a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.pom b/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.pom
deleted file mode 100644
index 87541cb..0000000
--- a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.pom
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
- 4.0.0
- com.mrzhang.andcomponent
- build-gradle
- 0.0.1
-
-
- com.android.tools.build
- gradle
- 2.3.2
- compile
-
-
- org.javassist
- javassist
- 3.20.0-GA
- compile
-
-
-
diff --git a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.pom.md5 b/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.pom.md5
deleted file mode 100644
index f807977..0000000
--- a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.pom.md5
+++ /dev/null
@@ -1 +0,0 @@
-f7969d81c9a02450834b43d980b3f378
\ No newline at end of file
diff --git a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.pom.sha1 b/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.pom.sha1
deleted file mode 100644
index 0565d14..0000000
--- a/repo/com/mrzhang/andcomponent/build-gradle/0.0.1/build-gradle-0.0.1.pom.sha1
+++ /dev/null
@@ -1 +0,0 @@
-c00ce9b4fe7cd90ebe6341a0e073811833da0a19
\ No newline at end of file
diff --git a/repo/com/mrzhang/andcomponent/build-gradle/maven-metadata.xml b/repo/com/mrzhang/andcomponent/build-gradle/maven-metadata.xml
deleted file mode 100644
index 45398c2..0000000
--- a/repo/com/mrzhang/andcomponent/build-gradle/maven-metadata.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
- com.mrzhang.andcomponent
- build-gradle
-
- 0.0.1
-
- 0.0.1
-
- 20170822072619
-
-
diff --git a/repo/com/mrzhang/andcomponent/build-gradle/maven-metadata.xml.md5 b/repo/com/mrzhang/andcomponent/build-gradle/maven-metadata.xml.md5
deleted file mode 100644
index f42572f..0000000
--- a/repo/com/mrzhang/andcomponent/build-gradle/maven-metadata.xml.md5
+++ /dev/null
@@ -1 +0,0 @@
-e8c8fd8e6525cb33c5843645ce43e961
\ No newline at end of file
diff --git a/repo/com/mrzhang/andcomponent/build-gradle/maven-metadata.xml.sha1 b/repo/com/mrzhang/andcomponent/build-gradle/maven-metadata.xml.sha1
deleted file mode 100644
index d567d10..0000000
--- a/repo/com/mrzhang/andcomponent/build-gradle/maven-metadata.xml.sha1
+++ /dev/null
@@ -1 +0,0 @@
-3d5e982f4d8a222b8778ee340eb544465bc198a8
\ No newline at end of file
diff --git a/router-anno-compiler/.gitignore b/router-anno-compiler/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/router-anno-compiler/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/router-anno-compiler/build.gradle b/router-anno-compiler/build.gradle
new file mode 100644
index 0000000..258fd87
--- /dev/null
+++ b/router-anno-compiler/build.gradle
@@ -0,0 +1,33 @@
+apply plugin: 'java'
+
+
+ext {
+ bintrayName = 'router-anno-compiler'
+ artifact = bintrayName
+ libraryName = 'router-anno-compiler'
+ libraryDescription = 'router-anno-compiler'
+ libraryVersion = "1.0.0"
+ licenseName = 'The Apache Software License, Version 2.0'
+ licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ allLicenses = ["Apache-2.0"]
+}
+apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
+apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
+
+dependencies {
+ compile fileTree(include: ['*.jar'], dir: 'libs')
+ compile 'com.google.auto.service:auto-service:1.0-rc2'
+ compile 'com.squareup:javapoet:1.9.0'
+
+
+ compile 'org.apache.commons:commons-lang3:3.4'
+ compile 'org.apache.commons:commons-collections4:4.1'
+
+ compile project(':router-annotation')
+
+}
+
+compileJava {
+ sourceCompatibility = '1.7'
+ targetCompatibility = '1.7'
+}
diff --git a/router-anno-compiler/src/main/java/com/luojilab/router/compiler/model/MethodInfo.java b/router-anno-compiler/src/main/java/com/luojilab/router/compiler/model/MethodInfo.java
new file mode 100644
index 0000000..9576082
--- /dev/null
+++ b/router-anno-compiler/src/main/java/com/luojilab/router/compiler/model/MethodInfo.java
@@ -0,0 +1,98 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 leobert-lan
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+package com.luojilab.router.compiler.model;
+
+import com.squareup.javapoet.ClassName;
+import com.squareup.javapoet.ParameterSpec;
+import com.squareup.javapoet.TypeName;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.TypeMirror;
+
+/**
+ * Description: Helper class to record method info needed by Processor
+ */
+public class MethodInfo {
+ private String methodName;
+ private List methodModifiers;
+ private List methodParameters;
+ private TypeMirror methodReturnType;
+
+ public MethodInfo() {
+ }
+
+ public MethodInfo setMethodName(String methodName) {
+ this.methodName = methodName;
+ return this;
+ }
+
+ public MethodInfo setMethodModifiers(List methodModifiers) {
+ this.methodModifiers = methodModifiers;
+ return this;
+ }
+
+ public MethodInfo setMethodParameters(List methodParameters) {
+ this.methodParameters = methodParameters;
+ return this;
+ }
+
+ public MethodInfo setMethodReturnType(TypeMirror methodReturnType) {
+ this.methodReturnType = methodReturnType;
+ return this;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public List getMethodModifiers() {
+ return methodModifiers;
+ }
+
+ public List getMethodParameters() {
+ List parameterSpecs = new ArrayList<>();
+ for (VariableElement variableElement : methodParameters) {
+ parameterSpecs.add(ParameterSpec.get(variableElement));
+ }
+ return parameterSpecs;
+ }
+
+ public List getMethodParametersSimple() {
+ List params = new ArrayList<>();
+ for (VariableElement methodParameter : methodParameters) {
+ params.add(methodParameter.getSimpleName().toString());
+ }
+ return params;
+ }
+
+ public TypeName getTypeName() {
+ return ClassName.get(methodReturnType);
+ }
+}
diff --git a/router-anno-compiler/src/main/java/com/luojilab/router/compiler/processor/AutowiredProcessor.java b/router-anno-compiler/src/main/java/com/luojilab/router/compiler/processor/AutowiredProcessor.java
new file mode 100644
index 0000000..920f228
--- /dev/null
+++ b/router-anno-compiler/src/main/java/com/luojilab/router/compiler/processor/AutowiredProcessor.java
@@ -0,0 +1,292 @@
+package com.luojilab.router.compiler.processor;
+
+import com.google.auto.service.AutoService;
+import com.luojilab.router.compiler.utils.Constants;
+import com.luojilab.router.compiler.utils.Logger;
+import com.luojilab.router.compiler.utils.TypeUtils;
+import com.luojilab.router.facade.annotation.Autowired;
+import com.luojilab.router.facade.enums.Type;
+import com.squareup.javapoet.ClassName;
+import com.squareup.javapoet.FieldSpec;
+import com.squareup.javapoet.JavaFile;
+import com.squareup.javapoet.MethodSpec;
+import com.squareup.javapoet.ParameterSpec;
+import com.squareup.javapoet.TypeName;
+import com.squareup.javapoet.TypeSpec;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Filer;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.Processor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedOptions;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.Elements;
+import javax.lang.model.util.Types;
+
+import static com.luojilab.router.compiler.utils.Constants.ANNOTATION_TYPE_AUTOWIRED;
+import static com.luojilab.router.compiler.utils.Constants.KEY_HOST_NAME;
+import static javax.lang.model.element.Modifier.PUBLIC;
+
+/**
+ *
Package: com.luojilab.router.compiler.processor
+ *
Project: DDComponentForAndroid
+ *
Classname: AutowiredProcessor
+ *
Description: Autowired Processor,Only Activity and Fragment/Fragment_V4 allowed
+ * Created by leobert on 2017/9/18.
+ */
+
+public class TypeUtils {
+ private Types types;
+ private Elements elements;
+ private TypeMirror parcelableType;
+
+ public TypeUtils(Types types, Elements elements) {
+ this.types = types;
+ this.elements = elements;
+
+ parcelableType = this.elements.getTypeElement(PARCELABLE).asType();
+ }
+
+ /**
+ * Diagnostics out the true java type
+ *
+ * @param element Raw type
+ * @return Type class of java
+ */
+ public int typeExchange(Element element) {
+ TypeMirror typeMirror = element.asType();
+
+ // Primitive
+ if (typeMirror.getKind().isPrimitive()) {
+ return element.asType().getKind().ordinal();
+ }
+
+ switch (typeMirror.toString()) {
+ case Constants.BYTE:
+ return Type.BYTE.ordinal();
+ case Constants.SHORT:
+ return Type.SHORT.ordinal();
+ case Constants.INTEGER:
+ return Type.INT.ordinal();
+ case Constants.LONG:
+ return Type.LONG.ordinal();
+ case Constants.FLOAT:
+ return Type.FLOAT.ordinal();
+ case Constants.DOUBEL:
+ return Type.DOUBLE.ordinal();
+ case Constants.BOOLEAN:
+ return Type.BOOLEAN.ordinal();
+ case Constants.STRING:
+ return Type.STRING.ordinal();
+ default: // Other side, maybe the PARCELABLE or OBJECT.
+ if (types.isSubtype(typeMirror, parcelableType)) { // PARCELABLE
+ return Type.PARCELABLE.ordinal();
+ } else { // For others
+ return Type.OBJECT.ordinal();
+ }
+ }
+ }
+
+ /**
+ * DESC of type
+ *
+ * @param element Raw type
+ * @return Type class of java
+ */
+ public String typeDesc(Element element) {
+ TypeMirror typeMirror = element.asType();
+
+ // Primitive
+ if (typeMirror.getKind().isPrimitive()) {
+ return element.asType().getKind().name();
+ }
+
+ switch (typeMirror.toString()) {
+ case Constants.BYTE:
+ return "byte";
+ case Constants.SHORT:
+ return "short";
+ case Constants.INTEGER:
+ return "int";
+ case Constants.LONG:
+ return "long";
+ case Constants.FLOAT:
+ return "byte";
+ case Constants.DOUBEL:
+ return "double";
+ case Constants.BOOLEAN:
+ return "boolean";
+ case Constants.STRING:
+ return "String";
+ default: // Other side, maybe the PARCELABLE or OBJECT.
+ if (types.isSubtype(typeMirror, parcelableType)) { // PARCELABLE
+ return "parcelable";
+ } else { // For others
+ return typeMirror.toString();
+ }
+ }
+ }
+
+
+}
diff --git a/router-annotation/.gitignore b/router-annotation/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/router-annotation/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/router-annotation/build.gradle b/router-annotation/build.gradle
new file mode 100644
index 0000000..7070f6a
--- /dev/null
+++ b/router-annotation/build.gradle
@@ -0,0 +1,24 @@
+apply plugin: 'java'
+
+ext {
+ bintrayName = 'router-annotation'
+ artifact = bintrayName
+ libraryName = 'router-annotation '
+ libraryDescription = 'router-annotation '
+ libraryVersion = "1.0.0"
+ licenseName = 'The Apache Software License, Version 2.0'
+ licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ allLicenses = ["Apache-2.0"]
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+}
+
+compileJava {
+ sourceCompatibility = '1.7'
+ targetCompatibility = '1.7'
+}
+
+apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
+apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
\ No newline at end of file
diff --git a/router-annotation/src/main/java/com/luojilab/router/facade/annotation/Autowired.java b/router-annotation/src/main/java/com/luojilab/router/facade/annotation/Autowired.java
new file mode 100644
index 0000000..9409ab7
--- /dev/null
+++ b/router-annotation/src/main/java/com/luojilab/router/facade/annotation/Autowired.java
@@ -0,0 +1,51 @@
+package com.luojilab.router.facade.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
Package: com.luojilab.router.facade.annotation
+ *
Project: DDComponentForAndroid
+ *
Classname: Autowired
+ *
Description: used to auto-inject dependency
+ * Created by leobert on 2017/9/18.
+ */
+@Target({ElementType.FIELD})
+@Retention(RetentionPolicy.CLASS)
+public @interface Autowired {
+
+ /**
+ * @return param's name or service name.
+ */
+ String name() default "";
+
+ /**
+ * primitive java type check will be ignore
+ * check the result of DI, if inject failed, the value of
+ * the field will be null, if required, output log
+ *
+ * @return true for required,false otherwise
+ */
+ boolean required() default false;
+
+ /**
+ * throw exception when the required field is null after inject.
+ *
+ * It can help developer find most data delivering bugs when developing.
+ * but not suggest to open this function after release.
+ *
+ * I suggest to define a Constant maintained manually
+ *
+ * only activated when required = true and throwOnNull = true.
+ *
+ * @return true if throwing exception when null is required, false otherwise
+ */
+ boolean throwOnNull() default false;
+
+ /**
+ * @return field description
+ */
+ String desc() default "none desc.";
+}
diff --git a/router-annotation/src/main/java/com/luojilab/router/facade/annotation/RouteNode.java b/router-annotation/src/main/java/com/luojilab/router/facade/annotation/RouteNode.java
new file mode 100644
index 0000000..1d79fca
--- /dev/null
+++ b/router-annotation/src/main/java/com/luojilab/router/facade/annotation/RouteNode.java
@@ -0,0 +1,31 @@
+package com.luojilab.router.facade.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
Package: com.luojilab.router.facade.annotation
+ *
Project: DDComponentForAndroid
+ *
Classname: RouteDef
+ *
Description: used to decline a route node
+ * Created by leobert on 2017/9/18.
+ */
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.CLASS)
+public @interface RouteNode {
+ /**
+ * path of one route
+ */
+ String path();
+ /**
+ * The priority of route.
+ */
+ int priority() default -1;
+
+ /**
+ * description of the activity, user for gen route table
+ */
+ String desc() default "";
+}
diff --git a/router-annotation/src/main/java/com/luojilab/router/facade/enums/NodeType.java b/router-annotation/src/main/java/com/luojilab/router/facade/enums/NodeType.java
new file mode 100644
index 0000000..2f5826b
--- /dev/null
+++ b/router-annotation/src/main/java/com/luojilab/router/facade/enums/NodeType.java
@@ -0,0 +1,51 @@
+package com.luojilab.router.facade.enums;
+
+/**
+ *