Skip to content
qiibeta edited this page May 17, 2020 · 4 revisions

Dependency

gradle.properties add

SCENEROUTER_CORE=com.bytedance.scenerouter:core:0.0.1
SCENEROUTER_ANNOTATION=com.bytedance.scenerouter:annotation:0.0.1
SCENEROUTER_APT=com.bytedance.scenerouter:apt:0.0.1
SCENEROUTER_PLUGIN=com.bytedance.scenerouter:plugin:0.0.1

app build.gradle add

dependencies {
        classpath SCENEROUTER_PLUGIN
    }

app build.gradle add

apply plugin: 'com.bytedance.scenerouter'

every module build.gradle add

dependencies {
implementation SCENEROUTER_ANNOTATION
    implementation SCENEROUTER_CORE
    annotationProcessor SCENEROUTER_APT
    kapt SCENEROUTER_APT
    implementation SCENEROUTER_APT
}

option

android {
    defaultConfig {
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [SCENE_ROUTER_MODULE_NAME: project.getName(),
                             SCENE_ROUTER_DEBUG      : "true"]
            }
        }
    }

Usage

Configuration

@SceneUrl({"/test1", "app:///test2", "/test3/target"})
public class LibrarySceneJava extends Scene
@SceneUrl("/test1", "/test2", "/test3")
class LibraryDetailSceneKotlin : Scene() {

Open

       SceneRouter sceneRouter = SceneRouters.of(YourScene.this);
        sceneRouter.url(targetUrl).argument("argKey", "argValue").open(new OpenCallback() {
            @Override
            public void onSuccess() {

            }

            @Override
            public void onFail(@Nullable Exception exception) {
                if (exception instanceof SceneNotFoundException) {

                }
            }
        });

Samples

https://github.com/bytedance/scene/tree/scene_router_samples