├── arouter-ktx
├── .gitignore
├── src
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── dylanc
│ │ │ └── arouter
│ │ │ ├── IRoutePaths.kt
│ │ │ ├── ARouterInitializer.kt
│ │ │ ├── SignInInterceptor.kt
│ │ │ ├── PathsInitializer.kt
│ │ │ ├── RequireSignInContract.kt
│ │ │ ├── ARouter.kt
│ │ │ └── Postcard.kt
│ │ └── AndroidManifest.xml
├── consumer-rules.pro
├── proguard-rules.pro
└── build.gradle
├── module-base
├── .gitignore
├── consumer-rules.pro
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── dylanc
│ │ └── arouter
│ │ └── sample
│ │ └── base
│ │ ├── bean
│ │ └── ApiResponse.kt
│ │ └── constants
│ │ └── Constants.kt
├── 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
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable
│ │ │ │ ├── ic_baseline_account_circle_24.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_splash.xml
│ │ │ │ └── activity_main.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── dylanc
│ │ │ │ └── arouter
│ │ │ │ └── sample
│ │ │ │ ├── constant
│ │ │ │ └── Constants.kt
│ │ │ │ ├── App.kt
│ │ │ │ └── ui
│ │ │ │ ├── SplashActivity.kt
│ │ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── dylanc
│ │ │ └── arouter
│ │ │ └── sample
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── dylanc
│ │ └── arouter
│ │ └── sample
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── module-payment-api
├── .gitignore
├── consumer-rules.pro
├── src
│ ├── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── dylanc
│ │ │ └── arouter
│ │ │ └── sample
│ │ │ └── payment
│ │ │ └── service
│ │ │ ├── Paths.kt
│ │ │ └── PaymentService.kt
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── dylanc
│ │ │ └── arouter
│ │ │ └── sample
│ │ │ └── payment
│ │ │ └── service
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── dylanc
│ │ └── arouter
│ │ └── sample
│ │ └── payment
│ │ └── service
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── module-payment-impl
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── themes.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
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── values-night
│ │ │ │ └── themes.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── layout
│ │ │ │ └── activity_pay.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── manifest
│ │ │ └── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── dylanc
│ │ │ │ └── arouter
│ │ │ │ └── sample
│ │ │ │ └── payment
│ │ │ │ ├── provider
│ │ │ │ └── PaymentServiceProvider.kt
│ │ │ │ └── ui
│ │ │ │ └── PayActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── dylanc
│ │ │ └── arouter
│ │ │ └── sample
│ │ │ └── payment
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── dylanc
│ │ └── arouter
│ │ └── sample
│ │ └── payment
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── module-user-api
├── .gitignore
├── consumer-rules.pro
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── dylanc
│ │ └── arouter
│ │ └── sample
│ │ └── user
│ │ └── service
│ │ ├── bean
│ │ └── User.kt
│ │ ├── Paths.kt
│ │ └── UserService.kt
├── proguard-rules.pro
└── build.gradle
├── module-user-impl
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.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
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_user_info.xml
│ │ │ │ └── activity_login.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── manifest
│ │ │ └── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── dylanc
│ │ │ │ └── arouter
│ │ │ │ └── sample
│ │ │ │ └── user
│ │ │ │ ├── ui
│ │ │ │ ├── login
│ │ │ │ │ ├── LoginViewModel.kt
│ │ │ │ │ └── LoginActivity.kt
│ │ │ │ ├── TestActivity.kt
│ │ │ │ └── userinfo
│ │ │ │ │ └── UserInfoActivity.kt
│ │ │ │ ├── api
│ │ │ │ └── UserApi.kt
│ │ │ │ ├── App.kt
│ │ │ │ ├── repository
│ │ │ │ └── UserRepository.kt
│ │ │ │ └── provider
│ │ │ │ └── UserServiceProvider.kt
│ │ └── AndroidManifest.xml
│ └── userUI2
│ │ └── res
│ │ └── layout
│ │ └── activity_login.xml
├── proguard-rules.pro
└── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── arouter-annotations
├── build.gradle
└── src
│ └── main
│ └── java
│ └── com
│ └── dylanc
│ └── arouter
│ └── annotations
│ ├── RequireSignIn.kt
│ ├── SignInActivity.kt
│ ├── LoginActivityPath.kt
│ └── RequireLoginPath.kt
├── .gitignore
├── settings.gradle
├── arouter-compiler
├── src
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── dylanc
│ │ │ └── arouter
│ │ │ └── compiler
│ │ │ ├── Constants.kt
│ │ │ ├── LoginInfoProcessor.kt
│ │ │ └── PathsProcessor.kt
│ │ └── resources
│ │ └── META-INF
│ │ └── services
│ │ └── javax.annotation.processing.Processor
└── build.gradle
├── gradle.properties
├── gradlew.bat
└── gradlew
/arouter-ktx/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module-base/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module-base/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/sample-app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module-payment-api/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/module-payment-api/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/module-payment-impl/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/module-user-api/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module-user-api/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/module-user-impl/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module-base/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SamplePayment
3 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Sample-Login
3 |
4 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/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/DylanCaiCoding/ARouterKTX/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/DylanCaiCoding/ARouterKTX/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/DylanCaiCoding/ARouterKTX/HEAD/sample-app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module-user-api/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/sample-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-user-impl/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-user-impl/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-user-impl/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample-app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/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/DylanCaiCoding/ARouterKTX/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/DylanCaiCoding/ARouterKTX/HEAD/sample-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-payment-impl/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-payment-impl/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-payment-impl/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-user-impl/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-user-impl/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/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/DylanCaiCoding/ARouterKTX/HEAD/sample-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-payment-impl/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-payment-impl/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-user-impl/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-user-impl/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-payment-impl/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-payment-impl/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-user-impl/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-user-impl/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-user-impl/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-payment-impl/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-payment-impl/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DylanCaiCoding/ARouterKTX/HEAD/module-payment-impl/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample-app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ARouterKTX
3 | Login
4 | Logout
5 |
6 |
--------------------------------------------------------------------------------
/arouter-ktx/src/main/java/com/dylanc/arouter/IRoutePaths.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter
2 |
3 | /**
4 | * @author Dylan Cai
5 | */
6 | interface IRoutePaths {
7 |
8 | fun loadInto(list: ArrayList)
9 | }
--------------------------------------------------------------------------------
/arouter-annotations/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java-library'
3 | id 'kotlin'
4 | }
5 |
6 | java {
7 | sourceCompatibility = JavaVersion.VERSION_1_7
8 | targetCompatibility = JavaVersion.VERSION_1_7
9 | }
--------------------------------------------------------------------------------
/module-payment-api/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
7 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
7 |
--------------------------------------------------------------------------------
/module-payment-api/src/main/java/com/dylanc/arouter/sample/payment/service/Paths.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.payment.service
2 |
3 | /**
4 | * @author Dylan Cai
5 | */
6 |
7 | const val GROUP_PAYMENT = "/payment"
8 | const val PATH_PAYMENT = "$GROUP_PAYMENT/payment"
--------------------------------------------------------------------------------
/arouter-annotations/src/main/java/com/dylanc/arouter/annotations/RequireSignIn.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.annotations
2 |
3 | /**
4 | * @author Dylan Cai
5 | */
6 | @Retention(AnnotationRetention.SOURCE)
7 | @Target(AnnotationTarget.CLASS)
8 | annotation class RequireSignIn
9 |
--------------------------------------------------------------------------------
/arouter-annotations/src/main/java/com/dylanc/arouter/annotations/SignInActivity.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.annotations
2 |
3 | /**
4 | * @author Dylan Cai
5 | */
6 | @Retention(AnnotationRetention.SOURCE)
7 | @Target(AnnotationTarget.CLASS)
8 | annotation class SignInActivity
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/arouter-annotations/src/main/java/com/dylanc/arouter/annotations/LoginActivityPath.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.annotations
2 |
3 | /**
4 | * @author Dylan Cai
5 | */
6 | @Retention(AnnotationRetention.SOURCE)
7 | @Target(AnnotationTarget.FIELD)
8 | annotation class LoginActivityPath
9 |
--------------------------------------------------------------------------------
/arouter-annotations/src/main/java/com/dylanc/arouter/annotations/RequireLoginPath.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.annotations
2 |
3 | /**
4 | * @author Dylan Cai
5 | */
6 | @Retention(AnnotationRetention.SOURCE)
7 | @Target(AnnotationTarget.FIELD)
8 | annotation class RequireLoginPath
9 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat May 23 00:05:36 CST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
7 |
--------------------------------------------------------------------------------
/module-base/src/main/java/com/dylanc/arouter/sample/base/bean/ApiResponse.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.base.bean
2 |
3 | /**
4 | * @author Dylan Cai
5 | * @since 2020/5/24
6 | */
7 | data class ApiResponse(
8 | val code: Int,
9 | val msg: String,
10 | val data: T
11 | )
--------------------------------------------------------------------------------
/module-base/src/main/java/com/dylanc/arouter/sample/base/constants/Constants.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.base.constants
2 |
3 |
4 | /**
5 | * @author Dylan Cai
6 | */
7 |
8 | //const val GROUP_APP = "/app"
9 | //
10 | //@RequireLoginPath
11 | //const val PATH_MAIN = "$GROUP_APP/main"
--------------------------------------------------------------------------------
/module-payment-impl/src/main/manifest/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='ARouterKTX'
2 | include ':sample-app'
3 | include ':arouter-ktx'
4 | include ':module-user-api'
5 | include ':module-base'
6 | include ':module-user-impl'
7 | include ':module-payment-impl'
8 | include ':module-payment-api'
9 | include ':arouter-annotations'
10 | include ':arouter-compiler'
11 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/module-payment-api/src/main/java/com/dylanc/arouter/sample/payment/service/PaymentService.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.payment.service
2 |
3 | import com.alibaba.android.arouter.facade.template.IProvider
4 |
5 | /**
6 | * @author Dylan Cai
7 | */
8 | interface PaymentService : IProvider {
9 | fun aliPay(money: Float)
10 |
11 | fun wechatPay(money: Float)
12 | }
--------------------------------------------------------------------------------
/module-user-api/src/main/java/com/dylanc/arouter/sample/user/service/bean/User.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.user.service.bean
2 |
3 | import android.os.Parcelable
4 | import kotlinx.parcelize.Parcelize
5 |
6 | /**
7 | * @author Dylan Cai
8 | * @since 2020/5/24
9 | */
10 | @Parcelize
11 | data class User(
12 | val id: String,
13 | val name: String
14 | ) : Parcelable
--------------------------------------------------------------------------------
/module-user-impl/src/main/manifest/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/arouter-ktx/consumer-rules.pro:
--------------------------------------------------------------------------------
1 | -keep class com.dylanc.arouter.*{*;}
2 |
3 | -keep public class com.alibaba.android.arouter.routes.**{*;}
4 | -keep public class com.alibaba.android.arouter.facade.**{*;}
5 | -keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
6 | # 如果使用了 byType 的方式获取 Service,需添加下面规则,保护接口
7 | -keep interface * implements com.alibaba.android.arouter.facade.template.IProvider
--------------------------------------------------------------------------------
/arouter-compiler/src/main/java/com/dylanc/arouter/compiler/Constants.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.compiler
2 |
3 | /**
4 | * @author Dylan Cai
5 | */
6 | const val PACKAGE_NAME = "com.alibaba.android.arouter.routes"
7 |
8 | const val PROJECT = "ARouter"
9 |
10 | const val SEPARATOR = "$$"
11 |
12 | const val KEY_MODULE_NAME = "AROUTER_MODULE_NAME"
13 |
14 | const val IROUTE_PATHS = "com.dylanc.arouter.IRoutePaths"
--------------------------------------------------------------------------------
/arouter-compiler/src/main/resources/META-INF/services/javax.annotation.processing.Processor:
--------------------------------------------------------------------------------
1 | com.dylanc.arouter.compiler.PathsProcessor
2 | com.dylanc.arouter.compiler.LoginInfoProcessor
3 | com.alibaba.android.arouter.compiler.processor.RouteProcessor,aggregating
4 | com.alibaba.android.arouter.compiler.processor.AutowiredProcessor,aggregating
5 | com.alibaba.android.arouter.compiler.processor.InterceptorProcessor,aggregating
6 |
--------------------------------------------------------------------------------
/module-user-api/src/main/java/com/dylanc/arouter/sample/user/service/Paths.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.user.service
2 |
3 | import com.dylanc.arouter.annotations.RequireLoginPath
4 | import com.dylanc.arouter.annotations.LoginActivityPath
5 |
6 | const val GROUP_USER = "/user"
7 |
8 | @LoginActivityPath
9 | const val PATH_LOGIN = "$GROUP_USER/login"
10 |
11 | @RequireLoginPath
12 | const val PATH_USER_INFO = "$GROUP_USER/userinfo"
--------------------------------------------------------------------------------
/sample-app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/dylanc/arouter/sample/constant/Constants.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.constant
2 |
3 | import com.dylanc.arouter.annotations.RequireLoginPath
4 | import com.dylanc.retrofit.annotations.BaseUrl
5 |
6 | /**
7 | * @author Dylan Cai
8 | * @since 2020/5/24
9 | */
10 | @BaseUrl
11 | const val BASE_URL = "https://fastmock.site/"
12 |
13 | const val GROUP_APP = "/app"
14 |
15 | const val PATH_MAIN = "$GROUP_APP/main"
--------------------------------------------------------------------------------
/arouter-compiler/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java-library'
3 | id 'kotlin'
4 | }
5 |
6 | dependencies {
7 | implementation "com.squareup:javapoet:1.13.0"
8 | implementation 'com.alibaba:arouter-compiler:1.5.2'
9 | api 'com.alibaba:arouter-annotation:1.0.6'
10 | api project(path: ':arouter-annotations')
11 | }
12 |
13 | java {
14 | sourceCompatibility = JavaVersion.VERSION_1_7
15 | targetCompatibility = JavaVersion.VERSION_1_7
16 | }
17 |
--------------------------------------------------------------------------------
/sample-app/src/test/java/com/dylanc/arouter/sample/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/module-payment-impl/src/test/java/com/dylanc/arouter/sample/payment/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.payment
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/module-payment-api/src/test/java/com/dylanc/arouter/sample/payment/service/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.payment.service
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/dylanc/arouter/sample/App.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample
2 |
3 | import android.app.Application
4 | import com.dylanc.arouter.SignInInterceptor
5 | import com.dylanc.arouter.routerServices
6 | import com.dylanc.arouter.sample.user.service.UserService
7 |
8 | /**
9 | * @author Dylan Cai
10 | */
11 | @Suppress("unused")
12 | class App : Application() {
13 |
14 | private val userService: UserService? by routerServices()
15 |
16 | override fun onCreate() {
17 | super.onCreate()
18 | SignInInterceptor.enable { userService?.isLogin() == true }
19 | }
20 | }
--------------------------------------------------------------------------------
/module-user-api/src/main/java/com/dylanc/arouter/sample/user/service/UserService.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.user.service
2 |
3 | import android.app.Activity
4 | import com.alibaba.android.arouter.facade.template.IProvider
5 | import com.dylanc.arouter.sample.user.service.bean.User
6 | import kotlinx.coroutines.flow.Flow
7 |
8 | /**
9 | * @author Dylan Cai
10 | * @since 2020/5/24
11 | */
12 | interface UserService : IProvider {
13 | fun login(username: String, password: String): Flow
14 |
15 | fun logout(activity: Activity)
16 |
17 | fun isLogin(): Boolean
18 |
19 | val username: String?
20 | }
--------------------------------------------------------------------------------
/sample-app/src/main/res/drawable/ic_baseline_account_circle_24.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/java/com/dylanc/arouter/sample/user/ui/login/LoginViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.user.ui.login
2 |
3 | import androidx.lifecycle.asLiveData
4 | import com.dylanc.arouter.sample.user.repository.UserRepository
5 | import com.dylanc.retrofit.coroutines.RequestViewModel
6 | import com.dylanc.retrofit.coroutines.catchWith
7 | import com.dylanc.retrofit.coroutines.showLoadingWith
8 |
9 | /**
10 | * @author Dylan Cai
11 | */
12 | class LoginViewModel : RequestViewModel() {
13 |
14 | fun login(username: String, password: String) =
15 | UserRepository.login(username, password)
16 | .showLoadingWith(loadingFlow)
17 | .catchWith(exceptionFlow)
18 | .asLiveData()
19 | }
--------------------------------------------------------------------------------
/module-user-impl/src/main/java/com/dylanc/arouter/sample/user/api/UserApi.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.user.api
2 |
3 | import com.dylanc.arouter.sample.base.bean.ApiResponse
4 | import com.dylanc.arouter.sample.user.service.bean.User
5 | import retrofit2.http.Field
6 | import retrofit2.http.FormUrlEncoded
7 | import retrofit2.http.POST
8 |
9 | /**
10 | * @author Dylan Cai
11 | * @since 2020/5/24
12 | */
13 | private const val USER = "mock/fcd983f6975dc5cfcb8b28b0f12b645f/component/user"
14 |
15 | interface UserApi {
16 |
17 | @FormUrlEncoded
18 | @POST("$USER/login")
19 | suspend fun login(
20 | @Field("username") username: String,
21 | @Field("password") password: String
22 | ): ApiResponse
23 | }
--------------------------------------------------------------------------------
/module-user-impl/src/main/java/com/dylanc/arouter/sample/user/App.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.user
2 |
3 | import android.app.Application
4 | import com.dylanc.arouter.SignInInterceptor
5 | import com.dylanc.arouter.routerServices
6 | import com.dylanc.arouter.sample.user.service.UserService
7 | import com.dylanc.retrofit.initRetrofit
8 |
9 | /**
10 | * @author Dylan Cai
11 | */
12 | @Suppress("unused")
13 | class App : Application() {
14 |
15 | private val userService: UserService? by routerServices()
16 |
17 | override fun onCreate() {
18 | super.onCreate()
19 | SignInInterceptor.enable { userService?.isLogin() == true }
20 |
21 | initRetrofit {
22 | baseUrl("https://fastmock.site/")
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/arouter-ktx/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
12 |
15 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/java/com/dylanc/arouter/sample/user/ui/TestActivity.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.user.ui
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 | import com.dylanc.arouter.sample.user.service.PATH_USER_INFO
6 | import com.dylanc.arouter.sample.user.databinding.ActivityMainBinding
7 | import com.dylanc.arouter.startActivityByRouter
8 | import com.dylanc.viewbinding.binding
9 |
10 | class TestActivity : AppCompatActivity() {
11 |
12 | private val binding: ActivityMainBinding by binding()
13 |
14 | override fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | binding.btnUserInfo.setOnClickListener {
17 | startActivityByRouter(PATH_USER_INFO)
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/dylanc/arouter/sample/ui/SplashActivity.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.ui
2 |
3 | import android.os.Bundle
4 | import android.os.Handler
5 | import android.os.Looper
6 | import androidx.appcompat.app.AppCompatActivity
7 | import com.dylanc.arouter.sample.R
8 | import com.dylanc.arouter.sample.constant.PATH_MAIN
9 | import com.dylanc.arouter.startActivityByRouter
10 |
11 | class SplashActivity : AppCompatActivity() {
12 |
13 | override fun onCreate(savedInstanceState: Bundle?) {
14 | super.onCreate(savedInstanceState)
15 | setContentView(R.layout.activity_splash)
16 | Handler(Looper.getMainLooper()).postDelayed({
17 | startActivityByRouter(PATH_MAIN) {
18 | onArrival { finish() }
19 | }
20 | }, 1000)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/module-payment-impl/src/main/java/com/dylanc/arouter/sample/payment/provider/PaymentServiceProvider.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.payment.provider
2 |
3 | import android.content.Context
4 | import com.alibaba.android.arouter.facade.annotation.Route
5 | import com.dylanc.arouter.sample.payment.service.PaymentService
6 | import com.dylanc.longan.toast
7 | import com.dylanc.longan.topActivity
8 |
9 | /**
10 | * @author Dylan Cai
11 | */
12 | @Route(path = "/payment/service")
13 | class PaymentServiceProvider : PaymentService {
14 |
15 | override fun aliPay(money: Float) {
16 | topActivity.toast("Ali Pay ¥$money")
17 | }
18 |
19 | override fun wechatPay(money: Float) {
20 | topActivity.toast("Wechat Pay ¥$money")
21 | }
22 |
23 | override fun init(context: Context) {
24 |
25 | }
26 | }
--------------------------------------------------------------------------------
/sample-app/src/androidTest/java/com/dylanc/arouter/sample/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.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.dylanc.arouter.ktx.sample", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/module-payment-impl/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/sample-app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/arouter-ktx/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/module-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 |
--------------------------------------------------------------------------------
/module-payment-api/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
--------------------------------------------------------------------------------
/module-payment-impl/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
--------------------------------------------------------------------------------
/module-payment-impl/src/androidTest/java/com/dylanc/arouter/sample/payment/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.payment
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.dylanc.arouter.sample.payment", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/module-user-api/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/module-user-impl/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 |
23 |
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/module-payment-api/src/androidTest/java/com/dylanc/arouter/sample/payment/service/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.payment.service
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.dylanc.arouter.sample.payment.service.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/layout/activity_user_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/java/com/dylanc/arouter/sample/user/repository/UserRepository.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.user.repository
2 |
3 | import com.dylanc.arouter.sample.user.service.bean.User
4 | import com.dylanc.arouter.sample.user.api.UserApi
5 | import com.dylanc.mmkv.MMKVOwner
6 | import com.dylanc.mmkv.mmkvParcelable
7 | import com.dylanc.retrofit.apiServices
8 | import kotlinx.coroutines.flow.flow
9 |
10 | /**
11 | * @author Dylan Cai
12 | */
13 | object UserRepository : MMKVOwner {
14 | private val api: UserApi by apiServices()
15 | var user by mmkvParcelable()
16 |
17 | fun login(username: String, password: String) = flow {
18 | api.login(username, password).data.let {
19 | user = it
20 | emit(it)
21 | }
22 | }
23 |
24 | fun logout() {
25 | if (kv.containsKey(this::user.name)) {
26 | kv.removeValueForKey(this::user.name)
27 | }
28 | }
29 |
30 | fun isLogin() = user != null
31 | }
--------------------------------------------------------------------------------
/arouter-ktx/src/main/java/com/dylanc/arouter/ARouterInitializer.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("unused")
2 |
3 | package com.dylanc.arouter
4 |
5 | import android.app.Application
6 | import android.content.Context
7 | import android.content.pm.ApplicationInfo
8 | import androidx.startup.Initializer
9 | import com.alibaba.android.arouter.launcher.ARouter
10 |
11 | /**
12 | * @author Dylan Cai
13 | */
14 | internal lateinit var application: Application
15 |
16 | internal class ARouterInitializer : Initializer {
17 |
18 | override fun create(context: Context) {
19 | application = context as Application
20 | val applicationInfo = context.packageManager.getApplicationInfo(context.packageName, 0)
21 | val isDebug = applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0
22 | if (isDebug) {
23 | ARouter.openLog()
24 | ARouter.openDebug()
25 | }
26 | ARouter.init(context)
27 | }
28 |
29 | override fun dependencies() = emptyList>>()
30 | }
--------------------------------------------------------------------------------
/module-user-impl/src/main/java/com/dylanc/arouter/sample/user/provider/UserServiceProvider.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.user.provider
2 |
3 | import android.app.Activity
4 | import android.content.Context
5 | import com.alibaba.android.arouter.facade.annotation.Route
6 | import com.dylanc.arouter.sample.user.service.GROUP_USER
7 | import com.dylanc.arouter.sample.user.service.UserService
8 | import com.dylanc.arouter.sample.user.repository.UserRepository
9 |
10 | /**
11 | * @author Dylan Cai
12 | * @since 2020/5/24
13 | */
14 | @Route(path = "$GROUP_USER/service")
15 | class UserServiceProvider : UserService {
16 |
17 | override fun login(username: String, password: String) =
18 | UserRepository.login(username, password)
19 |
20 | override fun logout(activity: Activity) {
21 | UserRepository.logout()
22 | }
23 |
24 | override fun isLogin(): Boolean =
25 | UserRepository.isLogin()
26 |
27 | override val username: String?
28 | get() = UserRepository.user?.name
29 |
30 | override fun init(context: Context) {}
31 | }
--------------------------------------------------------------------------------
/module-payment-impl/src/main/java/com/dylanc/arouter/sample/payment/ui/PayActivity.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.payment.ui
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 | import com.alibaba.android.arouter.facade.annotation.Route
6 | import com.dylanc.arouter.routerServices
7 | import com.dylanc.arouter.sample.payment.databinding.ActivityPayBinding
8 | import com.dylanc.arouter.sample.payment.service.PATH_PAYMENT
9 | import com.dylanc.arouter.sample.payment.service.PaymentService
10 | import com.dylanc.viewbinding.binding
11 |
12 | @Route(path = PATH_PAYMENT)
13 | class PayActivity : AppCompatActivity() {
14 |
15 | private val binding: ActivityPayBinding by binding()
16 | private val paymentService: PaymentService? by routerServices()
17 |
18 | override fun onCreate(savedInstanceState: Bundle?) {
19 | super.onCreate(savedInstanceState)
20 | with(binding) {
21 | btnAliPay.setOnClickListener {
22 | paymentService?.aliPay(100f)
23 | }
24 | btnWechatPay.setOnClickListener {
25 | paymentService?.wechatPay(200f)
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/module-payment-api/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-parcelize'
4 |
5 | android {
6 | compileSdkVersion rootProject.compile_sdk_version
7 |
8 | defaultConfig {
9 | minSdkVersion rootProject.min_sdk_version
10 | targetSdkVersion rootProject.target_sdk_version
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles 'consumer-rules.pro'
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_1_8
27 | targetCompatibility JavaVersion.VERSION_1_8
28 | }
29 |
30 | kotlinOptions {
31 | jvmTarget = '1.8'
32 | }
33 | }
34 |
35 | dependencies {
36 | implementation fileTree(dir: 'libs', include: ['*.jar'])
37 | api project(path: ':module-base')
38 | api project(path: ':arouter-ktx')
39 | }
40 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/java/com/dylanc/arouter/sample/user/ui/login/LoginActivity.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.user.ui.login
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 | import com.alibaba.android.arouter.facade.annotation.Route
6 | import com.dylanc.arouter.loginSuccess
7 | import com.dylanc.arouter.sample.user.service.PATH_LOGIN
8 | import com.dylanc.arouter.sample.user.databinding.ActivityLoginBinding
9 | import com.dylanc.longan.doOnClick
10 | import com.dylanc.longan.toast
11 | import com.dylanc.retrofit.coroutines.requestViewModels
12 | import com.dylanc.viewbinding.binding
13 |
14 | @Route(path = PATH_LOGIN)
15 | class LoginActivity : AppCompatActivity() {
16 |
17 | private val binding: ActivityLoginBinding by binding()
18 | private val viewModel: LoginViewModel by requestViewModels()
19 |
20 | override fun onCreate(savedInstanceState: Bundle?) {
21 | super.onCreate(savedInstanceState)
22 | binding.btnLogin.doOnClick {
23 | val username = binding.etUsername.text.toString()
24 | val password = binding.etPassword.text.toString()
25 | viewModel.login(username, password)
26 | .observe(this) {
27 | toast("login success")
28 | loginSuccess()
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/module-user-impl/src/main/java/com/dylanc/arouter/sample/user/ui/userinfo/UserInfoActivity.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.user.ui.userinfo
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 | import com.alibaba.android.arouter.facade.annotation.Route
6 | import com.dylanc.arouter.routerServices
7 | import com.dylanc.arouter.sample.user.databinding.ActivityUserInfoBinding
8 | import com.dylanc.arouter.sample.user.service.PATH_USER_INFO
9 | import com.dylanc.arouter.sample.user.service.UserService
10 | import com.dylanc.arouter.startActivityByRouter
11 | import com.dylanc.longan.activity
12 | import com.dylanc.longan.finishAllActivities
13 | import com.dylanc.viewbinding.binding
14 |
15 | @Route(path = PATH_USER_INFO)
16 | class UserInfoActivity : AppCompatActivity() {
17 |
18 | private val binding: ActivityUserInfoBinding by binding()
19 | private val userService: UserService? by routerServices()
20 |
21 | override fun onCreate(savedInstanceState: Bundle?) {
22 | super.onCreate(savedInstanceState)
23 | binding.btnLogout.setOnClickListener {
24 | userService?.logout(activity)
25 | startActivityByRouter("/app/main") {
26 | onArrival {
27 | finishAllActivities()
28 | }
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/sample-app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
23 | -keep class com.dylanc.retrofit.helper.*{*;}
24 | -keep public class com.alibaba.android.arouter.routes.**{*;}
25 | -keep public class com.alibaba.android.arouter.facade.**{*;}
26 | -keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
27 | # 如果使用了 byType 的方式获取 Service,需添加下面规则,保护接口
28 | -keep interface * implements com.alibaba.android.arouter.facade.template.IProvider
29 |
30 | -keep class com.dylanc.arouter.sample.user.** {*;}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/module-user-api/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-parcelize'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion rootProject.compile_sdk_version
8 |
9 | defaultConfig {
10 | minSdkVersion rootProject.min_sdk_version
11 | targetSdkVersion rootProject.target_sdk_version
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles 'consumer-rules.pro'
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | compileOptions {
27 | sourceCompatibility JavaVersion.VERSION_1_8
28 | targetCompatibility JavaVersion.VERSION_1_8
29 | }
30 |
31 | kotlinOptions {
32 | jvmTarget = '1.8'
33 | }
34 | }
35 |
36 | kapt {
37 | arguments {
38 | arg("AROUTER_MODULE_NAME", project.getName())
39 | }
40 | }
41 |
42 | dependencies {
43 | implementation fileTree(dir: 'libs', include: ['*.jar'])
44 | api project(path: ':module-base')
45 | api project(path: ':arouter-ktx')
46 | kapt project(path: ':arouter-compiler')
47 | }
48 |
--------------------------------------------------------------------------------
/arouter-ktx/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-parcelize'
4 | apply plugin: 'kotlin-kapt'
5 | apply plugin: 'com.github.dcendents.android-maven'
6 |
7 | group = 'com.github.DylanCaiCoding'
8 |
9 | android {
10 | compileSdkVersion rootProject.compile_sdk_version
11 |
12 | defaultConfig {
13 | minSdkVersion 16
14 | targetSdkVersion rootProject.target_sdk_version
15 | versionCode 1
16 | versionName "1.0"
17 |
18 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19 | consumerProguardFiles 'consumer-rules.pro'
20 | }
21 |
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 |
29 | compileOptions {
30 | kotlinOptions.freeCompilerArgs += ['-module-name', "arouter-ktx"]
31 | }
32 | }
33 |
34 | kapt {
35 | arguments {
36 | arg("AROUTER_MODULE_NAME", project.getName())
37 | }
38 | }
39 |
40 | dependencies {
41 | implementation fileTree(dir: 'libs', include: ['*.jar'])
42 | implementation 'androidx.fragment:fragment-ktx:1.3.6'
43 | implementation "androidx.startup:startup-runtime:1.1.0"
44 | api "com.alibaba:arouter-api:$arouter_api_version"
45 | api project(path: ':arouter-annotations')
46 | }
--------------------------------------------------------------------------------
/arouter-ktx/src/main/java/com/dylanc/arouter/SignInInterceptor.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter
2 |
3 | import android.content.Context
4 | import com.alibaba.android.arouter.facade.Postcard
5 | import com.alibaba.android.arouter.facade.annotation.Interceptor
6 | import com.alibaba.android.arouter.facade.callback.InterceptorCallback
7 | import com.alibaba.android.arouter.facade.template.IInterceptor
8 |
9 | /**
10 | * @author Dylan Cai
11 | */
12 | @Interceptor(priority = Int.MAX_VALUE)
13 | class SignInInterceptor : IInterceptor {
14 |
15 | override fun process(postcard: Postcard, callback: InterceptorCallback) {
16 | if (isInterceptPath(postcard.path)) {
17 | startActivityByRouter(SignInActivityPath!!, KEY_ROUTER_PATH to postcard.path) {
18 | onArrival { callback.onInterrupt(null) }
19 | }
20 | } else {
21 | callback.onContinue(postcard)
22 | }
23 | }
24 |
25 | override fun init(context: Context) = Unit
26 |
27 | companion object {
28 | internal var checkSignIn: (() -> Boolean)? = null
29 | internal var SignInActivityPath: String? = null
30 | internal val requireSignInPaths = arrayListOf()
31 |
32 | fun enable(onCheckSignIn: () -> Boolean) {
33 | checkSignIn = onCheckSignIn
34 | }
35 |
36 | internal fun isInterceptPath(path: String) =
37 | SignInActivityPath != null && path != SignInActivityPath &&
38 | requireSignInPaths.contains(path) && checkSignIn?.invoke() == false
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/arouter-ktx/src/main/java/com/dylanc/arouter/PathsInitializer.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("unused")
2 |
3 | package com.dylanc.arouter
4 |
5 | import android.content.Context
6 | import android.util.Log
7 | import androidx.startup.Initializer
8 | import com.alibaba.android.arouter.launcher.ARouter
9 | import com.alibaba.android.arouter.utils.Consts
10 | import com.dylanc.arouter.SignInInterceptor.Companion.SignInActivityPath
11 | import com.dylanc.arouter.SignInInterceptor.Companion.requireSignInPaths
12 |
13 | /**
14 | * @author Dylan Cai
15 | */
16 | internal class PathsInitializer : Initializer {
17 |
18 | @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
19 | override fun create(context: Context) {
20 | try {
21 | val clazz = Class.forName("${Consts.ROUTE_ROOT_PAKCAGE}.ARouter$\$LoginInfo")
22 | SignInActivityPath = clazz.getField("activityPath")[clazz.newInstance()] as? String
23 |
24 | val sharedPreferences = context.getSharedPreferences(Consts.AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE)
25 | val routerMap = HashSet(sharedPreferences.getStringSet(Consts.AROUTER_SP_KEY_MAP, HashSet()))
26 | for (className in routerMap) {
27 | if(className.startsWith("${Consts.ROUTE_ROOT_PAKCAGE}.ARouter$\$Paths$\$")){
28 | (Class.forName(className).newInstance() as? IRoutePaths)?.loadInto(requireSignInPaths)
29 | }
30 | }
31 |
32 | ARouter.logger.debug("Paths", requireSignInPaths.toString())
33 | } catch (e: NoSuchFieldException) {
34 | } catch (e: Exception) {
35 | e.printStackTrace()
36 | }
37 | }
38 |
39 | override fun dependencies() = listOf(ARouterInitializer::class.java)
40 | }
41 |
--------------------------------------------------------------------------------
/sample-app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/layout/activity_pay.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
25 |
26 |
38 |
39 |
--------------------------------------------------------------------------------
/arouter-ktx/src/main/java/com/dylanc/arouter/RequireSignInContract.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter
2 |
3 | import android.app.Activity
4 | import android.content.Context
5 | import android.content.Intent
6 | import androidx.activity.result.ActivityResultCaller
7 | import androidx.activity.result.contract.ActivityResultContract
8 | import com.alibaba.android.arouter.core.LogisticsCenter
9 | import com.alibaba.android.arouter.facade.enums.RouteType
10 | import com.alibaba.android.arouter.launcher.ARouter
11 | import com.dylanc.arouter.SignInInterceptor.Companion.SignInActivityPath
12 |
13 | fun ActivityResultCaller.requireLoginLauncher(onLoginFailure: (() -> Unit)? = null, onLoginSuccess: () -> Unit) =
14 | registerForActivityResult(RequireSignInContract()) {
15 | if (it) onLoginSuccess() else onLoginFailure?.invoke()
16 | }
17 |
18 | class RequireSignInContract : ActivityResultContract() {
19 |
20 | override fun createIntent(context: Context, input: Unit?): Intent {
21 | val postcard = ARouter.getInstance().build(SignInActivityPath!!)
22 | LogisticsCenter.completion(postcard)
23 | if (postcard.type != RouteType.ACTIVITY) {
24 | throw IllegalArgumentException("The routing class for the path of $SignInActivityPath is not an activity type.")
25 | }
26 | return Intent(context, postcard.destination)
27 | }
28 |
29 | override fun parseResult(resultCode: Int, intent: Intent?) = resultCode == Activity.RESULT_OK
30 |
31 | override fun getSynchronousResult(context: Context, input: Unit?): SynchronousResult? =
32 | when {
33 | SignInActivityPath == null -> SynchronousResult(true)
34 | SignInInterceptor.checkSignIn?.invoke() == true -> SynchronousResult(true)
35 | else -> null
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/module-base/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | android {
6 | compileSdkVersion rootProject.compile_sdk_version
7 |
8 | defaultConfig {
9 | minSdkVersion rootProject.min_sdk_version
10 | targetSdkVersion rootProject.target_sdk_version
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles 'consumer-rules.pro'
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_1_8
27 | targetCompatibility JavaVersion.VERSION_1_8
28 | }
29 |
30 | kotlinOptions {
31 | jvmTarget = '1.8'
32 | }
33 | }
34 |
35 | dependencies {
36 | implementation fileTree(dir: 'libs', include: ['*.jar'])
37 | api "androidx.core:core-ktx:$core_ktx_version"
38 | api "androidx.appcompat:appcompat:$app_compat_version"
39 | api "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
40 | api "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
41 |
42 | api 'com.github.DylanCaiCoding.ViewBindingKTX:viewbinding-ktx:1.2.4'
43 | api "com.github.DylanCaiCoding.RetrofitKTX:retrofit-ktx:$retrofit_ktx_version"
44 | kapt "com.github.DylanCaiCoding.RetrofitKTX:retrofit-compiler:$retrofit_ktx_version"
45 | api "com.github.DylanCaiCoding.RetrofitKTX:retrofit-coroutines:$retrofit_ktx_version"
46 | api 'com.github.DylanCaiCoding:Longan:1.0.0'
47 | api 'com.github.DylanCaiCoding:MMKV-KTX:1.0.0'
48 | }
--------------------------------------------------------------------------------
/sample-app/src/main/java/com/dylanc/arouter/sample/ui/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.sample.ui
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 | import com.alibaba.android.arouter.facade.annotation.Route
6 | import com.dylanc.arouter.requireLoginLauncher
7 | import com.dylanc.arouter.routerServices
8 | import com.dylanc.arouter.sample.R
9 | import com.dylanc.arouter.sample.constant.PATH_MAIN
10 | import com.dylanc.arouter.sample.databinding.ActivityMainBinding
11 | import com.dylanc.arouter.sample.payment.service.PATH_PAYMENT
12 | import com.dylanc.arouter.sample.user.service.PATH_USER_INFO
13 | import com.dylanc.arouter.sample.user.service.UserService
14 | import com.dylanc.arouter.startActivityByRouter
15 | import com.dylanc.viewbinding.binding
16 |
17 | @Route(path = PATH_MAIN)
18 | class MainActivity : AppCompatActivity() {
19 |
20 | private val binding: ActivityMainBinding by binding()
21 | private val userService: UserService? by routerServices()
22 |
23 | override fun onCreate(savedInstanceState: Bundle?) {
24 | super.onCreate(savedInstanceState)
25 | with(binding) {
26 | setSupportActionBar(toolbar)
27 | if (userService?.isLogin() == true) {
28 | tvUsername.text = userService?.username
29 | } else {
30 | tvUsername.setText(R.string.login)
31 | }
32 |
33 | tvUsername.setOnClickListener {
34 | if (tvUsername.text.toString() != getString(R.string.login)) {
35 | startActivityByRouter(PATH_USER_INFO)
36 | } else {
37 | changeUsernameLauncher.launch(Unit)
38 | }
39 | }
40 |
41 | btnPay.setOnClickListener {
42 | startActivityByRouter(PATH_PAYMENT)
43 | }
44 | }
45 | }
46 |
47 | private val changeUsernameLauncher = requireLoginLauncher {
48 | binding.tvUsername.text = userService?.username
49 | }
50 |
51 | }
--------------------------------------------------------------------------------
/sample-app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
26 |
27 |
37 |
38 |
50 |
51 |
--------------------------------------------------------------------------------
/module-user-impl/src/userUI2/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
27 |
28 |
41 |
42 |
52 |
53 |
--------------------------------------------------------------------------------
/arouter-ktx/src/main/java/com/dylanc/arouter/ARouter.kt:
--------------------------------------------------------------------------------
1 | @file:JvmName("ARouterUtils")
2 | @file:Suppress("unused")
3 |
4 | package com.dylanc.arouter
5 |
6 | import android.app.Activity
7 | import android.content.Context
8 | import android.content.Intent
9 | import androidx.activity.result.ActivityResultLauncher
10 | import androidx.core.os.bundleOf
11 | import androidx.fragment.app.Fragment
12 | import com.alibaba.android.arouter.facade.Postcard
13 | import com.alibaba.android.arouter.facade.template.IProvider
14 | import com.alibaba.android.arouter.launcher.ARouter
15 |
16 | internal const val KEY_ROUTER_PATH = "router_path"
17 |
18 | @JvmName("startActivity")
19 | fun startActivityByRouter(path: String, vararg pairs: Pair, block: (PostcardBuilder.() -> Unit)? = null) =
20 | application.startActivityByRouter(path, *pairs, block = block)
21 |
22 | @JvmName("startActivity")
23 | fun Fragment.startActivityByRouter(path: String, vararg pairs: Pair, block: (PostcardBuilder.() -> Unit)? = null) =
24 | requireActivity().startActivityByRouter(path, *pairs, block = block)
25 |
26 | @JvmName("startActivity")
27 | fun Context.startActivityByRouter(path: String, vararg pairs: Pair, block: (PostcardBuilder.() -> Unit)? = null) {
28 | ARouter.getInstance().build(path).with(bundleOf(*pairs)).navigation(this, block)
29 | }
30 |
31 | inline fun routerServices() =
32 | lazy { ARouter.getInstance().navigation(T::class.java) }
33 |
34 | inline fun routerServices(path: String) =
35 | lazy { ARouter.getInstance().build(path).navigation() as? T }
36 |
37 | fun createFragmentByRouter(path: String, block: Postcard.() -> Unit = {}) =
38 | ARouter.getInstance().build(path).apply(block).navigation() as? Fragment
39 |
40 | fun ActivityResultLauncher.launchByRouter(path: String, vararg pairs: Pair, block: (PostcardBuilder.() -> Unit)? = null) {
41 | ARouter.getInstance().build(path).with(bundleOf(*pairs)).navigation(this, block = block)
42 | }
43 |
44 | fun Activity.loginSuccess() {
45 | val path = intent.getStringExtra(KEY_ROUTER_PATH)
46 | if (path != null) {
47 | startActivityByRouter(path) {
48 | onArrival { finish() }
49 | }
50 | } else {
51 | setResult(Activity.RESULT_OK)
52 | finish()
53 | }
54 | }
--------------------------------------------------------------------------------
/module-payment-impl/build.gradle:
--------------------------------------------------------------------------------
1 | if (debugPayComponent) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 | apply plugin: 'kotlin-android'
7 | apply plugin: 'kotlin-kapt'
8 |
9 | android {
10 | compileSdkVersion rootProject.compile_sdk_version
11 | resourcePrefix "payment_"
12 |
13 | defaultConfig {
14 | if (debugPayComponent) {
15 | applicationId "com.dylanc.arouter.sample.payment"
16 | }
17 | minSdkVersion rootProject.min_sdk_version
18 | targetSdkVersion rootProject.target_sdk_version
19 | versionCode 1
20 | versionName "1.0"
21 |
22 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
23 | }
24 |
25 | sourceSets {
26 | main {
27 | if (debugPayComponent) {
28 | manifest.srcFile 'src/main/AndroidManifest.xml'
29 | } else {
30 | manifest.srcFile 'src/main/manifest/AndroidManifest.xml'
31 | }
32 | }
33 | }
34 |
35 | buildTypes {
36 | release {
37 | minifyEnabled false
38 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
39 | }
40 | }
41 |
42 | compileOptions {
43 | sourceCompatibility JavaVersion.VERSION_1_8
44 | targetCompatibility JavaVersion.VERSION_1_8
45 | }
46 |
47 | kotlinOptions {
48 | jvmTarget = '1.8'
49 | }
50 |
51 | buildFeatures {
52 | viewBinding true
53 | }
54 |
55 | flavorDimensions "paymentUI"
56 | productFlavors {
57 | paymentUI {
58 | dimension "paymentUI"
59 | }
60 | paymentUI2 {
61 | dimension "paymentUI"
62 | }
63 | }
64 | }
65 |
66 | kapt {
67 | arguments {
68 | arg("AROUTER_MODULE_NAME", project.getName())
69 | }
70 | }
71 |
72 | dependencies {
73 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
74 | kapt project(path: ':arouter-compiler')
75 | implementation project(path: ':module-payment-api')
76 |
77 | testImplementation "junit:junit:$junit_version"
78 | androidTestImplementation "androidx.test:runner:$runner_version"
79 | androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
80 | }
--------------------------------------------------------------------------------
/module-user-impl/build.gradle:
--------------------------------------------------------------------------------
1 | if (debugUserComponent) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 | apply plugin: 'kotlin-android'
7 | apply plugin: 'kotlin-kapt'
8 | apply plugin: 'kotlinx-serialization'
9 |
10 | android {
11 | compileSdkVersion rootProject.compile_sdk_version
12 | buildToolsVersion rootProject.build_tools_version
13 | resourcePrefix "user_"
14 |
15 | defaultConfig {
16 | if (debugUserComponent) {
17 | applicationId "com.dylanc.arouter.sample.user"
18 | }
19 | minSdkVersion rootProject.min_sdk_version
20 | targetSdkVersion rootProject.target_sdk_version
21 | versionCode 1
22 | versionName "1.0"
23 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
24 | }
25 |
26 | sourceSets {
27 | main {
28 | if (debugUserComponent) {
29 | manifest.srcFile 'src/main/AndroidManifest.xml'
30 | } else {
31 | manifest.srcFile 'src/main/manifest/AndroidManifest.xml'
32 | }
33 | }
34 | }
35 |
36 | buildTypes {
37 | release {
38 | minifyEnabled true
39 | consumerProguardFiles 'proguard-rules.pro'
40 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
41 | }
42 | }
43 |
44 | compileOptions {
45 | sourceCompatibility JavaVersion.VERSION_1_8
46 | targetCompatibility JavaVersion.VERSION_1_8
47 | }
48 |
49 | kotlinOptions {
50 | jvmTarget = '1.8'
51 | }
52 |
53 | buildFeatures {
54 | viewBinding true
55 | }
56 |
57 | flavorDimensions "userUI"
58 | productFlavors {
59 | userUI {
60 | dimension "userUI"
61 | }
62 | userUI2 {
63 | dimension "userUI"
64 | }
65 | }
66 | }
67 |
68 | kapt {
69 | arguments {
70 | arg("AROUTER_MODULE_NAME", project.getName())
71 | }
72 | }
73 |
74 | dependencies {
75 | implementation fileTree(dir: 'libs', include: ['*.jar'])
76 | implementation project(path: ':module-user-api')
77 | kapt project(path: ':arouter-compiler')
78 |
79 | testImplementation "junit:junit:$junit_version"
80 | androidTestImplementation "androidx.test:runner:$runner_version"
81 | androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
82 | }
--------------------------------------------------------------------------------
/sample-app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | android {
6 | compileSdkVersion rootProject.compile_sdk_version
7 |
8 | defaultConfig {
9 | applicationId "com.dylanc.arouter.sample"
10 | minSdkVersion rootProject.min_sdk_version
11 | targetSdkVersion rootProject.target_sdk_version
12 | versionCode 2
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled true
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_1_8
27 | targetCompatibility JavaVersion.VERSION_1_8
28 | }
29 |
30 | kotlinOptions {
31 | jvmTarget = '1.8'
32 | }
33 |
34 | buildFeatures {
35 | viewBinding true
36 | }
37 |
38 | flavorDimensions "userUI", "paymentUI"
39 | productFlavors {
40 | paymentUI {
41 | dimension "paymentUI"
42 | }
43 | userUI2 {
44 | dimension "userUI"
45 | }
46 | }
47 | }
48 |
49 | kapt {
50 | arguments {
51 | arg("AROUTER_MODULE_NAME", project.getName())
52 | }
53 | }
54 |
55 | dependencies {
56 | implementation fileTree(dir: 'libs', include: ['*.jar'])
57 | implementation project(path: ':module-user-api')
58 | if (!debugUserComponent) {
59 | runtimeOnly project(path: ':module-user-impl')
60 | }
61 | implementation project(path: ':module-payment-api')
62 | if (!debugPayComponent) {
63 | runtimeOnly project(path: ':module-payment-impl')
64 | }
65 | kapt project(path: ':arouter-compiler')
66 | kapt "com.github.DylanCaiCoding.RetrofitKTX:retrofit-compiler:$retrofit_ktx_version"
67 |
68 | testImplementation "junit:junit:$junit_version"
69 | androidTestImplementation "androidx.test:runner:$runner_version"
70 | androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
71 | debugImplementation "com.squareup.leakcanary:leakcanary-android:$leak_canary_version"
72 | testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary_version"
73 | releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary_version"
74 | }
--------------------------------------------------------------------------------
/arouter-compiler/src/main/java/com/dylanc/arouter/compiler/LoginInfoProcessor.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.compiler
2 |
3 | import com.dylanc.arouter.annotations.LoginActivityPath
4 | import com.squareup.javapoet.*
5 | import java.io.IOException
6 | import javax.annotation.processing.AbstractProcessor
7 | import javax.annotation.processing.Filer
8 | import javax.annotation.processing.ProcessingEnvironment
9 | import javax.annotation.processing.RoundEnvironment
10 | import javax.lang.model.SourceVersion
11 | import javax.lang.model.element.Modifier
12 | import javax.lang.model.element.TypeElement
13 | import javax.lang.model.element.VariableElement
14 |
15 | /**
16 | * @author Dylan Cai
17 | */
18 | class LoginInfoProcessor : AbstractProcessor() {
19 | private lateinit var filer: Filer
20 |
21 | override fun init(processingEnv: ProcessingEnvironment) {
22 | super.init(processingEnv)
23 | filer = processingEnv.filer
24 | }
25 |
26 | override fun process(annotations: MutableSet, roundEnv: RoundEnvironment): Boolean {
27 | val loginActivityPathElements = roundEnv.getElementsAnnotatedWith(LoginActivityPath::class.java).map { it as VariableElement }
28 | val typeSpec = TypeSpec.classBuilder(ClassName.get(PACKAGE_NAME, "$PROJECT${SEPARATOR}LoginInfo"))
29 | .addModifiers(Modifier.PUBLIC)
30 | .addField(FieldSpec.builder(String::class.java, "activityPath", Modifier.PUBLIC).build())
31 | .addMethod(MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC)
32 | .apply {
33 | if (loginActivityPathElements.isNotEmpty()) {
34 | if (loginActivityPathElements.size > 1) {
35 | throw IllegalStateException("There must be only one annotation of @LoginActivityPath.")
36 | }
37 | val element = loginActivityPathElements.first()
38 | addStatement("activityPath = ${element.fullClassName}.${element.simpleName}")
39 | }
40 | }
41 | .build())
42 | .build()
43 |
44 | try {
45 | JavaFile.builder(PACKAGE_NAME, typeSpec).build().writeTo(filer)
46 | } catch (e: IOException) {
47 | e.printStackTrace()
48 | }
49 | return false
50 | }
51 |
52 | override fun getSupportedAnnotationTypes() = setOf(LoginActivityPath::class.java.canonicalName)
53 |
54 | override fun getSupportedSourceVersion() = SourceVersion.RELEASE_8
55 |
56 | private val VariableElement.fullClassName: String
57 | get() = ClassName.get(enclosingElement.asType()).toString()
58 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
26 |
27 |
40 |
41 |
52 |
53 |
62 |
63 |
--------------------------------------------------------------------------------
/arouter-compiler/src/main/java/com/dylanc/arouter/compiler/PathsProcessor.kt:
--------------------------------------------------------------------------------
1 | package com.dylanc.arouter.compiler
2 |
3 | import com.dylanc.arouter.annotations.RequireLoginPath
4 | import com.squareup.javapoet.*
5 | import java.io.IOException
6 | import java.lang.RuntimeException
7 | import javax.annotation.processing.AbstractProcessor
8 | import javax.annotation.processing.Filer
9 | import javax.annotation.processing.ProcessingEnvironment
10 | import javax.annotation.processing.RoundEnvironment
11 | import javax.lang.model.SourceVersion
12 | import javax.lang.model.element.Modifier
13 | import javax.lang.model.element.TypeElement
14 | import javax.lang.model.element.VariableElement
15 | import javax.lang.model.util.Elements
16 |
17 | /**
18 | * @author Dylan Cai
19 | */
20 | class PathsProcessor : AbstractProcessor() {
21 | private lateinit var filer: Filer
22 | private lateinit var elementUtils: Elements
23 | private var moduleName: String? = null
24 |
25 | override fun init(processingEnv: ProcessingEnvironment) {
26 | super.init(processingEnv)
27 | filer = processingEnv.filer
28 | elementUtils = processingEnv.elementUtils
29 |
30 | val options = processingEnv.options
31 | if (options.isNotEmpty()) {
32 | moduleName = options[KEY_MODULE_NAME]
33 | }
34 | if (!moduleName.isNullOrEmpty()) {
35 | moduleName = moduleName!!.replace("[^0-9a-zA-Z_]+".toRegex(), "")
36 | print("The user has configuration the module name, it was [$moduleName]")
37 | } else {
38 | throw RuntimeException("ARouter::Compiler >>> No module name, for more information, look at gradle log.")
39 | }
40 | }
41 |
42 | override fun process(annotations: MutableSet, roundEnv: RoundEnvironment): Boolean {
43 | val checkLoginPathElements = roundEnv.getElementsAnnotatedWith(RequireLoginPath::class.java).map { it as VariableElement }
44 | val arrayListType = ParameterizedTypeName.get(ClassName.get(ArrayList::class.java), ClassName.get(String::class.java))
45 | val paramSpec = ParameterSpec.builder(arrayListType, "paths").build()
46 | val typeIRoutePaths = elementUtils.getTypeElement(IROUTE_PATHS)
47 |
48 | val loadIntoMethodBuilder = MethodSpec.methodBuilder("loadInto")
49 | .addAnnotation(Override::class.java)
50 | .addModifiers(Modifier.PUBLIC)
51 | .addParameter(paramSpec)
52 |
53 | checkLoginPathElements.forEach { element ->
54 | loadIntoMethodBuilder.addStatement("paths.add(${element.fullClassName}.${element.simpleName})")
55 | }
56 |
57 | val typeSpec = TypeSpec.classBuilder(ClassName.get(PACKAGE_NAME, "$PROJECT${SEPARATOR}Paths$SEPARATOR$moduleName"))
58 | .addSuperinterface(ClassName.get(typeIRoutePaths))
59 | .addModifiers(Modifier.PUBLIC)
60 | .addMethod(loadIntoMethodBuilder.build())
61 | .build()
62 |
63 | try {
64 | JavaFile.builder(PACKAGE_NAME, typeSpec).build().writeTo(filer)
65 | } catch (e: IOException) {
66 | e.printStackTrace()
67 | }
68 | return false
69 | }
70 |
71 | override fun getSupportedAnnotationTypes() = setOf(RequireLoginPath::class.java.canonicalName)
72 |
73 | override fun getSupportedOptions() = setOf(KEY_MODULE_NAME)
74 |
75 | override fun getSupportedSourceVersion() = SourceVersion.RELEASE_8
76 |
77 | private val VariableElement.fullClassName: String
78 | get() = ClassName.get(enclosingElement.asType()).toString()
79 | }
--------------------------------------------------------------------------------
/sample-app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/module-payment-impl/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/module-user-impl/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/arouter-ktx/src/main/java/com/dylanc/arouter/Postcard.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("unused")
2 |
3 | package com.dylanc.arouter
4 |
5 | import android.app.Activity
6 | import android.content.Context
7 | import android.content.Intent
8 | import android.os.Bundle
9 | import android.os.Handler
10 | import android.os.Looper
11 | import android.widget.Toast
12 | import androidx.activity.result.ActivityResultLauncher
13 | import androidx.fragment.app.Fragment
14 | import com.alibaba.android.arouter.core.LogisticsCenter
15 | import com.alibaba.android.arouter.exception.NoRouteFoundException
16 | import com.alibaba.android.arouter.facade.Postcard
17 | import com.alibaba.android.arouter.facade.callback.InterceptorCallback
18 | import com.alibaba.android.arouter.facade.callback.NavCallback
19 | import com.alibaba.android.arouter.facade.callback.NavigationCallback
20 | import com.alibaba.android.arouter.facade.enums.RouteType
21 | import com.alibaba.android.arouter.facade.service.DegradeService
22 | import com.alibaba.android.arouter.facade.service.InterceptorService
23 | import com.alibaba.android.arouter.facade.service.PretreatmentService
24 | import com.alibaba.android.arouter.launcher.ARouter
25 | import com.alibaba.android.arouter.utils.Consts
26 | import com.alibaba.android.arouter.utils.TextUtils
27 |
28 | fun Postcard.navigation(context: Context, block: (PostcardBuilder.() -> Unit)? = null): Any? =
29 | navigation(context, PostcardBuilder(this).apply { block?.invoke(this) }.callback)
30 |
31 | fun Postcard.navigation(launcher: ActivityResultLauncher, context: Context = application, block: (PostcardBuilder.() -> Unit)? = null): Any? =
32 | navigation(launcher, context, PostcardBuilder(this).apply { block?.invoke(this) }.callback)
33 |
34 | fun Postcard.navigation(launcher: ActivityResultLauncher, context: Context = application, callback: NavigationCallback? = null): Any? {
35 | val pretreatmentService = ARouter.getInstance().navigation(PretreatmentService::class.java)
36 | if (null != pretreatmentService && !pretreatmentService.onPretreatment(context, this)) {
37 | return null
38 | }
39 |
40 | this.context = context
41 |
42 | try {
43 | LogisticsCenter.completion(this)
44 | } catch (ex: NoRouteFoundException) {
45 | ARouter.logger.warning(Consts.TAG, ex.message)
46 |
47 | if (ARouter.debuggable()) {
48 | runInMainThread {
49 | val text = "There's no route matched!\nPath = [$path]\nGroup = [$group]"
50 | Toast.makeText(application, text, Toast.LENGTH_LONG).show()
51 | }
52 | }
53 |
54 | if (null != callback) {
55 | callback.onLost(this)
56 | } else {
57 | ARouter.getInstance().navigation(DegradeService::class.java)?.onLost(context, this)
58 | }
59 | return null
60 | }
61 |
62 | callback?.onFound(this)
63 |
64 | val interceptorService = ARouter.getInstance().build("/arouter/service/interceptor").navigation() as InterceptorService
65 | if (!isGreenChannel) {
66 | interceptorService.doInterceptions(this, object : InterceptorCallback {
67 |
68 | override fun onContinue(postcard: Postcard) {
69 | postcard._navigation(launcher, callback)
70 | }
71 |
72 | override fun onInterrupt(exception: Throwable) {
73 | callback?.onInterrupt(this@navigation)
74 | ARouter.logger.info(Consts.TAG, "Navigation failed, termination by interceptor : " + exception.message)
75 | }
76 | })
77 | } else {
78 | return _navigation(launcher, callback)
79 | }
80 | return null
81 | }
82 |
83 | @Suppress("FunctionName", "DEPRECATION")
84 | private fun Postcard._navigation(launcher: ActivityResultLauncher, callback: NavigationCallback?): Any? {
85 | val currentContext = context
86 |
87 | when (type) {
88 | RouteType.ACTIVITY -> {
89 | val intent = Intent(currentContext, destination).putExtras(extras)
90 |
91 | val flags = flags
92 | if (0 != flags) {
93 | intent.flags = flags
94 | }
95 |
96 | val action = action
97 | if (!TextUtils.isEmpty(action)) {
98 | intent.action = action
99 | }
100 |
101 | runInMainThread {
102 | launcher.launch(intent)
103 |
104 | if (-1 != enterAnim && -1 != exitAnim && currentContext is Activity) { // Old version.
105 | currentContext.overridePendingTransition(enterAnim, exitAnim)
106 | }
107 |
108 | callback?.onArrival(this)
109 | }
110 | }
111 | RouteType.PROVIDER -> return provider
112 | RouteType.BOARDCAST, RouteType.CONTENT_PROVIDER, RouteType.FRAGMENT -> {
113 | val fragmentMeta = destination
114 | try {
115 | val instance = fragmentMeta.getConstructor().newInstance()
116 | if (instance is android.app.Fragment) {
117 | instance.arguments = extras
118 | } else if (instance is Fragment) {
119 | instance.arguments = extras
120 | }
121 | return instance
122 | } catch (ex: java.lang.Exception) {
123 | ARouter.logger.error(Consts.TAG, "Fetch fragment instance error, " + TextUtils.formatStackTrace(ex.stackTrace))
124 | }
125 | return null
126 | }
127 | RouteType.METHOD, RouteType.SERVICE -> return null
128 | else -> return null
129 | }
130 | return null
131 | }
132 |
133 | private val handler by lazy { Handler(Looper.getMainLooper()) }
134 |
135 | private fun runInMainThread(runnable: Runnable) {
136 | if (Looper.getMainLooper().thread !== Thread.currentThread()) {
137 | handler.post(runnable)
138 | } else {
139 | runnable.run()
140 | }
141 | }
142 |
143 | class PostcardBuilder(private val postcard: Postcard) {
144 | private var onArrival: ((Postcard) -> Unit)? = null
145 | private var onInterrupt: ((Postcard) -> Unit)? = null
146 | private var onFound: ((Postcard) -> Unit)? = null
147 | private var onLost: ((Postcard) -> Unit)? = null
148 |
149 | fun bundle(bundle: Bundle) {
150 | postcard.with(bundle)
151 | }
152 |
153 | fun flags(flag: Int) {
154 | postcard.withFlags(flag)
155 | }
156 |
157 | fun transition(enterAnim: Int, exitAnim: Int) {
158 | postcard.withTransition(enterAnim, exitAnim)
159 | }
160 |
161 | fun onArrival(block: (Postcard) -> Unit) {
162 | onArrival = block
163 | }
164 |
165 | fun onInterrupt(block: (Postcard) -> Unit) {
166 | onInterrupt = block
167 | }
168 |
169 | fun onFound(block: (Postcard) -> Unit) {
170 | onFound = block
171 | }
172 |
173 | fun onLost(block: (Postcard) -> Unit) {
174 | onLost = block
175 | }
176 |
177 | internal val callback: NavigationCallback?
178 | get() = if (onArrival != null || onInterrupt != null || onFound != null || onLost != null) {
179 | object : NavCallback() {
180 | override fun onArrival(postcard: Postcard) {
181 | onArrival?.invoke(postcard)
182 | }
183 |
184 | override fun onFound(postcard: Postcard) {
185 | onFound?.invoke(postcard)
186 | }
187 |
188 | override fun onLost(postcard: Postcard) {
189 | onLost?.invoke(postcard)
190 | }
191 |
192 | override fun onInterrupt(postcard: Postcard) {
193 | if (SignInInterceptor.isInterceptPath(postcard.path)) {
194 | onArrival?.invoke(postcard)
195 | } else {
196 | onInterrupt?.invoke(postcard)
197 | }
198 | }
199 | }
200 | } else {
201 | null
202 | }
203 |
204 | companion object {
205 | internal fun Postcard.builder() = PostcardBuilder(this)
206 | }
207 | }
208 |
--------------------------------------------------------------------------------