Fix / clear on detached

This commit is contained in:
Valere 2020-06-26 09:44:51 +02:00 committed by Benoit Marty
parent f5c1ad8f2a
commit 7ed9f535e6
3 changed files with 6 additions and 4 deletions

View File

@ -27,8 +27,6 @@ import javax.inject.Inject
class DefaultContentDownloadStateTracker @Inject constructor() : ProgressListener, ContentDownloadStateTracker { class DefaultContentDownloadStateTracker @Inject constructor() : ProgressListener, ContentDownloadStateTracker {
private val mainHandler = Handler(Looper.getMainLooper()) private val mainHandler = Handler(Looper.getMainLooper())
// TODO this will grow undefinitly..
private val states = mutableMapOf<String, ContentDownloadStateTracker.State>() private val states = mutableMapOf<String, ContentDownloadStateTracker.State>()
private val listeners = mutableMapOf<String, MutableList<ContentDownloadStateTracker.UpdateListener>>() private val listeners = mutableMapOf<String, MutableList<ContentDownloadStateTracker.UpdateListener>>()
@ -54,6 +52,7 @@ class DefaultContentDownloadStateTracker @Inject constructor() : ProgressListene
} }
override fun clear() { override fun clear() {
states.clear()
listeners.clear() listeners.clear()
} }

View File

@ -41,6 +41,7 @@ import im.vector.riotx.features.home.room.detail.RoomDetailViewState
import im.vector.riotx.features.home.room.detail.UnreadState import im.vector.riotx.features.home.room.detail.UnreadState
import im.vector.riotx.features.home.room.detail.timeline.factory.MergedHeaderItemFactory import im.vector.riotx.features.home.room.detail.timeline.factory.MergedHeaderItemFactory
import im.vector.riotx.features.home.room.detail.timeline.factory.TimelineItemFactory import im.vector.riotx.features.home.room.detail.timeline.factory.TimelineItemFactory
import im.vector.riotx.features.home.room.detail.timeline.helper.ContentDownloadStateTrackerBinder
import im.vector.riotx.features.home.room.detail.timeline.helper.ContentUploadStateTrackerBinder import im.vector.riotx.features.home.room.detail.timeline.helper.ContentUploadStateTrackerBinder
import im.vector.riotx.features.home.room.detail.timeline.helper.ReadMarkerVisibilityStateChangedListener import im.vector.riotx.features.home.room.detail.timeline.helper.ReadMarkerVisibilityStateChangedListener
import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineEventDiffUtilCallback import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineEventDiffUtilCallback
@ -60,6 +61,7 @@ import javax.inject.Inject
class TimelineEventController @Inject constructor(private val dateFormatter: VectorDateFormatter, class TimelineEventController @Inject constructor(private val dateFormatter: VectorDateFormatter,
private val contentUploadStateTrackerBinder: ContentUploadStateTrackerBinder, private val contentUploadStateTrackerBinder: ContentUploadStateTrackerBinder,
private val contentDownloadStateTrackerBinder: ContentDownloadStateTrackerBinder,
private val timelineItemFactory: TimelineItemFactory, private val timelineItemFactory: TimelineItemFactory,
private val timelineMediaSizeProvider: TimelineMediaSizeProvider, private val timelineMediaSizeProvider: TimelineMediaSizeProvider,
private val mergedHeaderItemFactory: MergedHeaderItemFactory, private val mergedHeaderItemFactory: MergedHeaderItemFactory,
@ -227,6 +229,7 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) { override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
timelineMediaSizeProvider.recyclerView = null timelineMediaSizeProvider.recyclerView = null
contentUploadStateTrackerBinder.clear() contentUploadStateTrackerBinder.clear()
contentDownloadStateTrackerBinder.clear()
timeline?.removeListener(this) timeline?.removeListener(this)
super.onDetachedFromRecyclerView(recyclerView) super.onDetachedFromRecyclerView(recyclerView)
} }

View File

@ -57,7 +57,7 @@ class ContentDownloadStateTrackerBinder @Inject constructor(private val activeSe
fun clear() { fun clear() {
activeSessionHolder.getSafeActiveSession()?.also { activeSessionHolder.getSafeActiveSession()?.also {
it.contentUploadProgressTracker().clear() it.contentDownloadProgressTracker().clear()
} }
} }
} }
@ -76,7 +76,7 @@ private class ContentDownloadUpdater(private val holder: MessageFileItem.Holder,
} }
} }
private var animatedDrawable: AnimatedVectorDrawableCompat? = null private var animatedDrawable: AnimatedVectorDrawableCompat? = null
private var animationLoopCallback = object : Animatable2Compat.AnimationCallback() { private var animationLoopCallback = object : Animatable2Compat.AnimationCallback() {
override fun onAnimationEnd(drawable: Drawable?) { override fun onAnimationEnd(drawable: Drawable?) {
animatedDrawable?.start() animatedDrawable?.start()