Commit 2f6f80ea authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Release markdown images on RecyclerView detach/recycle lifecycle.

parent ba1a92ba
......@@ -34,8 +34,19 @@ class TargetHeaderAdapterDelegate(
position: Int,
viewHolder: RecyclerView.ViewHolder,
payloads: MutableList<Any>
) =
(viewHolder as ViewHolder).bind(items[position] as TargetHeader)
) = (viewHolder as ViewHolder).bind(items[position] as TargetHeader)
override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) {
super.onViewDetachedFromWindow(holder)
(holder as ViewHolder).release()
}
override fun onViewRecycled(viewHolder: RecyclerView.ViewHolder) {
super.onViewRecycled(viewHolder)
(viewHolder as ViewHolder).release()
}
private inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private lateinit var item: TargetHeader
......@@ -131,5 +142,7 @@ class TargetHeaderAdapterDelegate(
}
}
}
fun release() = Markwon.unscheduleDrawables(itemView.descriptionTextView)
}
}
\ No newline at end of file
......@@ -29,8 +29,19 @@ class UserNoteAdapterDelegate(private val clickListener: (Note) -> Unit) : Adapt
position: Int,
viewHolder: RecyclerView.ViewHolder,
payloads: MutableList<Any>
) =
(viewHolder as ViewHolder).bind(items[position] as NoteWithFormattedBody)
) = (viewHolder as ViewHolder).bind(items[position] as NoteWithFormattedBody)
override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) {
super.onViewDetachedFromWindow(holder)
(holder as ViewHolder).release()
}
override fun onViewRecycled(viewHolder: RecyclerView.ViewHolder) {
super.onViewRecycled(viewHolder)
(viewHolder as ViewHolder).release()
}
private inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
private lateinit var note: Note
......@@ -48,5 +59,7 @@ class UserNoteAdapterDelegate(private val clickListener: (Note) -> Unit) : Adapt
Markwon.setText(descriptionTextView, data.body)
}
}
fun release() = Markwon.unscheduleDrawables(itemView.descriptionTextView)
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment