├── router ├── .gitignore ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── chenenyu │ │ │ └── router │ │ │ ├── RouteStatus.java │ │ │ ├── template │ │ │ ├── ParamInjector.java │ │ │ ├── InterceptorTable.java │ │ │ ├── RouteTable.java │ │ │ └── TargetInterceptorsTable.java │ │ │ ├── RouteCallback.java │ │ │ ├── matcher │ │ │ ├── AbsImplicitMatcher.java │ │ │ ├── DirectMatcher.java │ │ │ ├── BrowserMatcher.java │ │ │ ├── package-info.java │ │ │ ├── AbsExplicitMatcher.java │ │ │ ├── Matcher.java │ │ │ ├── ImplicitMatcher.java │ │ │ ├── AbsMatcher.java │ │ │ └── SchemeMatcher.java │ │ │ ├── chain │ │ │ ├── package-info.java │ │ │ ├── FragmentValidator.java │ │ │ ├── IntentValidator.java │ │ │ ├── BaseValidator.java │ │ │ ├── AttrsProcessor.java │ │ │ ├── FragmentProcessor.java │ │ │ ├── AppInterceptorsHandler.java │ │ │ └── IntentProcessor.java │ │ │ ├── util │ │ │ └── RLog.java │ │ │ ├── RouteResponse.java │ │ │ ├── RouteInterceptor.java │ │ │ ├── Router.java │ │ │ ├── AptHub.java │ │ │ ├── MatcherRegistry.java │ │ │ ├── RealInterceptorChain.java │ │ │ ├── IRouter.java │ │ │ ├── RealRouter.java │ │ │ ├── RouterInitializer.java │ │ │ ├── RouteRequest.java │ │ │ └── AbsRouter.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── Sample ├── app │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values-zh │ │ │ │ └── strings.xml │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ ├── activity_intercepted.xml │ │ │ │ ├── activity_test.xml │ │ │ │ ├── activity_dynamic.xml │ │ │ │ ├── activity_for_result.xml │ │ │ │ ├── activity_scheme.xml │ │ │ │ └── activity_main.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── chenenyu │ │ │ │ └── router │ │ │ │ └── app │ │ │ │ ├── Model.java │ │ │ │ ├── App.java │ │ │ │ ├── DynamicActivity.java │ │ │ │ ├── InterceptedActivity.java │ │ │ │ ├── WebActivity.java │ │ │ │ ├── GlobalInterceptor.java │ │ │ │ ├── BInterceptor.java │ │ │ │ ├── AInterceptor.java │ │ │ │ ├── ImplicitActivity.java │ │ │ │ ├── SchemeFilterActivity.java │ │ │ │ ├── ForResultActivity.java │ │ │ │ ├── TestActivity.java │ │ │ │ └── MainActivity.java │ │ │ ├── assets │ │ │ └── scheme.html │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ └── proguard-rules.pro ├── module1 │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── values │ │ │ │ └── strings.xml │ │ │ └── layout │ │ │ │ ├── activity_module1.xml │ │ │ │ └── fragment_module1.xml │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── chenenyu │ │ │ │ └── router │ │ │ │ └── module │ │ │ │ └── Module1Activity.kt │ │ │ └── java │ │ │ └── com │ │ │ └── chenenyu │ │ │ └── router │ │ │ └── module │ │ │ └── Module1Fragment.java │ ├── proguard-rules.pro │ └── build.gradle └── module2 │ ├── .gitignore │ ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ └── strings.xml │ │ └── layout │ │ │ ├── activity_module2.xml │ │ │ └── fragment_module2.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── chenenyu │ │ └── router │ │ └── module │ │ ├── Module2Activity.java │ │ └── Module2Fragment.java │ ├── proguard-rules.pro │ └── build.gradle ├── annotation ├── .gitignore ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── chenenyu │ └── router │ └── annotation │ ├── Interceptor.java │ ├── InjectParam.java │ └── Route.java ├── compiler ├── .gitignore ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ ├── services │ │ │ └── javax.annotation.processing.Processor │ │ │ └── gradle │ │ │ └── incremental.annotation.processors │ │ └── java │ │ └── com │ │ └── chenenyu │ │ └── router │ │ └── compiler │ │ ├── util │ │ ├── Logger.java │ │ └── Constants.java │ │ └── processor │ │ └── InterceptorProcessor.java └── build.gradle ├── router-plugin ├── .gitignore ├── README.md ├── settings.gradle.kts ├── src │ └── main │ │ └── java │ │ └── com │ │ └── l3gacy │ │ └── plugin │ │ ├── router │ │ ├── asm │ │ │ ├── RouterClassVisitor.kt │ │ │ └── RouterMethodVisitor.kt │ │ ├── internal │ │ │ └── Extensions.kt │ │ ├── RouterPlugin.kt │ │ └── task │ │ │ └── RouterClassesTask.kt │ │ └── internal │ │ ├── Stopwatch.kt │ │ ├── Extensions.kt │ │ └── Log.kt └── build.gradle.kts ├── gradle-plugin ├── .gitignore ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── gradle-plugins │ │ │ └── com.chenenyu.router.properties │ │ └── groovy │ │ └── com │ │ └── chenenyu │ │ └── router │ │ ├── ManifestTransformerTask.groovy │ │ └── ManifestTransformer.groovy └── build.gradle ├── static ├── screenshot.gif └── donate_wechat.png ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── publish.gradle ├── .gitignore ├── settings.gradle ├── LICENSE ├── release.sh ├── gradle.properties ├── .travis.yml ├── gradlew.bat ├── README.md └── gradlew /router/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Sample/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /annotation/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /compiler/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /router-plugin/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /router-plugin/README.md: -------------------------------------------------------------------------------- 1 | ## 路由插件工具 -------------------------------------------------------------------------------- /router-plugin/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Sample/module1/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Sample/module2/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /gradle-plugin/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /static/screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/static/screenshot.gif -------------------------------------------------------------------------------- /static/donate_wechat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/static/donate_wechat.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Sample/module1/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | module1 3 | 4 | -------------------------------------------------------------------------------- /Sample/module2/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | module2 3 | 4 | -------------------------------------------------------------------------------- /gradle-plugin/src/main/resources/META-INF/gradle-plugins/com.chenenyu.router.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.chenenyu.router.RouterPlugin -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/Sample/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/Sample/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/Sample/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/Sample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/Sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .gradle 3 | local.properties 4 | .idea 5 | build 6 | *.iml 7 | /captures 8 | .externalNativeBuild 9 | 10 | #publish.gradle 11 | /repo -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/Sample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/Sample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/Sample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/Sample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5peak2me/Router/HEAD/Sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/values-zh/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 跳转到 %s 4 | 动态路由 5 | -------------------------------------------------------------------------------- /Sample/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Router 3 | go to %s 4 | dynamic route 5 | 6 | -------------------------------------------------------------------------------- /compiler/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | com.chenenyu.router.compiler.processor.RouteProcessor 2 | com.chenenyu.router.compiler.processor.InterceptorProcessor 3 | com.chenenyu.router.compiler.processor.InjectParamProcessor -------------------------------------------------------------------------------- /Sample/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /Sample/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /compiler/src/main/resources/META-INF/gradle/incremental.annotation.processors: -------------------------------------------------------------------------------- 1 | com.chenenyu.router.compiler.processor.RouteProcessor,aggregating 2 | com.chenenyu.router.compiler.processor.InterceptorProcessor,aggregating 3 | com.chenenyu.router.compiler.processor.InjectParamProcessor,aggregating -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Jul 12 18:00:44 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /Sample/app/src/main/java/com/chenenyu/router/app/Model.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.app; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Test model. 7 | *

