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

点击进入然后马上点击回退键闪退 #677

Closed
VankaIn opened this issue Dec 14, 2017 · 5 comments
Closed

点击进入然后马上点击回退键闪退 #677

VankaIn opened this issue Dec 14, 2017 · 5 comments

Comments

@VankaIn
Copy link
Contributor

VankaIn commented Dec 14, 2017

具体场景:
打开 fragment,立马按回退键,崩溃。
原因:在 onEnterAnimationEnd 初始化一些 view,防止 fragment 转场动画卡顿。但是当点击回退键fragment 结束之后 onEnterAnimationEnd 里面的函数还是会运行,导致 view 报空指针错误

@VankaIn
Copy link
Contributor Author

VankaIn commented Dec 14, 2017

现在解决就是,在 baseFragment 里面加一个标志位isAnimateFinish = false,当做完onEnterAnimationEnd,这个标志为isAnimateFinish = true, 然后在回退栈时候判断,基本能解决以上问题,但是缺陷就是做转场过程的时候不能回退,希望楼主能给出更好的方案

@YoKeyword
Copy link
Owner

onEnterAnimationEnd里的代码贴一下, 因为内部是post,所以理论上是不会view为空的

一种原因是onEnterAnimationEnd里有异步操作,然后回调里操作了View导致崩溃

@VankaIn
Copy link
Contributor Author

VankaIn commented Dec 15, 2017

image.png

你好,以上是具体报错和代码截图。
我这边已经定位到问题,原因是使用 Bufferknife 的时候在 onDestroyView() 上使用了 unbinder.unbind()导致的,具体解决方案还需要探究,也希望大佬能指导一下

@YoKeyword
Copy link
Owner

ButterKnife的Unbinder.unbind()里,是强制把@BindView的 View置为null,所以在出栈情况下(先调用了onDestroyView()),再回调onEnterAnimEnd()导致了空指针

已经发布 v1.1.10,兼容了ButterKnife的Unbinder.unbind()

@VankaIn
Copy link
Contributor Author

VankaIn commented Dec 16, 2017

666, 效率真的是高

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