Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Conversation

@Goooler
Copy link
Owner

@Goooler Goooler commented Jun 21, 2022

@Goooler Goooler added this to the 1.6.0 milestone Jun 21, 2022
Comment on lines -30 to -35
fun View.dispatchBackPress() {
isFocusableInTouchMode = true
requestFocus()
setOnKeyListener { _, keyCode, event ->
val flag = keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_UP
if (flag) onBackPressed() else false
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added OnKeyListener on Fragment's contentView, if contentView lost focus, this callback is useless.

@Goooler Goooler merged commit c6b29be into trunk Jun 22, 2022
@Goooler Goooler deleted the back_dispatcher branch June 22, 2022 02:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants