Skip to content
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app update v2.1.2 Nov 27, 2019
gradle/wrapper create arouter demo Nov 7, 2019
library update as-3.5.3 Dec 11, 2019
LICENSE Initial commit Nov 7, 2019
README.md update v2.1.2 Nov 27, 2019
build.gradle update as-3.5.3 Dec 11, 2019
gradle.properties create arouter demo Nov 7, 2019
settings.gradle update readme Nov 9, 2019

README.md

Hello, Do you know about component development ?

If you don't know, please click here : CmonBaby

Arouter Build Status

  • Simplifies to devleper between components
  • Makes your code simpler
  • Very simple configuration
  • Lightweight (~32k jar)

Arouter in 4 steps

1. Setting build.gradle (android application / android library):

def moduleName = project.name
android {
    // ......
    defaultConfig {
        // ......

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [moduleName: moduleName]
            }
        }
    }
    buildTypes {
        release {
            // ......
        }
    }
}

2. Add class annotation as route

@ARouter(path = "/app/MainActivity")
public class MainActivity extends AppCompatActivity {}

3. Intent and carry params

RouterManager.getInstance() // Singleton
        // Arouter path
        .build("/library/LibraryActivity")
        // String
        .withString("name", "simon")
        // Basic data type
        .withInt("totalCount", 2333)
        .withBoolean("key", value)
        .withByte("key", value)
        .withChar("key", value)
        .withDouble("key", value)
        .withFloat("key", value)
        .withLong("key", value)
        .withShort("key", value)
        // Serializable and Parcelable
        .withSerializable("key", value)
        .withParcelable("key", value)
        // Bundle
        .withBundle("key", value)
        // Activate the callback
        .withResultString("key", value)
        // Intent jump
        .navigation(this, requestCode) // startActivityForResult()
        .navigation(this, resultCode) // setResult() + finish()
        .navigation(this); // startActivity()

4. About Parameters

@ARouter(path = "/library/LibraryActivity")
public class LibraryActivity extends AppCompatActivity {

    @Parameter // Parameter name = Field name
    String name;
    
    @Parameter(name = "totalCount") // Custom parameter name
    int count;
    
    @Parameter
    PersonalInfo info; // Javabean (must be 'implements Serializable or Parcelable')
    
    @Parameter(name = "/library/DrawableImpl")
    OpenApi drawable; // Public interface (must be 'extends Call')

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_library);

        ParameterManager.getInstance().loadParameter(this); // Lazy loading
        Log.e("simon >>> ", name);
    }
}

Add Arouter to your project

Via Gradle:

implementation 'com.cmonbaby.arouter.core:arouter_core:2.1.2'
implementation 'com.cmonbaby.arouter.annotation:arouter_annotation:2.1.2'
annotationProcessor 'com.cmonbaby.arouter.compiler:arouter_compiler:2.1.2'

Via Maven:

<dependency>
    <groupId>com.cmonbaby.arouter.annotation</groupId>
    <artifactId>arouter_annotation</artifactId>
    <version>2.1.2</version>
</dependency>
<dependency>
    <groupId>com.cmonbaby.arouter.compiler</groupId>
    <artifactId>arouter_compiler</artifactId>
    <version>2.1.2</version>
</dependency>
<dependency>
    <groupId>com.cmonbaby.arouter.core</groupId>
    <artifactId>arouter_core</artifactId>
    <version>2.1.2</version>
</dependency>

License

Copyright (C) 2013-2020 Markus Junginger, Simon (https://www.cmonbaby.com)
Arouter binaries and source code can be used according to the Apache License, Version 2.0.

You can’t perform that action at this time.