Navigator

open class Navigator(var url: String?, val intent: Intent?)

路由导航器。与RouterItem作用类似,允许互转。 RouterItem 用于描述一个静态的路由项 Navigator 用于描述一个路由项的跳转动作

TheRouter.build(url).with(k,v)
如果如果没有通过PathFixHandle拦截器修改,且只在build(url)时传入参数,TheRouter会确保参数在getUrlWithParams()导出时完全相同。
如果build(url)时有拼接参数,同时又调用with()传入参数,TheRouter会保证with的参数拼接在url拼接的参数前且在hash字段之前
如果有冲突时,优先使用with()中的kv,例如:
TheRouter.build("http://therouter.cn/page?a=b&k=v").withString("c","d").withString("k","x")
调用getUrlWithParams()导出的url为:http://therouter.cn/page?c=d&a=b&k=x
有hash字段时的处理,例如
TheRouter.build("https://therouter.cn/page?code=123&a=b#/abc").withString("code","111").withString("k","x")
调用getUrlWithParams()导出的url为:https://therouter.cn/page?k=x&code=111&a=b#/abc


如果url的hash部分包含有参数时,TheRouter也会将参数直接解析出来作为页面跳转参数传递出去,
但如果hash的参数与url的参数出现冲突,会优先取url的参数,例如:
TheRouter.build("http://therouter.cn/page?a=b&k=v#/abc&c=d&k=a").navigation()
此时页面参数获取到的将是:a=b、k=v、c=d(k=a被k=v替代)
如果url的hash部分包含有参数但同时又包含有问号时,将会认为hash部分是一个整体,是一个完整的子url,此时不会解析hash部分的参数,例如:
TheRouter.build("http://therouter.cn/page?a=b&k=v#/abc?c=d&k=a").navigation()
此时页面参数获取到的将是:a=b、k=v,子串部分不会解析

Constructors

Link copied to clipboard
constructor(url: String?)
constructor(url: String?, intent: Intent?)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var url: String?

Functions

Link copied to clipboard
fun action()
fun action(ctx: Context? = null)

执行导航器Action

Link copied to clipboard
fun addFlags(flags: Int): Navigator
Link copied to clipboard
fun <T : Fragment?> createFragment(): T?

通过导航器创建Fragment,当TheRouter没有初始化完成时,将返回null 接收方可通过argus或@Autowired获取参数

Link copied to clipboard
fun <T : Fragment?> createFragmentWithCallback(callback: (T?) -> Unit)

通过导航器创建Fragment,异步回调 接收方可通过argus或@Autowired获取参数

Link copied to clipboard

通过导航器创建Intent,会自动将Navigator中的参数传入Intent intent.putExtra(KEY_ACTION, routeItem.action) intent.putExtra(KEY_PATH, getUrlWithParams()) intent.putExtra(KEY_DESCRIPTION, routeItem.description)

Link copied to clipboard
fun createIntentWithCallback(ctx: Context?, callback: (Intent) -> Unit)

通过导航器创建Intent,会自动将Navigator中的参数传入Intent,异步回调返回 intent.putExtra(KEY_ACTION, routeItem.action) intent.putExtra(KEY_PATH, getUrlWithParams()) intent.putExtra(KEY_DESCRIPTION, routeItem.description)

Link copied to clipboard
fun fillParams(action: (Bundle) -> Unit): Navigator
Link copied to clipboard
fun navigation(context: Context? = getApplicationContext(), callback: NavigationCallback? = null)
fun navigation(fragment: Fragment?, callback: NavigationCallback? = null)
fun navigation(ctx: Context?, requestCode: Int, ncb: NavigationCallback? = null)
fun navigation(fragment: Fragment?, requestCode: Int, ncb: NavigationCallback? = null)

fun navigation(ctx: Context?, fragment: Fragment?, requestCode: Int, ncb: NavigationCallback? = null)

跳转到对应Activity落地页

Link copied to clipboard
fun optObject(key: String): Any?
Link copied to clipboard
Link copied to clipboard
fun setClipData(clipData: ClipData?): Navigator
Link copied to clipboard
fun setData(uri: Uri?): Navigator
Link copied to clipboard
fun setIdentifier(identifier: String?): Navigator
Link copied to clipboard
fun with(value: Bundle?): Navigator
Link copied to clipboard
fun withBoolean(key: String?, value: Boolean): Navigator
Link copied to clipboard
fun withBundle(key: String?, value: Bundle?): Navigator
Link copied to clipboard
fun withByte(key: String?, value: Byte): Navigator
Link copied to clipboard
fun withChar(key: String?, value: Char): Navigator
Link copied to clipboard
fun withDouble(key: String?, value: Double): Navigator
Link copied to clipboard
fun withFlags(flags: Int): Navigator
Link copied to clipboard
fun withFloat(key: String?, value: Float): Navigator
Link copied to clipboard
Link copied to clipboard
fun withInt(key: String?, value: Int): Navigator
Link copied to clipboard
fun withLong(key: String?, value: Long): Navigator
Link copied to clipboard
fun withObject(key: String, value: Any): Navigator
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun withString(key: String?, value: String?): Navigator