Coder Social home page Coder Social logo

Comments (13)

AvatarQing avatar AvatarQing commented on May 2, 2024 11

如果能把这个案例写在demo里最好了

from arouter.

zhi1ong avatar zhi1ong commented on May 2, 2024 1

拦截器只是提供了这种机制,不太适合关心内部的业务逻辑,如果搞成LoginInterceptor这种目的性很强的设计,用起来可能简单一些,但是不具通用性,可能用户就需要去记住N个不同功能的拦截器了,成本反而更高了。

大家会就纠结这些特型的拦截器和标准的拦截器的区别和时序了

from arouter.

zhi1ong avatar zhi1ong commented on May 2, 2024

不是这样用的,不要修改目的地,在拦截器里面自己拉起登录页,登录成功之后,调用回调的onContinue就会继续往下走了,失败的话,调用终止即可。

参考Demo中的用法。

from arouter.

ManchesterLee avatar ManchesterLee commented on May 2, 2024

@zhi1ong
非常感谢您的耐心回答。

我还有一点不明白的,在拦截器中去自己启动登录页的话,登录结果如何通知到Interceptor,回调onContinue呢?

from arouter.

zhi1ong avatar zhi1ong commented on May 2, 2024

广播、消息、回调,反正能通知回来就行,然后再回调Interceptor的回调

from arouter.

ManchesterLee avatar ManchesterLee commented on May 2, 2024

@zhi1ong
非常感谢您的耐心回答。

我也想过要这样做,但是这样写出来感觉有点别扭。如果能有一种方法让Router直接处理这些事件就好了。目前可能只能这样解决了。再次感谢您的耐心回答。

from arouter.

 avatar commented on May 2, 2024

登录结果具体怎么回调到拦截器中能说细点吗?

from arouter.

zhi1ong avatar zhi1ong commented on May 2, 2024

最简单的可以通过广播,不过一般的实践是把登录封装起来,做成一个异步接口,外部需要登录的时候,不关心内部的页面,只需要在接口的回调中调用拦截器的onContinue即可

from arouter.

 avatar commented on May 2, 2024

@zhi1ong 谢谢,用广播来通知会不会太重量级了,能不能加一下 QQ 细说?851183849还有一些别的问题想请教您。

from arouter.

zhi1ong avatar zhi1ong commented on May 2, 2024

可以,本地广播传递点事件还是很常用的

from arouter.

kevintkm avatar kevintkm commented on May 2, 2024

可以在LoginInterceptor里面把控制拦截或者释放两个对象(PostCard和InterceptorCallback)传到一个自定义的单例中,然后在登录页面对这个单例(即是对PostCard和InterceptorCallback)进行操作,来实现目的。

from arouter.

robinx2012 avatar robinx2012 commented on May 2, 2024

调起登录页面,但是无法知道前一个activity引用。不知道各位咋实现的?

from arouter.

protectedMan avatar protectedMan commented on May 2, 2024

image

登录的activity里
image

这样搞行不行。两个静态变量会不会有空指针的危险啊

后来我使用了eventbus来传递InterceptorCallback和Postcard对象

from arouter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.