8 | * Created by Enyu Chen on 2017/6/28. 9 | */ 10 | public class Model implements Serializable { 11 | // empty 12 | } 13 | -------------------------------------------------------------------------------- /annotation/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | sourceCompatibility = JavaVersion.VERSION_1_8 4 | targetCompatibility = JavaVersion.VERSION_1_8 5 | 6 | ext { 7 | GROUP = 'com.chenenyu.router' 8 | ARTIFACT = 'annotation' 9 | VERSION = ANNOTATION_VERSION 10 | } 11 | 12 | //apply from: '../gradle/publish.gradle' 13 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | // core 2 | include ':router', ':compiler', ':annotation'/*, ':gradle-plugin'*/ 3 | // demo 4 | include ':app', ':module1', ':module2' 5 | project(':app').projectDir = new File("Sample/app") 6 | project(':module1').projectDir = new File("Sample/module1") 7 | project(':module2').projectDir = new File("Sample/module2") 8 | 9 | includeBuild("router-plugin") 10 | -------------------------------------------------------------------------------- /Sample/app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /router/src/main/java/com/chenenyu/router/RouteStatus.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router; 2 | 3 | /** 4 | * Result for each route. 5 | *

6 | * Created by chenenyu on 2017/3/9. 7 | */ 8 | public enum RouteStatus { 9 | PROCESSING, 10 | SUCCEED, 11 | INTERCEPTED, 12 | NOT_FOUND, 13 | FAILED; 14 | 15 | public boolean isSuccessful() { 16 | return this == SUCCEED; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /router/src/main/java/com/chenenyu/router/template/ParamInjector.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.template; 2 | 3 | /** 4 | * Interface that help to generate param class. 5 | *

6 | * Created by chenenyu on 2017/6/15. 7 | */ 8 | public interface ParamInjector { 9 | /** 10 | * Inject params. 11 | * 12 | * @param obj Activity or fragment instance. 13 | */ 14 | void inject(Object obj); 15 | } 16 | -------------------------------------------------------------------------------- /Sample/app/src/main/java/com/chenenyu/router/app/App.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.app; 2 | 3 | import android.app.Application; 4 | 5 | import com.chenenyu.router.util.RLog; 6 | 7 | /** 8 | *

9 | * Created by Cheney on 2017/1/12. 10 | */ 11 | public class App extends Application { 12 | @Override 13 | public void onCreate() { 14 | super.onCreate(); 15 | 16 | RLog.showLog(true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Sample/module1/src/main/res/layout/activity_module1.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /Sample/module2/src/main/res/layout/activity_module2.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /Sample/app/src/main/java/com/chenenyu/router/app/DynamicActivity.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.app; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.appcompat.app.AppCompatActivity; 6 | 7 | public class DynamicActivity extends AppCompatActivity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_dynamic); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Sample/module1/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Sample/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Sample/module2/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /router/src/main/java/com/chenenyu/router/RouteCallback.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router; 2 | 3 | import android.net.Uri; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | *

9 | * Created by chenenyu on 2016/12/20. 10 | */ 11 | public interface RouteCallback extends Serializable { 12 | /** 13 | * Callback 14 | * 15 | * @param status {@link RouteStatus} 16 | * @param uri uri 17 | * @param message notice msg 18 | */ 19 | void callback(RouteStatus status, Uri uri, String message); 20 | } 21 | -------------------------------------------------------------------------------- /annotation/src/main/java/com/chenenyu/router/annotation/Interceptor.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Annotation for interceptor class. 10 | *

11 | * Created by Cheney on 2017/3/6. 12 | */ 13 | @Target(ElementType.TYPE) 14 | @Retention(RetentionPolicy.CLASS) 15 | public @interface Interceptor { 16 | String value(); 17 | } 18 | -------------------------------------------------------------------------------- /router/src/main/java/com/chenenyu/router/template/InterceptorTable.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.template; 2 | 3 | import com.chenenyu.router.RouteInterceptor; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Interceptor table mapping. 9 | *

10 | * Created by chenenyu on 2017/6/30. 11 | */ 12 | public interface InterceptorTable { 13 | /** 14 | * Mapping between name and interceptor. 15 | * 16 | * @param map name -> interceptor. 17 | */ 18 | void handle(Map> map); 19 | } 20 | -------------------------------------------------------------------------------- /router/src/main/java/com/chenenyu/router/template/RouteTable.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.template; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Route table mapping. 7 | *

8 | * Created by chenenyu on 2016/12/22. 9 | */ 10 | public interface RouteTable { 11 | /** 12 | * Mapping between uri and target, the target class may be an {@link android.app.Activity}, 13 | * or {@link androidx.fragment.app.Fragment}. 14 | * 15 | * @param map uri -> target. 16 | */ 17 | void handle(Map> map); 18 | } 19 | -------------------------------------------------------------------------------- /annotation/src/main/java/com/chenenyu/router/annotation/InjectParam.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Annotation for injected params. 10 | *

11 | * Created by chenenyu on 2017/6/12. 12 | */ 13 | @Target({ElementType.FIELD}) 14 | @Retention(RetentionPolicy.CLASS) 15 | public @interface InjectParam { 16 | String key() default ""; 17 | } 18 | -------------------------------------------------------------------------------- /Sample/app/src/main/res/layout/activity_intercepted.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /annotation/src/main/java/com/chenenyu/router/annotation/Route.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Annotation for route. 10 | *

11 | * Created by chenenyu on 2016/12/20. 12 | */ 13 | @Target({ElementType.TYPE}) 14 | @Retention(RetentionPolicy.CLASS) 15 | public @interface Route { 16 | String[] value(); 17 | 18 | String[] interceptors() default {}; 19 | } 20 | -------------------------------------------------------------------------------- /Sample/app/src/main/res/layout/activity_test.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /router/src/main/java/com/chenenyu/router/template/TargetInterceptorsTable.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.template; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Target interceptor mapping. 7 | *

8 | * Created by chenenyu on 2017/6/29. 9 | */ 10 | public interface TargetInterceptorsTable { 11 | /** 12 | * Mapping between target and interceptors, the target class may be an {@link android.app.Activity}, 13 | * or {@link androidx.fragment.app.Fragment}. 14 | * 15 | * @param map target -> interceptors array. 16 | */ 17 | void handle(Map, String[]> map); 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright {2019} {chenenyu} 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /gradle-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'groovy' 2 | 3 | sourceCompatibility = JavaVersion.VERSION_1_8 4 | targetCompatibility = JavaVersion.VERSION_1_8 5 | 6 | repositories { 7 | google() 8 | } 9 | 10 | dependencies { 11 | implementation gradleApi() 12 | implementation localGroovy() 13 | compileOnly 'com.android.tools.build:gradle:7.2.1' 14 | compileOnly 'com.android.tools:common:30.2.1' 15 | compileOnly 'com.android.tools:repository:30.2.1' 16 | } 17 | 18 | ext { 19 | GROUP = 'com.chenenyu.router' 20 | ARTIFACT = 'gradle-plugin' 21 | VERSION = PLUGIN_VERSION 22 | } 23 | 24 | apply from: '../gradle/publish.gradle' -------------------------------------------------------------------------------- /Sample/app/src/main/res/layout/activity_dynamic.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /compiler/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | tasks.withType(JavaCompile) { 4 | options.encoding = "UTF-8" 5 | } 6 | 7 | sourceCompatibility = JavaVersion.VERSION_1_8 8 | targetCompatibility = JavaVersion.VERSION_1_8 9 | 10 | dependencies { 11 | implementation fileTree(include: ['*.jar'], dir: 'libs') 12 | implementation 'com.squareup:javapoet:1.13.0' 13 | // implementation project(':annotation') 14 | implementation "com.chenenyu.router:annotation:${ANNOTATION_VERSION}" 15 | } 16 | 17 | ext { 18 | GROUP = 'com.chenenyu.router' 19 | ARTIFACT = 'compiler' 20 | VERSION = COMPILER_VERSION 21 | } 22 | 23 | //apply from: '../gradle/publish.gradle' 24 | -------------------------------------------------------------------------------- /Sample/app/src/main/java/com/chenenyu/router/app/InterceptedActivity.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.app; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.appcompat.app.AppCompatActivity; 6 | 7 | import com.chenenyu.router.annotation.Route; 8 | 9 | @Route(value = "intercepted", interceptors = {"AInterceptor", "BInterceptor"}) 10 | //@Route(value = "intercepted", interceptors = {"BInterceptor", "AInterceptor"}) 11 | public class InterceptedActivity extends AppCompatActivity { 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_intercepted); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | # annotation 2 | ./gradlew clean -p annotation 3 | ./gradlew publishReleasePublicationToMavenRepository -p annotation 4 | 5 | # compiler 6 | ./gradlew clean -p compiler 7 | #./gradlew publishReleasePublicationToMavenLocal -p compiler # for test 8 | ./gradlew publishReleasePublicationToMavenRepository -p compiler 9 | 10 | # router 11 | ./gradlew clean -p router 12 | #./gradlew publishReleasePublicationToMavenLocal -p router # for test 13 | ./gradlew publishReleasePublicationToMavenRepository -p router 14 | 15 | # gradle-plugin 16 | ./gradlew clean -p gradle-plugin 17 | #./gradlew publishReleasePublicationToMavenLocal -p gradle-plugin # for test 18 | ./gradlew publishReleasePublicationToMavenRepository -p gradle-plugin -------------------------------------------------------------------------------- /router/src/main/java/com/chenenyu/router/matcher/AbsImplicitMatcher.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.matcher; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | 7 | import androidx.annotation.Nullable; 8 | 9 | /** 10 | * Base mather for implicit intent. 11 | *

12 | * Created by chenenyu on 2017/3/12. 13 | */ 14 | public abstract class AbsImplicitMatcher extends AbsMatcher { 15 | 16 | public AbsImplicitMatcher(int priority) { 17 | super(priority); 18 | } 19 | 20 | @Override 21 | public Object generate(Context context, Uri uri, @Nullable Class target) { 22 | return new Intent(Intent.ACTION_VIEW, uri); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /router/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 12 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /router/src/main/java/com/chenenyu/router/matcher/DirectMatcher.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.matcher; 2 | 3 | import android.content.Context; 4 | import android.net.Uri; 5 | 6 | import androidx.annotation.Nullable; 7 | 8 | import com.chenenyu.router.RouteRequest; 9 | 10 | /** 11 | * Absolutely matcher. 12 | *

13 | * Created by chenenyu on 2016/12/23. 14 | */ 15 | public class DirectMatcher extends AbsExplicitMatcher { 16 | 17 | public DirectMatcher(int priority) { 18 | super(priority); 19 | } 20 | 21 | @Override 22 | public boolean match(Context context, Uri uri, @Nullable String route, RouteRequest routeRequest) { 23 | return !isEmpty(route) && uri.toString().equals(route); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Sample/app/src/main/java/com/chenenyu/router/app/WebActivity.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.app; 2 | 3 | import android.os.Bundle; 4 | import android.webkit.WebView; 5 | 6 | import androidx.appcompat.app.AppCompatActivity; 7 | 8 | public class WebActivity extends AppCompatActivity { 9 | WebView mWebView; 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | 15 | mWebView = new WebView(this); 16 | setContentView(mWebView); 17 | mWebView.loadUrl("file:///android_asset/scheme.html"); 18 | } 19 | 20 | @Override 21 | protected void onDestroy() { 22 | super.onDestroy(); 23 | mWebView.destroy(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Sample/app/src/main/java/com/chenenyu/router/app/GlobalInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.chenenyu.router.app; 2 | 3 | import android.util.Log; 4 | 5 | import androidx.annotation.NonNull; 6 | 7 | import com.chenenyu.router.RouteInterceptor; 8 | import com.chenenyu.router.RouteResponse; 9 | 10 | /** 11 | * Global interceptor. 12 | *

13 | * Created by chenenyu on 2017/9/11. 14 | */ 15 | public class GlobalInterceptor implements RouteInterceptor { 16 | @NonNull 17 | @Override 18 | public RouteResponse intercept(Chain chain) { 19 | Log.d("GlobalInterceptor", String.format("{uri: %s, interceptor: %s}", 20 | chain.getRequest().getUri().toString(), GlobalInterceptor.class.getName())); 21 | return chain.process(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sample/app/src/main/assets/scheme.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | Router 8 | 9 | 10 |

This's a WebView.
11 | 25 | 26 | -------------------------------------------------------------------------------- /Sample/module1/src/main/res/layout/fragment_module1.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 |