Navigator

open class Navigator(url: String?, 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

Navigator
链接已复制到剪贴板
fun Navigator(url: String?)
Navigator
链接已复制到剪贴板
fun Navigator(url: String?, intent: Intent?)

Functions

action
链接已复制到剪贴板
fun action()
fun action(ctx: Context? = null)

执行导航器Action

addFlags
链接已复制到剪贴板
fun addFlags(flags: Int): Navigator
createFragment
链接已复制到剪贴板
fun <T : Fragment?> createFragment(): T?

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

createFragmentWithCallback
链接已复制到剪贴板
fun <T : Fragment?> createFragmentWithCallback(callback: (T?) -> Unit)

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

createIntent
链接已复制到剪贴板
fun createIntent(ctx: Context?): Intent

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

createIntentWithCallback
链接已复制到剪贴板
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)

fillParams
链接已复制到剪贴板
fun fillParams(action: (Bundle) -> Unit): Navigator
getUrlWithParams
链接已复制到剪贴板
fun getUrlWithParams(): String
fun getUrlWithParams(handle: NavigatorParamsFixHandle): String
fun getUrlWithParams(handle: (String, String) -> String): String
navigation
链接已复制到剪贴板
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落地页

optObject
链接已复制到剪贴板
fun optObject(key: String): Any?
pending
链接已复制到剪贴板
fun pending(): Navigator
setClipData
链接已复制到剪贴板
fun setClipData(clipData: ClipData?): Navigator
setData
链接已复制到剪贴板
fun setData(uri: Uri?): Navigator
setIdentifier
链接已复制到剪贴板
fun setIdentifier(identifier: String?): Navigator
with
链接已复制到剪贴板
fun with(value: Bundle?): Navigator
withBoolean
链接已复制到剪贴板
fun withBoolean(key: String?, value: Boolean): Navigator
withBundle
链接已复制到剪贴板
fun withBundle(key: String?, value: Bundle?): Navigator
withByte
链接已复制到剪贴板
fun withByte(key: String?, value: Byte): Navigator
withChar
链接已复制到剪贴板
fun withChar(key: String?, value: Char): Navigator
withDouble
链接已复制到剪贴板
fun withDouble(key: String?, value: Double): Navigator
withFlags
链接已复制到剪贴板
fun withFlags(flags: Int): Navigator
withFloat
链接已复制到剪贴板
fun withFloat(key: String?, value: Float): Navigator
withInAnimation
链接已复制到剪贴板
fun withInAnimation(id: Int): Navigator
withInt
链接已复制到剪贴板
fun withInt(key: String?, value: Int): Navigator
withLong
链接已复制到剪贴板
fun withLong(key: String?, value: Long): Navigator
withObject
链接已复制到剪贴板
fun withObject(key: String, value: Any): Navigator
withOptionsCompat
链接已复制到剪贴板
fun withOptionsCompat(options: Bundle?): Navigator
withOutAnimation
链接已复制到剪贴板
fun withOutAnimation(id: Int): Navigator
withParcelable
链接已复制到剪贴板
fun withParcelable(key: String?, value: Parcelable?): Navigator
withSerializable
链接已复制到剪贴板
fun withSerializable(key: String?, value: Serializable?): Navigator
withString
链接已复制到剪贴板
fun withString(key: String?, value: String?): Navigator

Properties

extras
链接已复制到剪贴板
val extras: Bundle
intent
链接已复制到剪贴板
val intent: Intent?
kvPair
链接已复制到剪贴板
val kvPair: HashMap<String, String>
originalUrl
链接已复制到剪贴板
val originalUrl: String?
pathFixOriginalUrl
链接已复制到剪贴板
var pathFixOriginalUrl: String
simpleUrl
链接已复制到剪贴板
val simpleUrl: String
url
链接已复制到剪贴板
var url: String?