Comments (13)
如果能把这个案例写在demo里最好了
from arouter.
拦截器只是提供了这种机制,不太适合关心内部的业务逻辑,如果搞成LoginInterceptor这种目的性很强的设计,用起来可能简单一些,但是不具通用性,可能用户就需要去记住N个不同功能的拦截器了,成本反而更高了。
大家会就纠结这些特型的拦截器和标准的拦截器的区别和时序了
from arouter.
不是这样用的,不要修改目的地,在拦截器里面自己拉起登录页,登录成功之后,调用回调的onContinue就会继续往下走了,失败的话,调用终止即可。
参考Demo中的用法。
from arouter.
@zhi1ong
非常感谢您的耐心回答。
我还有一点不明白的,在拦截器中去自己启动登录页的话,登录结果如何通知到Interceptor,回调onContinue呢?
from arouter.
广播、消息、回调,反正能通知回来就行,然后再回调Interceptor的回调
from arouter.
@zhi1ong
非常感谢您的耐心回答。
我也想过要这样做,但是这样写出来感觉有点别扭。如果能有一种方法让Router直接处理这些事件就好了。目前可能只能这样解决了。再次感谢您的耐心回答。
from arouter.
登录结果具体怎么回调到拦截器中能说细点吗?
from arouter.
最简单的可以通过广播,不过一般的实践是把登录封装起来,做成一个异步接口,外部需要登录的时候,不关心内部的页面,只需要在接口的回调中调用拦截器的onContinue即可
from arouter.
@zhi1ong 谢谢,用广播来通知会不会太重量级了,能不能加一下 QQ 细说?851183849还有一些别的问题想请教您。
from arouter.
可以,本地广播传递点事件还是很常用的
from arouter.
可以在LoginInterceptor里面把控制拦截或者释放两个对象(PostCard和InterceptorCallback)传到一个自定义的单例中,然后在登录页面对这个单例(即是对PostCard和InterceptorCallback)进行操作,来实现目的。
from arouter.
调起登录页面,但是无法知道前一个activity引用。不知道各位咋实现的?
from arouter.
这样搞行不行。两个静态变量会不会有空指针的危险啊
后来我使用了eventbus来传递InterceptorCallback和Postcard对象
from arouter.
Related Issues (20)
- 真特么垃圾,史上最垃圾的库 HOT 1
- Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.server.wm.Task.inPinnedWindowingMode()' on a null object reference
- 通过三方插件对ARouter提供KSP注解处理器支持, 帮助大家移除KAPT、提升kotlin项目编译速度
- It's outrageous, why is it strongly related to the calling order of the code:
- Fork了一个版本,适配了AGP8.0,可直接远程引用,链接见内
- 希望能适配 APG 7.3+ HOT 5
- 初始化耗时-BlockCanaryContext检测
- AS 火烈鸟 构建性能提示 HOT 2
- The following annotation processors are not incremental: jetified-arouter-compiler-1.1.4.jar (com.alibaba:arouter-compiler:1.1.4). Make sure all annotation processors are incremental to improve your build speed. :module_device:compileYF_PRODebugJavaWithJavac spend 78ms
- 安卓Android 7.1.1报错:
- Android7.1.1报错:Attempt to read from field 'java.lang.String com.android.server.am.ActivityRecord.packageName' on a null object reference,具体信息如下:
- 同时使用arouter 和 hilt报错 HOT 7
- 基于 KSP 和 AGP 8 的重构版本 HOT 3
- 自定义类型值不传崩溃
- It will caused NullPointException if we implement the interface of 'PretreatmentService' with Kotlin language
- ⚠️⚠️⚠️新写了一个Android路由库,Gradle8.0+自动注册,同样的API,更多的功能.
- 以后再用阿里的开源库我就是狗 HOT 3
- gradle 8.0构建项目报错API 'android.registerTransform' is removed. HOT 3
- 被通付盾安全监测出一个中危漏洞,贵司有计划修复一下么? HOT 1
- R8混淆报错了-dontwarn javax.lang.model.element.**
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arouter.