diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/pager/webtoon/WebtoonRecyclerView.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/pager/webtoon/WebtoonRecyclerView.kt index 4ec3edaa6..a8c0ff2e4 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/pager/webtoon/WebtoonRecyclerView.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/pager/webtoon/WebtoonRecyclerView.kt @@ -8,17 +8,18 @@ import androidx.core.view.forEach import androidx.recyclerview.widget.RecyclerView import org.koitharu.kotatsu.core.util.ext.findCenterViewPosition import java.util.LinkedList +import java.util.WeakHashMap class WebtoonRecyclerView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : RecyclerView(context, attrs, defStyleAttr) { private var onPageScrollListeners: MutableList? = null - private val detachedViews = ArrayList() + private val detachedViews = WeakHashMap() override fun onChildDetachedFromWindow(child: View) { super.onChildDetachedFromWindow(child) - detachedViews.add(child) + detachedViews[child] = Unit } override fun onChildAttachedToWindow(child: View) { @@ -115,7 +116,7 @@ class WebtoonRecyclerView @JvmOverloads constructor( forEach { child -> (child as WebtoonFrameLayout).target.requestLayout() } - detachedViews.forEach {child -> + detachedViews.keys.forEach { child -> (child as WebtoonFrameLayout).target.requestLayout() } }