Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scene自身添加一个 NavigationListener,在pop时没有收到回调 #22

Closed
Ccixyj opened this issue Jan 3, 2020 · 4 comments
Closed

Comments

@Ccixyj
Copy link

Ccixyj commented Jan 3, 2020

有一个使用场景需要在scene内部监听栈进出。push时可以,pop时收不到。

 requireNavigationScene().addNavigationListener(this , NavigationListener { from, to, isPush ->
   //pop 时没有回调
        } )
@qii
Copy link
Member

qii commented Jan 5, 2020

你这个被pop的就是你在监听的Scene?

@Ccixyj
Copy link
Author

Ccixyj commented Jan 5, 2020

@qii 对。

@qii
Copy link
Member

qii commented Jan 6, 2020

addNavigationListener 的时候这个 this 就是当前的 Scene 的 lifecycleowner,pop 这个 Scene 的时候,自然因为 lifecycle 销毁,于是回调被移除了,于是也就收不到 NavigationListener 的回调。或者你可以考虑把 this 改为 requireNavigationScene(),然后在回调里面判断 from == 你的 Scene,并且 isPush == false,然后再把自己 removeNavigationListener 掉

@Ccixyj
Copy link
Author

Ccixyj commented Jan 7, 2020

交给navigation scene也是可以的

@Ccixyj Ccixyj closed this as completed Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants