跳详情页强校验登陆
App大了之后会有多种跳转方式,比如短链、web、app内、push等,想在跳转前做一些事情,那么拦截器就派上用场了
@Interceptor(priority = 10, name = "详情页校验登陆状态")
public class DetailInterceptor implements IInterceptor {
private Context mContext;
@Override
public void process(Postcard postcard, InterceptorCallback callback) {
try {
//未登陆&是详情 那么登陆并跳转
if (!LoginManager.isLogin() && postcard.getPath().equals(SyRouter.DETAILS) && null != postcard.getUri()) {
//跳转登陆页面吧.....
return;
}
//正常跳转....
callback.onContinue(postcard);
} catch (Exception e) {
e.printStackTrace();
callback.onContinue(postcard);
}
}
@Override
public void init(Context context) {
this.mContext = context;
}
}
网友评论