mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-12 10:32:36 +00:00
Handle async call back to already destroyed UI
Fixes #1426 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
c4ca802408
commit
73e96198de
@ -602,7 +602,9 @@ class ChatController(args: Bundle) :
|
|||||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||||
|
try {
|
||||||
if (s.length >= lengthFilter) {
|
if (s.length >= lengthFilter) {
|
||||||
binding.messageInputView.inputEditText?.error = String.format(
|
binding.messageInputView.inputEditText?.error = String.format(
|
||||||
Objects.requireNonNull<Resources>(resources).getString(R.string.nc_limit_hit),
|
Objects.requireNonNull<Resources>(resources).getString(R.string.nc_limit_hit),
|
||||||
@ -621,7 +623,9 @@ class ChatController(args: Bundle) :
|
|||||||
var mentionSpan: Spans.MentionChipSpan
|
var mentionSpan: Spans.MentionChipSpan
|
||||||
for (i in mentionSpans.indices) {
|
for (i in mentionSpans.indices) {
|
||||||
mentionSpan = mentionSpans[i]
|
mentionSpan = mentionSpans[i]
|
||||||
if (start >= editable.getSpanStart(mentionSpan) && start < editable.getSpanEnd(mentionSpan)) {
|
if (start >= editable.getSpanStart(mentionSpan) &&
|
||||||
|
start < editable.getSpanEnd(mentionSpan)
|
||||||
|
) {
|
||||||
if (editable.subSequence(
|
if (editable.subSequence(
|
||||||
editable.getSpanStart(mentionSpan),
|
editable.getSpanStart(mentionSpan),
|
||||||
editable.getSpanEnd(mentionSpan)
|
editable.getSpanEnd(mentionSpan)
|
||||||
@ -632,6 +636,11 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (npe: NullPointerException) {
|
||||||
|
// view binding can be null
|
||||||
|
// since this is called asynchrously and UI might have been destroyed in the meantime
|
||||||
|
Log.i(TAG, "UI destroyed - view binding already gone")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable) {
|
override fun afterTextChanged(s: Editable) {
|
||||||
|
Loading…
Reference in New Issue
Block a user