-
Notifications
You must be signed in to change notification settings - Fork 228
添加拦截器
Half Stack edited this page Jun 21, 2018
·
6 revisions
Router
支持拦截器功能,即拦截路由。
intercept
返回chain.intercept()
即表示拦截该次路由,chain.process()
表示不拦截。
Router.addGlobalInterceptor(new RouteInterceptor() {
@Override
public RouteResponse intercept(Chain chain) {
// operation.
return chain.process();
}
});
@Interceptor("SampleInterceptor")
public class SampleInterceptor implements RouteInterceptor {
@Override
public RouteResponse intercept(Chain chain) {
return chain.process();
}
}
@Route(value = "test", interceptors = "SampleInterceptor")
public class TestActivity extends AppCompatActivity {
...
}