Fix clear glide in recycler view
This commit is contained in:
parent
31eccf5f1c
commit
5f76f182f6
|
@ -23,7 +23,6 @@ import android.widget.ImageView
|
|||
import android.widget.LinearLayout
|
||||
import androidx.core.view.isVisible
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.glide.GlideApp
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.timeline.item.ReadReceiptData
|
||||
import im.vector.app.features.home.room.detail.timeline.item.toMatrixItem
|
||||
|
@ -113,9 +112,9 @@ class ReadReceiptsView @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun unbind() {
|
||||
fun unbind(avatarRenderer: AvatarRenderer?) {
|
||||
receiptAvatars.forEach {
|
||||
GlideApp.with(context.applicationContext).clear(it)
|
||||
avatarRenderer?.clear(it)
|
||||
}
|
||||
isVisible = false
|
||||
}
|
||||
|
|
|
@ -56,6 +56,11 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active
|
|||
DrawableImageViewTarget(imageView))
|
||||
}
|
||||
|
||||
fun clear(imageView: ImageView) {
|
||||
// It can be called after recycler view is destroyed, just silently catch
|
||||
tryThis { GlideApp.with(imageView).clear(imageView) }
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun render(matrixItem: MatrixItem, imageView: ImageView, glideRequests: GlideRequests) {
|
||||
render(imageView.context,
|
||||
|
|
|
@ -110,7 +110,7 @@ abstract class AbsBaseMessageItem<H : AbsBaseMessageItem.Holder> : BaseEventItem
|
|||
|
||||
override fun unbind(holder: H) {
|
||||
holder.reactionsContainer.setOnLongClickListener(null)
|
||||
holder.readReceiptsView.unbind()
|
||||
holder.readReceiptsView.unbind(baseAttributes.avatarRenderer)
|
||||
super.unbind(holder)
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ abstract class AbsMessageItem<H : AbsMessageItem.Holder> : AbsBaseMessageItem<H>
|
|||
}
|
||||
|
||||
override fun unbind(holder: H) {
|
||||
attributes.avatarRenderer.clear(holder.avatarImageView)
|
||||
holder.avatarImageView.setOnClickListener(null)
|
||||
holder.avatarImageView.setOnLongClickListener(null)
|
||||
holder.memberNameView.setOnClickListener(null)
|
||||
|
|
|
@ -44,6 +44,12 @@ abstract class DefaultItem : BaseEventItem<DefaultItem.Holder>() {
|
|||
holder.readReceiptsView.render(attributes.informationData.readReceipts, attributes.avatarRenderer, _readReceiptsClickListener)
|
||||
}
|
||||
|
||||
override fun unbind(holder: Holder) {
|
||||
attributes.avatarRenderer.clear(holder.avatarImageView)
|
||||
holder.readReceiptsView.unbind(attributes.avatarRenderer)
|
||||
super.unbind(holder)
|
||||
}
|
||||
|
||||
override fun getEventIds(): List<String> {
|
||||
return listOf(attributes.informationData.eventId)
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
|
|||
|
||||
override fun unbind(holder: Holder) {
|
||||
GlideApp.with(holder.view.context.applicationContext).clear(holder.imageView)
|
||||
imageContentRenderer.clear(holder.imageView)
|
||||
contentUploadStateTrackerBinder.unbind(attributes.informationData.eventId)
|
||||
holder.imageView.setOnClickListener(null)
|
||||
holder.imageView.setOnLongClickListener(null)
|
||||
|
|
|
@ -60,6 +60,12 @@ abstract class NoticeItem : BaseEventItem<NoticeItem.Holder>() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun unbind(holder: Holder) {
|
||||
attributes.avatarRenderer.clear(holder.avatarImageView)
|
||||
holder.readReceiptsView.unbind(attributes.avatarRenderer)
|
||||
super.unbind(holder)
|
||||
}
|
||||
|
||||
override fun getEventIds(): List<String> {
|
||||
return listOf(attributes.informationData.eventId)
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel<RoomSummaryItem.Holder>() {
|
|||
override fun unbind(holder: Holder) {
|
||||
holder.rootView.setOnClickListener(null)
|
||||
holder.rootView.setOnLongClickListener(null)
|
||||
avatarRenderer.clear(holder.avatarImageView)
|
||||
super.unbind(holder)
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,15 @@ class ImageContentRenderer @Inject constructor(private val activeSessionHolder:
|
|||
.into(imageView)
|
||||
}
|
||||
|
||||
fun clear(imageView: ImageView) {
|
||||
// It can be called after recycler view is destroyed, just silently catch
|
||||
// We'd better keep ref to requestManager, but we don't have it
|
||||
tryThis {
|
||||
GlideApp
|
||||
.with(imageView).clear(imageView)
|
||||
}
|
||||
}
|
||||
|
||||
fun render(data: Data, contextView: View, target: CustomViewTarget<*, Drawable>) {
|
||||
val req = if (data.elementToDecrypt != null) {
|
||||
// Encrypted image
|
||||
|
|
Loading…
Reference in New Issue