Giter VIP home page Giter VIP logo

hll-wp-therouter-android's Introduction

TheRouter: Android componentization solution

Hex.pm Language Wiki

HomePage | 中文官网

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.2'

// app module 
apply plugin: 'therouter'

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

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.

hll-wp-therouter-android's People

Contributors

kymjs 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.