public class Router
extends java.lang.Object
支持正则匹配,正则优先级比较低,只有在字符串没匹配的情况下才会尝试正则匹配
限定符和类型 | 类和说明 |
---|---|
static interface |
Router.UrlInterceptor
url 拦截器
|
限定符和类型 | 方法和说明 |
---|---|
void |
addUrlInterceptor(Router.UrlInterceptor interceptor)
添加一个拦截器
|
static Router |
getInstance() |
com.aliyun.iot.aep.component.router.IUrlHandler |
getModuleUrlHandler(java.lang.String url)
获取url对应的 urlHandler
|
void |
registerModuleUrlHandler(java.util.List<java.lang.String> urls,
com.aliyun.iot.aep.component.router.IUrlHandler handler)
注册url 列表到一个urlHandler上
|
void |
registerModuleUrlHandler(java.lang.String url,
com.aliyun.iot.aep.component.router.IUrlHandler handler)
注册单个url 到对应的handler上
|
void |
registerRegexUrlHandler(java.lang.String regexUrl,
com.aliyun.iot.aep.component.router.IUrlHandler handler)
注册正则到 handler上
|
void |
removeUrlInterceptor(Router.UrlInterceptor interceptor)
删除一个拦截器
|
void |
setDefaultUrlHandler(com.aliyun.iot.aep.component.router.IUrlHandler defaultUrlHandler)
设置默认拦截器
|
boolean |
toUrl(android.content.Context context,
java.lang.String url)
|
boolean |
toUrl(android.content.Context context,
java.lang.String url,
android.os.Bundle bundle)
|
boolean |
toUrl(android.content.Context context,
java.lang.String url,
android.os.Bundle bundle,
int requestCode)
根据url 先经过拦截器处理,然后找到注册的urlHandler让其处理,如果没找到则使用默认处理
|
boolean |
toUrlForResult(android.app.Activity act,
java.lang.String url,
int requestCode)
|
boolean |
toUrlForResult(android.app.Activity act,
java.lang.String url,
int requestCode,
android.os.Bundle bundle)
以startActivityForResult形式启动Activity
|
public static final Router getInstance()
public void registerModuleUrlHandler(java.util.List<java.lang.String> urls, com.aliyun.iot.aep.component.router.IUrlHandler handler)
urls
- url 列表handler
- 响应处理注册url 的handlerpublic void registerModuleUrlHandler(java.lang.String url, com.aliyun.iot.aep.component.router.IUrlHandler handler)
url
- 要注册的urlhandler
- 响应的handlerpublic void registerRegexUrlHandler(java.lang.String regexUrl, com.aliyun.iot.aep.component.router.IUrlHandler handler)
regexUrl
- 要注册的正则handler
- 响应的handlerpublic void addUrlInterceptor(Router.UrlInterceptor interceptor)
interceptor
- public void removeUrlInterceptor(Router.UrlInterceptor interceptor)
interceptor
- public void setDefaultUrlHandler(com.aliyun.iot.aep.component.router.IUrlHandler defaultUrlHandler)
defaultUrlHandler
- public com.aliyun.iot.aep.component.router.IUrlHandler getModuleUrlHandler(java.lang.String url)
url
- public boolean toUrl(android.content.Context context, java.lang.String url)
public boolean toUrl(android.content.Context context, java.lang.String url, android.os.Bundle bundle)
public boolean toUrlForResult(android.app.Activity act, java.lang.String url, int requestCode)
public boolean toUrlForResult(android.app.Activity act, java.lang.String url, int requestCode, android.os.Bundle bundle)
requestCode
- 启动intent的request codebundle
- intent 的参数toUrl(Context, String, Bundle, int)
public boolean toUrl(android.content.Context context, java.lang.String url, android.os.Bundle bundle, int requestCode)
context
- 当前页面的Activityurl
- 要跳转到的url