mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 04:15:09 +01:00
Refactoring RecentMangaAdapter + removing recents header while searching
This commit is contained in:
parent
0545780ae9
commit
f264a69626
@ -1,6 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.ui.recents
|
package eu.kanade.tachiyomi.ui.recents
|
||||||
|
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
|
import com.tfcporciuncula.flow.Preference
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterAdapter
|
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterAdapter
|
||||||
@ -32,24 +33,15 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
setDisplayHeadersAtStartUp(true)
|
setDisplayHeadersAtStartUp(true)
|
||||||
preferences.showRecentsDownloads()
|
preferences.showRecentsDownloads().register { showDownloads = it }
|
||||||
.asFlow()
|
preferences.showRecentsRemHistory().register { showRemoveHistory = it }
|
||||||
.onEach {
|
preferences.showTitleFirstInRecents().register { showTitleFirst = it }
|
||||||
showDownloads = it
|
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
}
|
||||||
.launchIn(delegate.scope())
|
|
||||||
preferences.showRecentsRemHistory()
|
private fun <T> Preference<T>.register(onChanged: (T) -> Unit) {
|
||||||
.asFlow()
|
asFlow()
|
||||||
.onEach {
|
.onEach {
|
||||||
showRemoveHistory = it
|
onChanged(it)
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
.launchIn(delegate.scope())
|
|
||||||
preferences.showTitleFirstInRecents()
|
|
||||||
.asFlow()
|
|
||||||
.onEach {
|
|
||||||
showTitleFirst = it
|
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
.launchIn(delegate.scope())
|
.launchIn(delegate.scope())
|
||||||
|
@ -149,10 +149,8 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
presenter.onCreate()
|
presenter.onCreate()
|
||||||
if (presenter.recentItems.isNotEmpty()) {
|
if (presenter.recentItems.isNotEmpty()) {
|
||||||
adapter.updateDataSet(presenter.recentItems)
|
adapter.updateDataSet(presenter.recentItems)
|
||||||
if (presenter.viewType > 0) {
|
|
||||||
adapter.addScrollableHeader(presenter.generalHeader)
|
adapter.addScrollableHeader(presenter.generalHeader)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
binding.downloadBottomSheet.dlBottomSheet.onCreate(this)
|
binding.downloadBottomSheet.dlBottomSheet.onCreate(this)
|
||||||
|
|
||||||
@ -305,11 +303,11 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
binding.swipeRefresh.isRefreshing = LibraryUpdateService.isRunning()
|
binding.swipeRefresh.isRefreshing = LibraryUpdateService.isRunning()
|
||||||
adapter.updateItems(recents)
|
adapter.updateItems(recents)
|
||||||
adapter.headerItems.forEach {
|
adapter.headerItems.forEach {
|
||||||
if (it != presenter.generalHeader) {
|
if (it != presenter.generalHeader || presenter.query.isNotEmpty()) {
|
||||||
adapter.removeScrollableHeader(it)
|
adapter.removeScrollableHeader(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!adapter.headerItems.any { it === presenter.generalHeader }) {
|
if (presenter.query.isEmpty() && !adapter.headerItems.any { it === presenter.generalHeader }) {
|
||||||
adapter.addScrollableHeader(presenter.generalHeader)
|
adapter.addScrollableHeader(presenter.generalHeader)
|
||||||
}
|
}
|
||||||
adapter.onLoadMoreComplete(null)
|
adapter.onLoadMoreComplete(null)
|
||||||
|
Loading…
Reference in New Issue
Block a user