All Projects → ssseasonnn → Rxrouter

ssseasonnn / Rxrouter

A lightweight, simple, smart and powerful Android routing library.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Rxrouter

T Mvp
Android AOP Architecture by Apt, AspectJ, Javassisit, based on Realm+Databinding+MVP+Retrofit+Rxjava2
Stars: ✭ 2,740 (+756.25%)
Mutual labels:  rxjava, router
Component
🔥🔥🔥A powerful componentized framework.一个强大、100% 兼容、支持 AndroidX、支持 Kotlin并且灵活的组件化框架
Stars: ✭ 2,434 (+660.63%)
Mutual labels:  rxjava, router
Popular Movies App
A simple Android app, that helps user to discover movies. Project 1 & 2 of Udacity Android Developer Nanodegree.
Stars: ✭ 293 (-8.44%)
Mutual labels:  rxjava
Esp wifi repeater
A full functional WiFi Repeater (correctly: a WiFi NAT Router)
Stars: ✭ 3,818 (+1093.13%)
Mutual labels:  router
Eventline
Micro-framework for routing and handling events for bots and applications 🤖. IFTTT for developers 👩‍💻👨‍💻
Stars: ✭ 305 (-4.69%)
Mutual labels:  router
Rxbiometric
☝️ RxJava and RxKotlin bindings for Biometric Prompt (Fingerprint Scanner) on Android
Stars: ✭ 295 (-7.81%)
Mutual labels:  rxjava
Rxgps
Finding current location cannot be easier on Android !
Stars: ✭ 307 (-4.06%)
Mutual labels:  rxjava
Pjax Api
The second generation PJAX for advanced web frameworks.
Stars: ✭ 291 (-9.06%)
Mutual labels:  router
Router
Ruby/Rack HTTP router
Stars: ✭ 317 (-0.94%)
Mutual labels:  router
Autodispose
Automatic binding+disposal of RxJava streams.
Stars: ✭ 3,209 (+902.81%)
Mutual labels:  rxjava
Clean Android Code
MVP + Dagger 2 + RxJava + Retrofit2
Stars: ✭ 311 (-2.81%)
Mutual labels:  rxjava
Cortex
Routing system for WordPress
Stars: ✭ 300 (-6.25%)
Mutual labels:  router
Fluro
Fluro is a Flutter routing library that adds flexible routing options like wildcards, named parameters and clear route definitions.
Stars: ✭ 3,372 (+953.75%)
Mutual labels:  router
Crayon
Simple framework agnostic UI router for SPAs
Stars: ✭ 310 (-3.12%)
Mutual labels:  router
Requery
requery - modern SQL based query & persistence for Java / Kotlin / Android
Stars: ✭ 3,071 (+859.69%)
Mutual labels:  rxjava
Svelte Router
Svelte Router adds routing to your Svelte apps. It's designed for Single Page Applications (SPA). Includes localisation, guards and nested layouts.
Stars: ✭ 310 (-3.12%)
Mutual labels:  router
Xhttp2
💪A powerful network request library, encapsulated using the RxJava2 + Retrofit2 + OKHttp combination.(一个功能强悍的网络请求库,使用RxJava2 + Retrofit2 + OKHttp组合进行封装)
Stars: ✭ 292 (-8.75%)
Mutual labels:  rxjava
Mpvue Router Patch
🛴在 mpvue 中使用 vue-router 兼容的路由写法
Stars: ✭ 298 (-6.87%)
Mutual labels:  router
Routing Controllers
Create structured, declarative and beautifully organized class-based controllers with heavy decorators usage in Express / Koa using TypeScript and Routing Controllers Framework.
Stars: ✭ 3,557 (+1011.56%)
Mutual labels:  router
Amazefilemanager
Material design file manager for Android
Stars: ✭ 3,626 (+1033.13%)
Mutual labels:  rxjava

RxRouter

Download

Read this in other languages: 中文English 

A lightweight, simple, smart and powerful Android routing library.

Getting started

Setting up the dependency

Add to your project build.gradle file:

dependencies {
	implementation 'zlc.season:rxrouter:x.y.z'
	annotationProcessor 'zlc.season:rxrouter-compiler:x.y.z'
}

(Please replace x and y and z with the latest version numbers: )

For Kotlin you should use kapt instead of annotationProcessor

Hello World

First add the @url annotation to the activity we need to route:

@Url("this is a url")
class UrlActivity : AppCompatActivity() {
    ...
}

Then create a class that is annotated with @Router to tell RxRouter that there is a router:

@Router
class MainRouter{
}

This class doesn't need to have any remaining code. RxRouter will automatically generate a RouterProvider based on the class name of the class. For example, MainRouter will generate MainRouterProvider.

Then we need to add these routers to RxRouterProviders:

class CustomApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        RxRouterProviders.add(MainRouterProvider())
    }
}

Finally, we can start our performance:

RxRouter.of(context)
        .route("this is a uri")
        .subscribe()

Parameters

Routing with parameters:

With the with method, you can add a series of parameters to this route.

RxRouter.of(context)
        .with(10)                         	//int value
        .with(true)							//boolean value
        .with(20.12)						//double value
        .with("this is a string value")		//string value
        .with(Bundle())						//Bundle value
        .route("this is a uri")
        .subscribe()

No longer needs the onActivityResult method

Want to get the value returned by the route? No longer have to write a bunch of onActivityResult methods! One step in place with RxJava!

RxRouter.of(context)
		.with(false)
        .with(2000)
        .with(9999999999999999)
        .route("this is a uri")
        .subscribe {
            if (it.resultCode == Activity.RESULT_OK) {
                val intent = it.data
                val stringResult = intent.getStringExtra("result")
                result_text.text = stringResult
                stringResult.toast()
            }
        }

If there is a result return, it will be processed in subscribe.

Routing through Class

Do not want to use Url annotations? No problem, RxRouter also supports the original jump of the specified class name, in the same way:

RxRouter.of(context)
        .routeClass(ClassForResultActivity::class.java)
        .subscribe{
            if (it.resultCode == Activity.RESULT_OK) {
                val intent = it.data
                val stringResult = intent.getStringExtra("result")
                result_text.text = stringResult
                stringResult.toast()
            }
        }

Routing through Action

Similarly, RxRouter also supports system Actions and custom Actions.

Routing through custom Action:

<activity android:name=".ActionActivity">
    <intent-filter>
        <action android:name="zlc.season.sample.action" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
RxRouter.of(context)
        .routeAction("zlc.season.sample.action")
        .subscribe({
            "no result".toast()
        }, {
            it.message?.toast()
        })

Routing through system action:

//dial
RxRouter.of(this)
        .addUri(Uri.parse("tel:123456"))
        .routeSystemAction(Intent.ACTION_DIAL)
        .subscribe()

//send message
val bundle = Bundle()
bundle.putString("sms_body", "this is message")
RxRouter.of(this)
        .addUri(Uri.parse("smsto:10086"))
        .with(bundle)
        .routeSystemAction(Intent.ACTION_SENDTO)
        .subscribe()

Firewall

The RxRouter has a small and powerful firewall that can be intercepted according to firewall rules before routing. You can add one or more firewalls.

//create a LoginFirewall
class LoginFirewall : Firewall {
    override fun allow(datagram: Datagram): Boolean {
        if (notLogin) {
            "please log in".toast()
            return false
        }
        return true
    }
}

//Add Firewall to Route
RxRouter.of(this)
        .addFirewall(LoginFirewall())
        .route("this is a url")
        .subscribe()

License

Copyright 2018 Season.Zlc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].