TP-63087 | Null context crash fix (#10327)
This commit is contained in:
@@ -368,9 +368,9 @@ class NaviChatFragment : BaseFragment(), WidgetCallback, MessageOperation, Toolb
|
||||
binding.clFreeText.isVisible = (showFreeText)
|
||||
if (showFreeText) {
|
||||
binding.etFreeText.requestFocus()
|
||||
openKeyboard(context = requireContext(), view = binding.etFreeText) {}
|
||||
openKeyboard(context = context, view = binding.etFreeText) {}
|
||||
} else {
|
||||
hideKeyboard(context = requireContext(), view = binding.etFreeText)
|
||||
hideKeyboard(context = context, view = binding.etFreeText)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -897,9 +897,9 @@ class NaviChatFragment : BaseFragment(), WidgetCallback, MessageOperation, Toolb
|
||||
binding.clFreeText.isVisible = it
|
||||
if (it) {
|
||||
binding.etFreeText.requestFocus()
|
||||
openKeyboard(context = requireContext(), view = binding.etFreeText) {}
|
||||
openKeyboard(context = context, view = binding.etFreeText) {}
|
||||
} else {
|
||||
hideKeyboard(context = requireContext(), view = binding.etFreeText)
|
||||
hideKeyboard(context = context, view = binding.etFreeText)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1606,14 +1606,14 @@ class NaviChatFragment : BaseFragment(), WidgetCallback, MessageOperation, Toolb
|
||||
if (binding.clFreeText.visibility == GONE) {
|
||||
binding.clFreeText.isVisible = true
|
||||
binding.etFreeText.requestFocus()
|
||||
openKeyboard(context = requireContext(), view = binding.etFreeText) {
|
||||
openKeyboard(context = context, view = binding.etFreeText) {
|
||||
scrollChatToLatestMessageReceived()
|
||||
}
|
||||
}
|
||||
}
|
||||
NaviChatControllerEnum.DISABLE_FREE_TEXT.name -> {
|
||||
binding.clFreeText.isVisible = false
|
||||
hideKeyboard(context = requireContext(), view = binding.etFreeText)
|
||||
hideKeyboard(context = context, view = binding.etFreeText)
|
||||
}
|
||||
}
|
||||
naviChatControllerWidget.widgetData?.controllerConfig?.let { config ->
|
||||
|
||||
@@ -22,8 +22,8 @@ fun openKeyboard(context: Context? = null, view: View, onFinish: () -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
fun hideKeyboard(context: Context, view: View) {
|
||||
(context.getSystemService(Activity.INPUT_METHOD_SERVICE) as? InputMethodManager)?.apply {
|
||||
fun hideKeyboard(context: Context?, view: View) {
|
||||
(context?.getSystemService(Activity.INPUT_METHOD_SERVICE) as? InputMethodManager)?.apply {
|
||||
hideSoftInputFromWindow(view.windowToken, 0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user