From f007fb04b8f54abb7f0276f41453da93838ed0ad Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 10 Jul 2019 16:40:32 +0200 Subject: [PATCH] Timeline: clean listeners --- .../internal/session/room/timeline/DefaultTimeline.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt index 3925adf190..87f78224cd 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt @@ -43,7 +43,7 @@ import kotlin.collections.ArrayList import kotlin.collections.HashMap -private const val INITIAL_LOAD_SIZE = 20 +private const val INITIAL_LOAD_SIZE = 10 private const val MIN_FETCHING_COUNT = 30 private const val DISPLAY_INDEX_UNKNOWN = Int.MIN_VALUE @@ -216,6 +216,7 @@ internal class DefaultTimeline( backgroundRealm.set(realm) clearUnlinkedEvents(realm) + roomEntity = RoomEntity.where(realm, roomId = roomId).findFirst()?.also { it.sendingTimelineEvents.addChangeListener { _ -> postSnapshot() @@ -242,6 +243,8 @@ internal class DefaultTimeline( Timber.v("Dispose timeline for roomId: $roomId and eventId: $initialEventId") BACKGROUND_HANDLER.post { cancelableBag.cancel() + roomEntity?.sendingTimelineEvents?.removeAllChangeListeners() + eventRelations.removeAllChangeListeners() liveEvents.removeAllChangeListeners() backgroundRealm.getAndSet(null).also { it.close()