com.chenenyu.router:annotation

Awesome android router library.

License

License

GroupId

GroupId

com.chenenyu.router
ArtifactId

ArtifactId

annotation
Last Version

Last Version

0.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

com.chenenyu.router:annotation
Awesome android router library.
Project URL

Project URL

https://github.com/chenenyu/Router
Source Code Management

Source Code Management

https://github.com/chenenyu/Router

Download annotation

How to add to project

<!-- https://jarcasting.com/artifacts/com.chenenyu.router/annotation/ -->
<dependency>
    <groupId>com.chenenyu.router</groupId>
    <artifactId>annotation</artifactId>
    <version>0.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.chenenyu.router/annotation/
implementation 'com.chenenyu.router:annotation:0.5.0'
// https://jarcasting.com/artifacts/com.chenenyu.router/annotation/
implementation ("com.chenenyu.router:annotation:0.5.0")
'com.chenenyu.router:annotation:jar:0.5.0'
<dependency org="com.chenenyu.router" name="annotation" rev="0.5.0">
  <artifact name="annotation" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.chenenyu.router', module='annotation', version='0.5.0')
)
libraryDependencies += "com.chenenyu.router" % "annotation" % "0.5.0"
[com.chenenyu.router/annotation "0.5.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Build Status license PullRequest

Router

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

screenshot

Getting started

  • Add router gradle plugin to your project-level build.gradle, as shown below.
buildscript {
    repositories {
        google()
        mavenCentral()
        // jcenter() // deprecated
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:+'
        classpath "com.chenenyu.router:gradle-plugin:x.y.z"
    }
}

latest router-gradle-plugin version: maven

  • 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'
    compilerLoggable = true/false // 打开/关闭编译期log
}

latest router version: maven

latest compiler version: maven

基本用法

  • 添加拦截器(可选)
@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);
// startActivityForResult
Router.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
    }
});

// 获取路由对应的intent
Router.build("test").getIntent();
// 获取注解的Fragment
Router.build("test").getFragment();

进阶用法

建议浏览 wiki.

讨论

QQ group: 271849001

Donate ❤️

Click here.

License

Apache 2.0

Versions

Version
0.5.0