TP-63087 | open keyboard NPE crash fix (#10379)

This commit is contained in:
Varun Jain
2024-04-09 18:55:36 +05:30
committed by GitHub
parent 73f9368d3e
commit 570b2d21cf

View File

@@ -16,9 +16,11 @@ import android.view.inputmethod.InputMethodManager
fun openKeyboard(context: Context? = null, view: View, onFinish: () -> Unit) {
post(view = view, delay = ANIMATION_DURATION) {
val imm = context?.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT)
post(view = view, delay = ANIMATION_DURATION, task = onFinish)
context?.let {
val imm = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as? InputMethodManager
imm?.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT)
post(view = view, delay = ANIMATION_DURATION, task = onFinish)
}
}
}