Coder Social home page Coder Social logo

fish19920404 / android-rudolph-router Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wzbos/android-rudolph-router

0.0 0.0 0.0 417 KB

Rudolph android router framework(鲁道夫安卓路由组件框架)

License: Apache License 2.0

Java 22.96% Kotlin 76.85% Shell 0.19%

android-rudolph-router's Introduction

Rudolph

Rudolph Android Router Framework(鲁道夫安卓路由框架组件)

Download Maven

版本更新记录

框架特性

  • 支持组件API模块自动生成
  • 自动生成路由Builder类与服务类的接口层;
  • 加载更快,更稳定,无需插桩与dex扫描;
  • 无需指定模块名,接入更简单;
  • 显式跳转与URL路由地址跳转融为一体,更方便快捷;
  • 通过Builder方式传参,无需手动写参数名,从而减少参数传错和修改带来的Bug隐患;
  • 支持所有Intent的参数类型;
  • 支持Activity 、Fragment、Service、Method四种路由类型
  • 支持Instant Run
  • 支持AndroidX
  • 支持Kotlin

支持路由类型

1、组件引入

1.添加依赖(1.x.x为版本号)

Java:

repositories {
   jcenter()
}

dependencies {
  implementation "cn.wzbos.android:rudolph:1.x.x"
  annotationProcessor "cn.wzbos.android:rudolph-compiler:1.x.x"
}

Kotlin:

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

repositories {
   jcenter()
}

dependencies {
  implementation "cn.wzbos.android:rudolph:1.x.x"
  kapt "cn.wzbos.android:rudolph-compiler:1.x.x"
}

2、代码混淆

所需混淆配置都已经打包到组件内,无需新增额外混淆配置

3、初始化

建议放到application中

Rudolph.init(this);

4、拦截器

  • 添加拦截器
Rudolph.addInterceptor(new Interceptor() {
    @Override
    public boolean intercept(Context context, Router routeInfo) {
        if ("/test4".equalsIgnoreCase(routeInfo.getRawUrl())) {
            Toast.makeText(MyApplication.this, "intercept,path:" + routeInfo.getRawUrl(), Toast.LENGTH_SHORT).show();
            return true;
        }
        return false;
    }
});
  • 移除拦截器
Rudolph.removeInterceptor(interceptor);

5、设置scheme

设置当前APP的scheme用于支持其他APP程序跳转到当前APP

Rudolph.setScheme("myApp")

scheme值需要于AndroidManifest.xml文件中的值相同,例如下面的scheme为"myApp"

<activity
    android:name=".MainActivity"
    android:configChanges="keyboardHidden|orientation"
    android:screenOrientation="portrait">
    <intent-filter>
        <data android:scheme="myApp" />
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

6、bind

给@Extra注解的变量赋值,一般用在Activity的create 或者 Service的init方法内

Rudolph.bind(this)

7、onNewIntent

用于在Activity的onNewIntent生命周期内重新赋值

Rudolph.onNewIntent("myApp")

8、addRoute

添加一条路由记录,一般场景下不需要用,此方法主要是路由表类自行调用

Rudolph.addRoute(new RouteInfo.Builder().routeType(RouteType.ACTIVITY)
    .target(KotlinActivity.class)
    .path("/kotlin/test")
    .tag("")
    .extra("userId",int.class)
    .extra("userName",String.class).build());

android-rudolph-router's People

Contributors

wzbos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.