原名ActivityRouter,Android 结构化路由框架
相对于基于字符串的路由框架(ARouter)而言,结构化路由框架具备面向对象、中心化的特点,如果我们需要跳转到一个Activity,ARouter 得先去查找这个页面的路径是什么、接收什么参数、参数的格式和用途是什么。而结构化路由框架则会自动生成一个中心类,把所有的页面调用都集成进去,有什么页面都清晰明了,每一个Activity都会生成一个Builder类,有什么参数,参数的作用都会注释清晰,不用担心会传错参数。解决Activity参数调整,字符串路由框架容易出现严重的调用异常问题。
自动生成构造器
,避免拼接参数容易写错问题。GRouter已经在拥有434个Activity、28个Module的千万用户级别APP稳定使用。GRouter 会一直致力于组件化解决方案,如果你有更好的建议,可以提Issues或私聊联系我。
Activity 页面跳转
// 不推荐
GRouter.getInstance().startActivity(context, "grouter://activity/user?uid=1")
// 不推荐
GRouter.getInstance().activityBuilder("user").put("uid",1).start(context)
// 推荐
GActivityCenter.UserActivity().uid(123).start(context)
下沉接口式 - 组件间服务调用
// 不推荐
val userService = GRouter.getInstance().getComponent("userService") as UserService
// 不推荐
val userService = GRouter.getInstance().getComponent("userService",UserService::class.java)
// 推荐
val userService = GComponentCenter.UserServiceImpl()
非下沉式 - 组件间单任务调用
// 不推荐
val response = GRouter.getInstance().taskBuilder("grouter://task/getUser?uid=1").execute()
// 不推荐
val response = GRouter.getInstance().taskBuilder("getUser").put("uid",1).execute()
// 推荐
val response = GTaskCenter.GetUserTask().uid(1).execute()
// 获取返回值
val user = response.value(User::class.java)
非下沉式 - 反射代理服务
val accountServiceDelegate = GDelegateCenter.AccountService(context)
Copyright 2019 taoweiji
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.