• Stars
    star
    1,086
  • Rank 42,633 (Top 0.9 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A framework for assisting in the renovation of Android componentization(帮助 App 进行组件化改造的动态路由框架)

TheRouter: Android componentization solution

Hex.pm Language Wiki

HomePage | iOS | 中文官网

A. Features

TheRouter core functions have four functionalities:

demo gif

B. Introduction

For more detailed documentation, please check the project wikiWiki

B1. Gradle configuration

module apt router plugin
version apt router plugin
// root build.gradle 
classpath 'cn.therouter:plugin:1.1.4'

// app module 
apply plugin: 'therouter'

// dependencies
kapt "cn.therouter:apt:1.1.4"
implementation "cn.therouter:router:1.1.4"

B2. initialization library

The library contains the automatic initialization function inside,link to: Single module automatic initialization; therefore, there's no need for any initialization code. However, it is recommended that you set the Debug environment according to your business settings to view log information.

@Override
protected void attachBaseContext(Context base) {
    TheRouter.setDebug(true or false);
    super.attachBaseContext(base);
}

B3. page parameter injection

Called in the onCreate() method of Activity or Fragment:
(It is recommended to do it directly in BaseActivity(BaseFragment))

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TheRouter.inject(this);
}

B4. page navigation

For the meaning of the annotation @Route, please check the documentation: Page Navigation

@Route(path = "http://therouter.com/home", action = "action://scheme.com",
        description = "second page", params = {"hello", "world"})
public class HomeActivity extends BaseActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TheRouter.build("Path")
            .withInt("intValue", 12345678)
            .withString("str_123_Value", "传中文字符串")
            .withBoolean("boolValue", true)
            .withLong("longValue", 123456789012345L)
            .withChar("charValue", 'c')
            .withDouble("double", 3.14159265358972)
            .withFloat("floatValue", 3.14159265358972F)
            .navigation();
    }
}

C. proguard rules configuration

# need add for Fragment page route
# -keep public class * extends android.app.Fragment
# -keep public class * extends androidx.fragment.app.Fragment
# -keep public class * extends android.support.v4.app.Fragment

-keep class androidx.annotation.Keep
-keep @androidx.annotation.Keep class * {*;}
-keepclassmembers class * {
    @androidx.annotation.Keep *;
}
-keepclasseswithmembers class * {
    @androidx.annotation.Keep <methods>;
}
-keepclasseswithmembers class * {
    @androidx.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
    @androidx.annotation.Keep <init>(...);
}
-keepclasseswithmembers class * {
    @com.therouter.router.Autowired <fields>;
}

D. Build and Debug

D1. project module description

TheRouter
  ├─app
  │   └──sample
  ├─business-a
  │   └──modular business demo
  ├─business-b
  │   └──modular business demo
  ├─business-base
  │   └──modular business demo
  │
  ├─apt
  │   └──Annotation processor tool code
  │
  ├─plugin
  │   └──Gradle plugin
  │
  └─router
      └──library code

D2. run Project

  1. Open local.properties and declare the modules you want to debug. For example, if you want the source code to debug the apt module, you can declare apt=true
  2. sync Gradle change

D3. plugin source code debugging

plugin debugging is special; you'll need to modify the module name to enable plugin debugging.

  1. Modify the plugin folder name to buildSrc (Case sensitive)
  2. Remove classpath reference in root build.gradle
  3. sync Gradle change

E. Change Log

link to Releases:Github Releases

F. Author

HUOLALA mobile technology team

G. LICENSE

TheRouter is licensed under the Apache License 2.0: LICENSE.

More Repositories

1

page-spy-web

Debug remotely and easily like chrome devtools.
TypeScript
4,192
star
2

hll-wp-glog

Glog is a cross platform high-performance log library developed by Huolala.
PHP
319
star
3

HLLOfflineWebVC-iOS

iOS offline package solution for H5
Objective-C
232
star
4

page-spy

📦 The platform SDKs for PageSpy
TypeScript
193
star
5

HLLOfflineWebView-android

Android offline package solution for H5
Java
177
star
6

hll-popupsmanager-ios

Objective-C
94
star
7

page-spy-api

Go
33
star
8

hll-wp-therouter-ios

A framework for assisting in the renovation of iOS componentization
Objective-C
29
star
9

hll-harmony-component

Batchfile
27
star
10

hll-wp-guldan-ios

OC Method Time Cost Tool
Objective-C
14
star
11

react-pull-to-refreshify

A simple react pull-to-refresh component with 0 dependencies.
TypeScript
9
star
12

i-devices

A device that achieves various device style effects such as smartphones (iPhone series, Google series) and computers (MacBook, SurfaceBook series) through pure CSS code
JavaScript
8
star
13

hll-cocoapods-podspec-binary

Ruby
7
star
14

nad

A solution that bridges language boundaries.
TypeScript
5
star
15

preload-js

TypeScript
3
star
16

nad-java-core

This library is for collecting all Spring Web routes as a serializable data structure.
Java
3
star
17

word-to-vue

A tool that converts Word documents into Vue template.
JavaScript
2
star
18

page-spy-extension

JavaScript
2
star
19

hll-dynamic-res-plugin

Resource Dynamization Solution For Android
Java
2
star
20

react-json-view

<ReactJsonView /> is a react component for displaying serializable data.
TypeScript
2
star
21

batteryfinder-android

A detection tool of Android App power consumption
Kotlin
1
star
22

hll-safetyairbag-ios

Objective-C
1
star