Fixed global layout listener never removed if binding is not available
This commit is contained in:
parent
2ed862426e
commit
fcd0779507
1 changed files with 4 additions and 3 deletions
|
@ -746,10 +746,11 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
||||||
.addOnGlobalLayoutListener(
|
.addOnGlobalLayoutListener(
|
||||||
object : OnGlobalLayoutListener {
|
object : OnGlobalLayoutListener {
|
||||||
override fun onGlobalLayout() {
|
override fun onGlobalLayout() {
|
||||||
|
binding.chatMessagesList
|
||||||
|
.viewTreeObserver
|
||||||
|
.removeOnGlobalLayoutListener(this)
|
||||||
|
|
||||||
if (isBindingAvailable()) {
|
if (isBindingAvailable()) {
|
||||||
binding.chatMessagesList
|
|
||||||
.viewTreeObserver
|
|
||||||
.removeOnGlobalLayoutListener(this)
|
|
||||||
if (::chatScrollListener.isInitialized) {
|
if (::chatScrollListener.isInitialized) {
|
||||||
binding.chatMessagesList.addOnScrollListener(chatScrollListener)
|
binding.chatMessagesList.addOnScrollListener(chatScrollListener)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue