页面里面返回键会触发显示是否操作的弹窗,发现有一定的几率弹窗显示后会自动关闭
Opened this issue · 2 comments
zhuzhao404 commented
XPopup版本
2.7.5(其实最新版也会出现)
手机系统和型号
三星s10+ Android 12(其他手机也会出现)
描述你的问题
多次尝试的情况下,偶发性的会立即关闭弹窗,视觉上就是闪一下
zhuzhao404 commented
经我多次测试,如果这个弹窗显示是由系统的back键触发显示的就会偶发这种现象下面我会贴出代码和日志:
class MainActivity : AppCompatActivity() {
lateinit var textView: TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
textView = findViewById<TextView>(R.id.textView);
textView.setOnClickListener {
testDialog("onClickAction")
}
}
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK) {
testDialog("onKeyDownBackAction")
return true
}
return super.onKeyDown(keyCode, event)
}
private fun testDialog(action: String) {
val clickTime = Date().time
val xPopup = XPopup.Builder(this).isDestroyOnDismiss(true)
.setPopupCallback(object : SimpleCallback() {
override fun onDismiss(popupView: BasePopupView?) {
val dismissTime = Date().time
Log.e(action, "onDismiss: ${dismissTime - clickTime}")
}
}).asConfirm("Confirm", "Are you sure to exit?") {
}.setConfirmText("OK").setCancelText("Cancel")
xPopup.show()
textView.postDelayed({
if (xPopup.isShow) {
xPopup.dismiss()
}
}, 500)
}
}
zhuzhao404 commented
#929
之前也有人提过这个问题