SimpleRouter
Android组件化路由库,支持模块间通信,适用于中小型项目
最新版本
模块 | srouter-annotation | srouter-compiler | srouter-api |
---|---|---|---|
版本 |
Demo展示
Demo apk下载
接入方式
-
在build.gradle文件中添加依赖和配置
参数示意:
> SIMPLE_ROUTER_KEY -> 配置生成的路由文件加密秘钥,长度为16个字 > OPEN_AES -> 是否开启加密 > SROUTER_ANNOTATION -> annotation版本号(查看上面最新版本) > SROUTER_API -> api版本号(查看上面最新版本) > SROUTER_COMPILER -> compiler版本号(查看上面最新版本)
代码配置:
plugins { id 'kotlin-kapt' } android { defaultConfig { javaCompileOptions { annotationProcessorOptions { arguments = [ SIMPLE_ROUTER_KEY: project.ext.simpleRouterKey, OPEN_AES : project.ext.openAes ] } } } } dependencies { implementation "com.github.jeff-liu14:srouter-annotation:$SROUTER_ANNOTATION" implementation "com.github.jeff-liu14:srouter-api:$SROUTER_API" kapt "com.github.jeff-liu14:srouter-compiler:$SROUTER_COMPILER" }
-
在需要的Activity/Fragment中添加注解
#activity @Route(path = "/app/home") class MainActivity : AppCompatActivity() { } # fragment @Route(path = "/app/demo/product/fragment") class ProductFragment : Fragment() { }
-
初始化SDK
SimpleRouter.init(this) SimpleRouter.scanRoute(BuildConfig.SIMPLE_ROUTER_KEY, BuildConfig.OPEN_AES)
-
路由跳转操作
//无参跳转 SimpleRouter.getInstance() .build(