mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 05:25:08 +01:00
Keeping a private static list of recents for recreation of recents controller
This commit is contained in:
parent
ed3e819829
commit
0b0f985e24
@ -69,7 +69,6 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
private var adapter = RecentMangaAdapter(this)
|
||||
|
||||
private var presenter = RecentsPresenter(this)
|
||||
private var recentItems: List<RecentMangaItem>? = null
|
||||
private var snack: Snackbar? = null
|
||||
private var lastChapterId: Long? = null
|
||||
private var showingDownloads = false
|
||||
@ -112,8 +111,8 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
headerHeight = it.systemWindowInsetTop + appBarHeight
|
||||
}
|
||||
|
||||
if (recentItems != null) adapter.updateDataSet(recentItems!!.toList())
|
||||
presenter.onCreate()
|
||||
if (presenter.recentItems.isNotEmpty()) adapter.updateDataSet(presenter.recentItems)
|
||||
|
||||
dl_bottom_sheet.onCreate(this)
|
||||
|
||||
@ -217,7 +216,6 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
|
||||
fun showLists(recents: List<RecentMangaItem>) {
|
||||
swipe_refresh.isRefreshing = LibraryUpdateService.isRunning()
|
||||
recentItems = recents
|
||||
adapter.updateDataSet(recents)
|
||||
if (lastChapterId != null) {
|
||||
refreshItem(lastChapterId ?: 0L)
|
||||
|
@ -36,7 +36,8 @@ class RecentsPresenter(
|
||||
|
||||
private var scope = CoroutineScope(Job() + Dispatchers.Default)
|
||||
|
||||
private var recentItems = listOf<RecentMangaItem>()
|
||||
var recentItems = listOf<RecentMangaItem>()
|
||||
private set
|
||||
var query = ""
|
||||
private val newAdditionsHeader = RecentMangaHeaderItem(RecentMangaHeaderItem.NEWLY_ADDED)
|
||||
private val newChaptersHeader = RecentMangaHeaderItem(RecentMangaHeaderItem.NEW_CHAPTERS)
|
||||
@ -48,6 +49,11 @@ class RecentsPresenter(
|
||||
fun onCreate() {
|
||||
downloadManager.addListener(this)
|
||||
LibraryUpdateService.setListener(this)
|
||||
if (lastRecents != null) {
|
||||
if (recentItems.isEmpty())
|
||||
recentItems = lastRecents ?: emptyList()
|
||||
lastRecents = null
|
||||
}
|
||||
getRecents()
|
||||
}
|
||||
|
||||
@ -170,6 +176,7 @@ class RecentsPresenter(
|
||||
fun onDestroy() {
|
||||
downloadManager.removeListener(this)
|
||||
LibraryUpdateService.removeListener(this)
|
||||
lastRecents = recentItems
|
||||
}
|
||||
|
||||
fun cancelScope() {
|
||||
@ -264,4 +271,8 @@ class RecentsPresenter(
|
||||
getRecents()
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
var lastRecents: List<RecentMangaItem>? = null
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user