Fixed fading out of header every time an item is selected in single list mode

This commit is contained in:
Jay 2020-02-22 17:35:23 -08:00
parent 8379c69874
commit 0337181b08

View File

@ -263,6 +263,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
}
override fun setSelection(manga: Manga, selected: Boolean) {
val currentMode = adapter.mode
if (selected) {
if (selectedMangas.add(manga)) {
val positions = adapter.allIndexOf(manga)
@ -292,13 +293,18 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
}
}
}
updateHeaders()
updateHeaders(currentMode != adapter.mode)
}
fun updateHeaders() {
private fun updateHeaders(changedMode: Boolean = false) {
val headerPositions = adapter.getHeaderPositions()
headerPositions.forEach {
adapter.notifyItemChanged(it)
if (changedMode) {
adapter.notifyItemChanged(it)
}
else {
(recycler.findViewHolderForAdapterPosition(it) as? LibraryHeaderItem.Holder)?.setSelection()
}
}
}