• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Router: 灵活的组件化路由框架.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

Router

开源软件地址:

https://gitee.com/chenenyu/Router

开源软件介绍:

Build Status license PullRequest

Router

中文wiki. 方便的话给个star!❤️

screenshot

Getting started

Branch 1.5 see here

  • Add router gradle plugin to your project-level build.gradle, as shown below.
buildscript {    repositories {        google()        jcenter()    }    dependencies {        classpath 'com.android.tools.build:gradle:+'        classpath "com.chenenyu.router:gradle-plugin:版本号"    }}

latest router-gradle-plugin version: Download

  • Apply router plugin in your module-level 'build.gradle'.
apply plugin: 'com.android.application' // apply plugin: 'com.android.library'apply plugin: 'com.chenenyu.router'

注意: 在rootProject的build.gradle文件中, 可以指定插件引用的library版本.

ext {    routerVersion = 'x.y.z'    compilerVersion = 'x.y.z'}

latest router version: Download

latest compiler version: compiler

基本用法

  • 添加拦截器(可选)
@Interceptor("SampleInterceptor")public class SampleInterceptor implements RouteInterceptor {    @Override    public RouteResponse intercept(Chain chain) {        // do something        return chain.process();    }}
  • 添加注解
// 给Activity添加注解,指定了路径和拦截器(可选)@Route(value = "test", interceptors = "SampleInterceptor")public class TestActivity extends AppCompatActivity {    @InjectParam(key="foo") // 参数映射    String foo;       @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        Router.injectParams(this);  // 自动从bundle中获取并注入参数        ...    }}// 给Fragment添加注解@Route("test")public class TestFragment extends Fragment {    ...}
  • 跳转
// 简单跳转Router.build("test").go(this);// startActivityForResultRouter.build("test").requestCode(0).go(this);// 携带bundle参数Router.build("test").with("key", Object).go(this);// 添加回调Router.build("test").go(this, new RouteCallback() {    @Override    public void callback(RouteStatus status, Uri uri, String message) {        // do something    }});// 获取路由对应的intentRouter.build("test").getIntent();// 获取注解的FragmentRouter.build("test").getFragment();

进阶用法

建议浏览 wiki.

谁在使用Router

讨论

QQ group: 271849001

Donate ❤️

Click here.

License

Apache 2.0


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap