mirror of https://github.com/tasks/tasks
Fix some back handlers
parent
ab02323f29
commit
738bf435db
@ -1,10 +1,23 @@
|
||||
package org.tasks.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import org.tasks.extensions.Context.hideKeyboard
|
||||
|
||||
fun Activity.hideKeyboard() {
|
||||
currentFocus?.let {
|
||||
hideKeyboard(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun ComponentActivity.addBackPressedCallback(block: () -> Unit) {
|
||||
onBackPressedDispatcher.addCallback(
|
||||
this,
|
||||
object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
block()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue