-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
存在 windowLeaked 的问题 #294
Comments
@aarthurddragon 本项目的所有窗体的确是基于Dialog的,BaseDialog只简单的复写了dismiss在里面try……catch来避免闪退,屏幕旋转时Dialog所在的Activity销毁重建了,导致windowLeaked。将Dialog迁移到DialogFragment需要联动改动很多,暂时没计划迁移。你可以试试将条件改为: Activity activity = requireActivity();
...
if (activity.isFinishing() || activity.isDestroyed()) {
return;
}
dialog.dismiss(); |
我取消了使用 lifecycle 组件,使用 lifycycle 组件处理 dialog 的消失问题反而出现了更多问题,新的配置代码如下,但还是存在 windowLeaked 的问题。 class MyFragment : Fragment() {
var datePicker: DatePicker? = null
private fun configureDatePicker() {
val datePicker = DatePicker(requireActivity())
// ...
// 省略无关的配置代码
// ...
this.datePicker = datePicker
datePicker.show()
}
override fun onDestroyView() {
datePicker?.let { if (it.isShowing) it.dismiss() }
datePicker = null
}
} 现在我主动在 onDestroyView() 中判断 datePicker 是否显示,如果显示,则执行 dismiss(),并且主动将引用赋值为 null,但是在屏幕旋转时依然存在 windowLeaked 的问题。日志如下(包名已使用 ...... 省略):
|
怕不是dismiss的问题吧,你看 |
bug 描述
注意到此项目的所有 dialog 都继承于 Dialog 而非 DialogFragment,所以我在配置更改(如屏幕旋转)时对正在显示的 dialog 主动执行 dismiss(),然而在屏幕旋转时 windowLeaked 的问题依然存在,可能和 dialog 内部维护的 view 相关。
配置代码
对 dialog 的配置代码如下:
The text was updated successfully, but these errors were encountered: