├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── .gitignore ├── .idea ├── caches │ ├── build_file_checksums.ser │ └── gradle_models.ser ├── codeStyles │ └── Project.xml ├── compiler.xml ├── dictionaries │ └── Wiki.xml ├── encodings.xml ├── gradle.xml ├── jarRepositories.xml ├── markdown-navigator.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── LICENSE ├── README.md ├── build.gradle ├── doc ├── IDEA 插件.md ├── RouterComponent、RouterTask、RouterDelegate对比.md ├── 利用拦截器实现统一处理页面URL和HTTP URL.md ├── 开始使用 GRouter.md ├── 引入 GRouter.md ├── 混淆 Proguard.md ├── 组件化关键概念.md └── 通过服务降级拦截需要登录的页面,引导用户登录,成功后调到目标页面.md ├── example ├── app-shell │ ├── shell-base │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── t │ │ │ │ └── example_shell_webview │ │ │ │ └── ExampleInstrumentedTest.kt │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── t │ │ │ │ │ └── example_shell_webview │ │ │ │ │ ├── DebugMockInterceptor.kt │ │ │ │ │ └── MockBaseApplication.kt │ │ │ └── res │ │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ ├── drawable │ │ │ │ └── ic_launcher_background.xml │ │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── t │ │ │ └── example_shell_webview │ │ │ └── ExampleUnitTest.kt │ └── shell-webview │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── t │ │ │ └── example_shell_webview │ │ │ └── ExampleInstrumentedTest.kt │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── t │ │ │ │ └── example_shell_webview │ │ │ │ ├── MainActivity.kt │ │ │ │ └── MockWebViewApplication.kt │ │ └── res │ │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── drawable │ │ │ └── ic_launcher_background.xml │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── t │ │ └── example_shell_webview │ │ └── ExampleUnitTest.kt ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── debug │ │ ├── AndroidManifest.xml2 │ │ └── java │ │ │ └── mock │ │ │ ├── DebugMockIntercepter.kt │ │ │ ├── MockBaseApplication.kt │ │ │ └── MockWebViewApplication.kt │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── grouter │ │ │ │ └── demo │ │ │ │ ├── AppRouterInterceptor.kt │ │ │ │ ├── BaseActivity.java │ │ │ │ ├── LoginRouterInterceptor.kt │ │ │ │ ├── MainActivity.kt │ │ │ │ ├── MyApplication.kt │ │ │ │ ├── _GRouter.kt │ │ │ │ ├── activity │ │ │ │ ├── AboutUsActivity.java │ │ │ │ ├── CinemaActivity.java │ │ │ │ ├── CinemaDetailActivity.java │ │ │ │ ├── LoginActivity.java │ │ │ │ ├── MomentActivity.java │ │ │ │ ├── MomentListActivity.java │ │ │ │ ├── MovieActivity.java │ │ │ │ ├── MoviePhotoActivity.java │ │ │ │ ├── MovieWorkerActivity.java │ │ │ │ ├── NetworkPingActivity.java │ │ │ │ ├── OverridePendingTransitionActivity.kt │ │ │ │ ├── OverridePendingTransitionTargetActivity.kt │ │ │ │ ├── SettingsActivity.java │ │ │ │ └── UserActivity.kt │ │ │ │ ├── component │ │ │ │ └── ComponentTestActivity.kt │ │ │ │ ├── delegate │ │ │ │ ├── MomentViewModel.kt │ │ │ │ └── UserViewModel.java │ │ │ │ ├── kotlin │ │ │ │ └── Crew.kt │ │ │ │ └── service │ │ │ │ ├── FeedServiceImpl.kt │ │ │ │ └── UserListTask.java │ │ └── res │ │ │ ├── layout │ │ │ ├── activity_component_test.xml │ │ │ ├── activity_main.xml │ │ │ ├── activity_override_pending_transition.xml │ │ │ ├── activity_override_pending_transition_target.xml │ │ │ ├── activity_second.xml │ │ │ ├── activity_test1.xml │ │ │ ├── activity_test2.xml │ │ │ ├── activity_third.xml │ │ │ └── content_component_test.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── grouter │ │ └── demo │ │ ├── UserTest.kt │ │ ├── delegate │ │ └── UserViewModelTest.java │ │ └── service │ │ └── AccountServiceTest.java ├── base │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── taoweiji │ │ │ └── basemodule │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── grouter │ │ │ │ └── demo │ │ │ │ ├── Account2Service.kt │ │ │ │ ├── base │ │ │ │ ├── model │ │ │ │ │ ├── Moment.kt │ │ │ │ │ └── User.kt │ │ │ │ ├── service │ │ │ │ │ ├── AccountService.kt │ │ │ │ │ ├── FeedService.kt │ │ │ │ │ └── UserService.kt │ │ │ │ └── view │ │ │ │ │ └── CrewActivity.java │ │ │ │ └── service │ │ │ │ └── WaimaiService.java │ │ ├── res │ │ │ ├── layout │ │ │ │ ├── activity_crew.xml │ │ │ │ └── content_crew.xml │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ └── xml │ │ │ │ └── network_security_config.xml │ │ └── router │ │ │ └── com │ │ │ └── grouter │ │ │ ├── GActivityCenter.java │ │ │ ├── GComponentCenter.java │ │ │ ├── GDelegateCenter.java │ │ │ ├── GRouterInitializer.java │ │ │ ├── GTaskCenter.java │ │ │ └── data │ │ │ ├── Router-app.json │ │ │ ├── Router-base.json │ │ │ ├── Router-travel.json │ │ │ ├── Router-waimai.json │ │ │ └── Router-webview.json │ │ └── test │ │ └── java │ │ └── com │ │ └── taoweiji │ │ └── basemodule │ │ └── ExampleUnitTest.java ├── example.gradle ├── travel │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── grouter │ │ │ └── example │ │ │ └── travel │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── grouter │ │ │ │ └── example │ │ │ │ └── travel │ │ │ │ ├── TravelHomeActivity.java │ │ │ │ ├── TravelMapActivity.java │ │ │ │ ├── TravelPoiActivity.java │ │ │ │ └── TravelPoiDetailActivity.java │ │ └── res │ │ │ └── values │ │ │ └── strings.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── grouter │ │ └── example │ │ └── travel │ │ └── ExampleUnitTest.java ├── waimai │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── grouter │ │ │ └── demo │ │ │ ├── other │ │ │ ├── OtherRouterInterceptor.java │ │ │ ├── activity │ │ │ │ ├── AccountBindActivity.java │ │ │ │ ├── AccountLoginActivity.java │ │ │ │ └── UserFragment.java │ │ │ └── service │ │ │ │ ├── AccountServiceImpl.kt │ │ │ │ ├── GetUserTask.java │ │ │ │ ├── UserLoginTask.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── service │ │ │ └── WaimaiServiceImpl.java │ │ └── res │ │ ├── layout │ │ └── activity_other_module.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── dimens.xml │ │ └── strings.xml └── webview │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── grouter_test.html │ ├── java │ └── com │ │ └── grouter │ │ └── demo │ │ └── webview │ │ └── activity │ │ └── WebViewActivity.kt │ └── res │ ├── layout │ ├── activity_other_module.xml │ └── activity_web_view.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ └── strings.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── grouter-annotation ├── .gitignore ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── grouter │ ├── RouterActivity.java │ ├── RouterComponent.java │ ├── RouterComponentConstructor.java │ ├── RouterDelegate.java │ ├── RouterDelegateConstructor.java │ ├── RouterDelegateMethod.java │ ├── RouterDocument.java │ ├── RouterField.java │ ├── RouterInterceptor.java │ └── RouterTask.java ├── grouter-compiler ├── .gitignore ├── build.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── grouter │ │ │ └── compiler │ │ │ ├── ActivityModel.java │ │ │ ├── ComponentModel.java │ │ │ ├── FileUtils.java │ │ │ ├── InterceptorModel.java │ │ │ ├── ParameterModel.java │ │ │ ├── RouterActivityCodeBuilder.java │ │ │ ├── RouterAutoInitializerBuilder.java │ │ │ ├── RouterBuildHelper.java │ │ │ ├── RouterComponentCodeBuilder.java │ │ │ ├── RouterDelegateCodeBuilder.java │ │ │ ├── RouterDelegateModel.java │ │ │ ├── RouterModel.java │ │ │ ├── RouterTaskCodeBuilder.java │ │ │ ├── TaskModel.java │ │ │ ├── TypeUtils.java │ │ │ └── processor │ │ │ ├── ActivityProcessor.java │ │ │ ├── ComponentProcessor.java │ │ │ ├── DelegateProcessor.java │ │ │ ├── InterceptorProcessor.java │ │ │ ├── RouterProcessor.java │ │ │ └── TaskProcessor.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── javax.annotation.processing.Processor │ └── test │ └── java │ └── com │ └── grouter │ └── compiler │ ├── JavapoetTest.java │ └── RouterBuildHelperTest.java ├── grouter-gradle-plugin ├── .gitignore ├── build.gradle └── src │ ├── main │ ├── groovy │ │ └── com │ │ │ └── grouter │ │ │ └── gradle │ │ │ └── plugin │ │ │ ├── GRouterExtension.groovy │ │ │ └── GRouterPlugin.groovy │ ├── java │ │ ├── com │ │ │ └── grouter │ │ │ │ └── compiler │ │ │ │ ├── ActivityModel.java │ │ │ │ ├── ComponentModel.java │ │ │ │ ├── FileUtils.java │ │ │ │ ├── InterceptorModel.java │ │ │ │ ├── ParameterModel.java │ │ │ │ ├── RouterActivityCodeBuilder.java │ │ │ │ ├── RouterAutoInitializerBuilder.java │ │ │ │ ├── RouterBuildHelper.java │ │ │ │ ├── RouterComponentCodeBuilder.java │ │ │ │ ├── RouterDelegateCodeBuilder.java │ │ │ │ ├── RouterDelegateModel.java │ │ │ │ ├── RouterModel.java │ │ │ │ ├── RouterTaskCodeBuilder.java │ │ │ │ ├── TaskModel.java │ │ │ │ └── TypeUtils.java │ │ └── router │ │ │ ├── KotlinTypeUtils.java │ │ │ ├── ParserHelper.java │ │ │ ├── activity │ │ │ ├── ActivityJavaSourceFileParser.java │ │ │ ├── ActivityKotlinSourceFileParser.java │ │ │ ├── ActivitySourceFileParser.java │ │ │ └── ActivitySourceFileParserHelper.java │ │ │ ├── component │ │ │ ├── ComponentJavaSourceFileParser.java │ │ │ ├── ComponentKotlinSourceFileParser.java │ │ │ ├── ComponentSourceFileHelper.java │ │ │ └── ComponentSourceFileParser.java │ │ │ ├── delegate │ │ │ ├── DelegateJavaSourceFileParser.java │ │ │ ├── DelegateKotlinSourceFileParser.java │ │ │ ├── DelegateSourceFileHelper.java │ │ │ └── DelegateSourceFileParser.java │ │ │ └── task │ │ │ ├── TaskJavaSourceFileParser.java │ │ │ ├── TaskKotlinSourceFileParser.java │ │ │ ├── TaskSourceFileParser.java │ │ │ └── TaskSourceFileParserHelper.java │ └── resources │ │ └── META-INF │ │ ├── gradle-plugins │ │ └── grouter.properties │ │ └── grouter.html │ └── test │ └── java │ └── router │ ├── ComponentRouterJavaRouterSourceFileParserTest.java │ ├── DelegateKotlinSourceFileParserTest.java │ ├── RouterJavaRouterSourceFileParserTest.java │ └── RouterKotlinRouterSourceFileParserTest.java ├── grouter-kotlinextensions ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── grouter │ │ └── kotlinextensions │ │ └── ExampleInstrumentedTest.kt │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── grouter │ │ └── kotlinextensions │ │ └── ActivityExtensions.kt │ └── res │ └── values │ └── strings.xml ├── grouter ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── grouter │ │ └── hybrid │ │ └── GRouterJavascriptInterfaceTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── grouter │ │ │ ├── ActivityRequest.java │ │ │ ├── ComponentRequest.java │ │ │ ├── ComponentUtils.java │ │ │ ├── DefaultMultiProjectGRouter.java │ │ │ ├── ErrorTask.java │ │ │ ├── GActivityBuilder.java │ │ │ ├── GActivityUtils.java │ │ │ ├── GRouter.java │ │ │ ├── GRouterInterceptor.java │ │ │ ├── GRouterLogger.java │ │ │ ├── GRouterTask.java │ │ │ ├── GRouterTaskBuilder.java │ │ │ ├── InterceptorUtils.java │ │ │ ├── LoggerUtils.java │ │ │ ├── MockTask.java │ │ │ ├── RouterInject.java │ │ │ ├── RouterUtils.java │ │ │ ├── SafeBundle.java │ │ │ ├── TaskRequest.java │ │ │ ├── fragment │ │ │ └── FragmentBuilder.java │ │ │ └── hybrid │ │ │ └── GRouterJavascriptInterface.java │ └── res │ │ ├── anim │ │ ├── activity_bottom_to_top_enter.xml │ │ ├── activity_bottom_to_top_exit.xml │ │ ├── activity_left_to_right_enter.xml │ │ ├── activity_left_to_right_exit.xml │ │ ├── activity_right_to_left_enter.xml │ │ ├── activity_right_to_left_exit.xml │ │ ├── activity_top_to_bottom_enter.xml │ │ ├── activity_top_to_bottom_exit.xml │ │ ├── fade_in.xml │ │ ├── fade_out.xml │ │ └── no_anim.xml │ │ └── values │ │ └── config.xml │ └── test │ └── java │ └── com │ └── grouter │ ├── GRouterTaskTest.java │ ├── RouterInjectTest.java │ ├── fragment │ └── FragmentBuilderTest.java │ └── hybrid │ └── GRouterJavascriptInterfaceTest.java ├── maven_public.gradle └── settings.gradle /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | /upload_jcenter.sh 10 | repo -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/caches/gradle_models.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/.idea/caches/gradle_models.ser -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/dictionaries/Wiki.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | gcomponent 5 | grouter 6 | taoweiji 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 32 | 33 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.3.41' 5 | 6 | repositories { 7 | maven { url uri('./repo') } 8 | mavenCentral() 9 | google() 10 | } 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:3.5.4' 13 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 14 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41" 15 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 16 | 17 | classpath 'io.github.taoweiji.grouter:grouter-gradle-plugin:+' 18 | } 19 | } 20 | 21 | allprojects { 22 | repositories { 23 | maven { url uri('./repo') } 24 | mavenCentral() 25 | google() 26 | } 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | 33 | allprojects { 34 | tasks.withType(Javadoc) { 35 | options.addStringOption('Xdoclint:none', '-quiet') 36 | options.addStringOption('encoding', 'UTF-8') 37 | } 38 | } -------------------------------------------------------------------------------- /doc/IDEA 插件.md: -------------------------------------------------------------------------------- 1 | 为了方便开发,GRouter提供强大的 IDEA 插件,通过插件可以非常方便实现跳转到目标类。 2 | 3 | -------------------------------------------------------------------------------- /doc/RouterComponent、RouterTask、RouterDelegate对比.md: -------------------------------------------------------------------------------- 1 | 2 | GRouter 提供三种组件间通信组件,RouterComponent、RouterTask和RouterDelegate,各个组件都有不同的特点有不同的应用场景。 3 | 4 | 5 | 6 | | | RouterComponent | RouterTask | RouterDelegate | 7 | | ------------- | ------------------------------------------------------------ | ----------------------------------------- | ------------------------------------------------------------ | 8 | | 跨Project调用 | 支持 | 支持 | 不支持 | 9 | | 描述 | 接口下沉式组件间服务 | 非下沉式组件间单任务服务 | 代理式服务 | 10 | | 缺点 | 需要在BaseModule下沉接口,适合在当前Project中使用,跨Project成本较大 | 每个Task只能执行一种任务 | 整体使用反射实现,与实现类关联性很低,只适合在当前Project使用 | 11 | | 优点 | | 依赖性很低,特别适合在跨Project项目中使用 | | 12 | | | | | | 13 | 14 | 15 | 16 | ### RouterComponent(需要下沉接口,多工程) 17 | 通常用于频繁使用的组件,比如获取当前的登录信息,获取单个用户信息等,使用频率很高,在各个Module都有不同程度的调用,由于是接口实现方式实现,代码调用方便。 18 | 19 | ### RouterDelegate(需要下沉Class,最简单,当前工程) 20 | RouterDelegate 的使用极其简单,原理是在BaseModule生成对应的壳类,通过反射代理的方式调用原来的类,虽然反射并没有降低太多的性能,但是使用时候需要更多的注意,因为需要代理的方法依赖的Class(eg. User.class)必须在BaseModule也存在,否则会生成代码出错,一旦出错就需要使用Gradle插件`GRouterFixRelease`命令解决错误。 21 | 22 | ### RouterTask(多工程、混合开发,功能强大) 23 | 24 | RouterTask的使用非常广泛,无需下沉接口,支持URL调用,相当于远程服务器API一样,可以在当前的Project使用,也可以解决不同的Project的服务调用问题,而且还支持 `Hybrid H5`和`Flutter`混合开发调用服务,支持转换成String、Map、反序列化对象和List,方便调用者在无依赖情况下使用,应用范围比RouterComponent和RouterDelegate大很多。 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /doc/利用拦截器实现统一处理页面URL和HTTP URL.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 提出 grouter_extras 概念 4 | link url,结合iOS,HTTP协议 -------------------------------------------------------------------------------- /doc/引入 GRouter.md: -------------------------------------------------------------------------------- 1 | 配置 gradle.properties 2 | 3 | ```properties 4 | # 如果是多Module,请填写填写BaseModule的路径{base-module-name}/src/main/java 5 | GROUTER_SOURCE_PATH =app/src/main/java 6 | # 请填写自己项目独特的scheme 7 | GROUTER_SCHEME =grouter 8 | ``` 9 | 10 | 配置根目录 build.gradle 11 | 12 | ```groovy 13 | buildscript { 14 | repositories { 15 | jcenter() 16 | maven { url 'https://dl.bintray.com/grouter/maven' } 17 | } 18 | dependencies { 19 | classpath 'com.grouter:grouter-gradle-plugin:1.0.0' 20 | } 21 | } 22 | ``` 23 | 24 | 在每一个Module的 build.gradle 增加 25 | 26 | ```groovy 27 | // 需要注意顺序,必须放在其它 'apply plugin: XXX' 后面 28 | apply plugin: 'grouter' 29 | ``` 30 | 31 | 在 MyApplication 进行初始化 32 | 33 | ```kotlin 34 | // 需要根据项目使用的json序列化框架实现序列化,下面的fastjson的序列化方案 35 | GRouter.setSerialization(object : GRouter.Serialization { 36 | override fun serializable(any: Any): String { 37 | return JSON.toJSONString(any) 38 | } 39 | override fun deserializeObject(json: String, clazz: Class): T? { 40 | return JSON.parseObject(json, clazz) 41 | } 42 | override fun deserializeList(json: String, clazz: Class): List? { 43 | return JSON.parseArray(json, clazz) 44 | } 45 | }) 46 | GRouter.getInstance().init(this, BuildConfig.BUILD_TYPE, null) 47 | ``` 48 | 49 | -------------------------------------------------------------------------------- /doc/混淆 Proguard.md: -------------------------------------------------------------------------------- 1 | ### ProGuard 混淆 2 | 3 | 如果项目用到了混淆,需要添加下面代码到proguard-rules.pro 4 | 5 | ```properties 6 | -keep class com.grouter.GRouterInitializer 7 | -keep @com.grouter.RouterComponent class * 8 | -keep @com.grouter.RouterDelegate class * 9 | -keep @com.grouter.RouterInterceptor class * 10 | -keep @com.grouter.RouterTask class * 11 | -keep @com.grouter.RouterActivity class * 12 | -keepclasseswithmembers class * { 13 | @com.grouter.RouterField ; 14 | } 15 | -keepclasseswithmembers class * { 16 | @com.grouter.RouterDelegateMethod ; 17 | } 18 | -keepclasseswithmembers class * { 19 | @com.grouter.RouterDelegateConstructor (...); 20 | } 21 | -keepclasseswithmembers class * { 22 | @com.grouter.RouterComponentConstructor (...); 23 | } 24 | 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /doc/组件化关键概念.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/doc/组件化关键概念.md -------------------------------------------------------------------------------- /doc/通过服务降级拦截需要登录的页面,引导用户登录,成功后调到目标页面.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/doc/通过服务降级拦截需要登录的页面,引导用户登录,成功后调到目标页面.md -------------------------------------------------------------------------------- /example/app-shell/shell-base/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /example/app-shell/shell-base/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | 6 | android { 7 | compileSdkVersion 30 8 | buildToolsVersion '28.0.3' 9 | 10 | defaultConfig { 11 | minSdkVersion 14 12 | targetSdkVersion 30 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 17 | 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | compileOptions { 26 | sourceCompatibility 1.8 27 | targetCompatibility 1.8 28 | } 29 | } 30 | 31 | dependencies { 32 | implementation fileTree(include: ['*.jar'], dir: 'libs') 33 | 34 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 35 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 36 | testImplementation 'junit:junit:4.12' 37 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 38 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 39 | api 'androidx.appcompat:appcompat:1.0.0' 40 | // api project(':example:grouter') 41 | api project(':example:base') 42 | api 'com.alibaba:fastjson:1.1.45.android' 43 | // api 'org.mockito:mockito-core:3.0.0' 44 | api 'org.mockito:mockito-android:3.0.0' 45 | } -------------------------------------------------------------------------------- /example/app-shell/shell-base/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/androidTest/java/com/t/example_shell_webview/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.t.example_shell_webview 2 | 3 | import android.support.test.InstrumentationRegistry 4 | import android.support.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.t.example_shell_webview", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/java/com/t/example_shell_webview/DebugMockInterceptor.kt: -------------------------------------------------------------------------------- 1 | package com.t.example_shell_webview 2 | 3 | import com.grouter.* 4 | import com.grouter.demo.base.model.User 5 | import com.grouter.demo.base.service.AccountService 6 | import com.grouter.demo.base.service.UserService 7 | import org.mockito.Mockito 8 | import java.lang.Exception 9 | 10 | class DebugMockInterceptor : GRouterInterceptor() { 11 | 12 | override fun process(request: TaskRequest): Boolean { 13 | if (request.path == "getLoginUser") { 14 | request.onContinueResult(User(123, "202cb962ac59075b964b07152d234b70")) 15 | return true 16 | } 17 | return super.process(request) 18 | } 19 | 20 | override fun onError(request: TaskRequest, exception: Exception): Boolean { 21 | if (request.path == "getLoginUser") { 22 | request.onContinueResult(User(123, "202cb962ac59075b964b07152d234b70")) 23 | return true 24 | } 25 | return super.onError(request, exception) 26 | } 27 | 28 | override fun process(request: ComponentRequest): Boolean { 29 | if (request.protocol == UserService::class.java) { 30 | val userService = Mockito.mock(UserService::class.java) 31 | Mockito.`when`(userService.getUser(1)).thenReturn(User(1, "Mockito")) 32 | request.onContinue(userService) 33 | return true 34 | } else if (request.protocol == AccountService::class.java) { 35 | val accountService = Mockito.mock(AccountService::class.java) 36 | Mockito.`when`(accountService.getLoginUser()).thenReturn(User(101, "Mockito")) 37 | request.onContinue(accountService) 38 | return true 39 | } 40 | return super.process(request) 41 | } 42 | 43 | override fun onError(request: ComponentRequest, exception: Exception): Boolean { 44 | if (request.protocol == UserService::class.java) { 45 | val userService: UserService = Mockito.mock(UserService::class.java) 46 | Mockito.`when`(userService.getUser(1)).thenReturn(User(1, "Mockito")) 47 | request.onContinue(userService) 48 | return true 49 | } 50 | return super.onError(request, exception) 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/java/com/t/example_shell_webview/MockBaseApplication.kt: -------------------------------------------------------------------------------- 1 | package com.t.example_shell_webview 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import com.alibaba.fastjson.JSON 6 | import com.grouter.GComponentCenter 7 | import com.grouter.GRouter 8 | import com.grouter.demo.base.model.User 9 | import com.grouter.demo.base.service.UserService 10 | import com.t.example_shell_base.BuildConfig 11 | import org.mockito.Mockito 12 | import org.mockito.Mockito.mock 13 | 14 | open class MockBaseApplication:Application() { 15 | override fun onCreate() { 16 | super.onCreate() 17 | GRouter.setSerialization(object : GRouter.Serialization { 18 | override fun serialize(any: Any): String { 19 | return JSON.toJSONString(any) 20 | } 21 | 22 | override fun deserializeObject(json: String, clazz: Class): T? { 23 | return JSON.parseObject(json, clazz) 24 | } 25 | 26 | override fun deserializeList(json: String, clazz: Class): List? { 27 | return JSON.parseArray(json, clazz) 28 | } 29 | }) 30 | GRouter.getInstance().init(this, BuildConfig.BUILD_TYPE, null) 31 | System.setProperty("org.mockito.android.target",getDir("target", Context.MODE_PRIVATE).absolutePath) 32 | } 33 | } -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/example/app-shell/shell-base/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/example/app-shell/shell-base/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/example/app-shell/shell-base/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/example/app-shell/shell-base/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/example/app-shell/shell-base/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/example/app-shell/shell-base/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/example/app-shell/shell-base/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/example/app-shell/shell-base/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/example/app-shell/shell-base/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taoweiji/grouter-android/6db9a3671e173eec56481c1a1adc1b4238933c9f/example/app-shell/shell-base/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MockApplication 3 | 4 | -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /example/app-shell/shell-base/src/test/java/com/t/example_shell_webview/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.t.example_shell_webview 2 | 3 | import com.alibaba.fastjson.JSON 4 | import com.grouter.demo.base.model.User 5 | import com.grouter.demo.base.service.UserService 6 | import org.junit.Test 7 | 8 | import org.junit.Assert.* 9 | import org.mockito.Mockito 10 | import org.mockito.internal.util.MockUtil 11 | import org.mockito.mock.MockCreationSettings 12 | import org.mockito.plugins.MockMaker 13 | import org.mockito.plugins.MockitoPlugins 14 | import java.io.File 15 | 16 | /** 17 | * Example local unit test, which will execute on the development machine (host). 18 | * 19 | * See [testing documentation](http://d.android.com/tools/testing). 20 | */ 21 | class ExampleUnitTest { 22 | @Test 23 | fun addition_isCorrect() { 24 | System.setProperty("org.mockito.android.target",File("test").absolutePath) 25 | // MockUtil.createMock() 26 | // MockUtil.createMock(AndroidByteBuddyMockMaker()) 27 | val userService = Mockito.mock(UserService::class.java) 28 | Mockito.`when`(userService.getUser(1)).thenReturn(User(1,"Mockito")) 29 | val user = userService.getUser(1) 30 | println(JSON.toJSONString(user)) 31 | assertEquals("Mockito", user.name) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example/app-shell/shell-webview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /example/app-shell/shell-webview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | android { 5 | compileSdkVersion 30 6 | 7 | 8 | defaultConfig { 9 | applicationId "com.t.example_shell_webview" 10 | minSdkVersion 21 11 | targetSdkVersion 30 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | compileOptions { 25 | sourceCompatibility 1.8 26 | targetCompatibility 1.8 27 | } 28 | 29 | } 30 | 31 | dependencies { 32 | implementation fileTree(dir: 'libs', include: ['*.jar']) 33 | testImplementation 'junit:junit:4.12' 34 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 35 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 36 | implementation project(':example:app-shell:shell-base') 37 | implementation project(':example:webview') 38 | } 39 | -------------------------------------------------------------------------------- /example/app-shell/shell-webview/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /example/app-shell/shell-webview/src/androidTest/java/com/t/example_shell_webview/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.t.example_shell_webview 2 | 3 | import android.support.test.InstrumentationRegistry 4 | import android.support.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.t.example_shell_webview", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/app-shell/shell-webview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /example/app-shell/shell-webview/src/main/java/com/t/example_shell_webview/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.t.example_shell_webview 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import android.util.Log 6 | import com.alibaba.fastjson.JSON 7 | import com.grouter.GActivityCenter 8 | import com.grouter.GComponentCenter 9 | import com.grouter.GRouter 10 | import com.grouter.demo.base.model.User 11 | import com.grouter.demo.base.service.UserService 12 | import kotlinx.android.synthetic.main.activity_main.* 13 | 14 | class MainActivity : AppCompatActivity() { 15 | 16 | override fun onCreate(savedInstanceState: Bundle?) { 17 | super.onCreate(savedInstanceState) 18 | setContentView(R.layout.activity_main) 19 | val response = GRouter.getInstance().taskBuilder("getLoginUser").put("uid", 1).execute() 20 | Log.e("getLoginUser", "结果${response.string()}") 21 | open_web_view.setOnClickListener { 22 | GActivityCenter.WebViewActivity().url("http://baidu.com").start(this) 23 | } 24 | val userService = GComponentCenter.UserServiceImpl() 25 | val user = userService.getUser(1) 26 | Log.e("getUser", "结果${JSON.toJSONString(user)}") 27 | 28 | val accountService = GComponentCenter.AccountServiceImpl() 29 | val loginUser: User? = accountService.getLoginUser() 30 | Log.e("loginUser", "结果${JSON.toJSONString(loginUser)}") 31 | 32 | GRouter.getInstance().getComponent("userService",UserService::class.java) 33 | 34 | GRouter.getInstance().taskBuilder("grouter://task/getUser?uid=1").execute().value(User::class.java) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /example/app-shell/shell-webview/src/main/java/com/t/example_shell_webview/MockWebViewApplication.kt: -------------------------------------------------------------------------------- 1 | package com.t.example_shell_webview 2 | 3 | import com.grouter.GRouter 4 | 5 | class MockWebViewApplication : MockBaseApplication() { 6 | override fun onCreate() { 7 | GRouter.getInstance().addInterceptor(DebugMockInterceptor()) 8 | super.onCreate() 9 | } 10 | } -------------------------------------------------------------------------------- /example/app-shell/shell-webview/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /example/app-shell/shell-webview/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |