Removing launchUI from library presenter

Also fixed library not having an alpha when coming to the screen from restoring
This commit is contained in:
Jay 2020-04-22 00:27:23 -04:00
parent 4e54690229
commit efb28e21a7
2 changed files with 37 additions and 30 deletions

View File

@ -495,7 +495,8 @@ class LibraryController(
justStarted = false
if (recycler_layout.alpha == 0f) recycler_layout.animate().alpha(1f).setDuration(500)
.start()
} else if (justStarted && freshStart) {
} else recycler_layout.alpha = 1f
if (justStarted && freshStart) {
scrollToHeader(activeCategory)
fast_scroller.translationX = 0f
view?.post {

View File

@ -18,7 +18,6 @@ import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
import eu.kanade.tachiyomi.util.lang.removeArticles
import eu.kanade.tachiyomi.util.system.executeOnIO
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_EXCLUDE
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_IGNORE
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_INCLUDE
@ -82,23 +81,22 @@ class LibraryPresenter(
/** Get favorited manga for library and sort and filter it */
fun getLibrary() {
launchUI {
scope.launch {
totalChapters = null
val mangaMap = withContext(Dispatchers.IO) {
val library = getLibraryFromDB()
library.apply {
setDownloadCount(library)
setUnreadBadge(library)
}
allLibraryItems = library
var mangaMap = library
mangaMap = applyFilters(mangaMap)
mangaMap = applySort(mangaMap)
mangaMap
val library = withContext(Dispatchers.IO) { getLibraryFromDB() }
library.apply {
setDownloadCount(library)
setUnreadBadge(library)
}
allLibraryItems = library
var mangaMap = library
mangaMap = applyFilters(mangaMap)
mangaMap = applySort(mangaMap)
val freshStart = libraryItems.isEmpty()
libraryItems = mangaMap
view.onNextLibraryUpdate(libraryItems, freshStart)
withContext(Dispatchers.Main) {
view.onNextLibraryUpdate(libraryItems, freshStart)
}
withContext(Dispatchers.IO) {
setTotalChapters()
}
@ -473,48 +471,56 @@ class LibraryPresenter(
/** Requests the library to be filtered. */
fun requestFilterUpdate() {
launchUI {
scope.launch {
var mangaMap = allLibraryItems
mangaMap = withContext(Dispatchers.IO) { applyFilters(mangaMap) }
mangaMap = withContext(Dispatchers.IO) { applySort(mangaMap) }
mangaMap = applyFilters(mangaMap)
mangaMap = applySort(mangaMap)
libraryItems = mangaMap
view.onNextLibraryUpdate(libraryItems)
withContext(Dispatchers.Main) {
view.onNextLibraryUpdate(libraryItems)
}
}
}
/** Requests the library to have download badges added/removed. */
fun requestDownloadBadgesUpdate() {
launchUI {
scope.launch {
val mangaMap = allLibraryItems
withContext(Dispatchers.IO) { setDownloadCount(mangaMap) }
setDownloadCount(mangaMap)
allLibraryItems = mangaMap
val current = libraryItems
withContext(Dispatchers.IO) { setDownloadCount(current) }
setDownloadCount(current)
libraryItems = current
view.onNextLibraryUpdate(libraryItems)
withContext(Dispatchers.Main) {
view.onNextLibraryUpdate(libraryItems)
}
}
}
/** Requests the library to have unread badges changed. */
fun requestUnreadBadgesUpdate() {
launchUI {
scope.launch {
val mangaMap = allLibraryItems
withContext(Dispatchers.IO) { setUnreadBadge(mangaMap) }
setUnreadBadge(mangaMap)
allLibraryItems = mangaMap
val current = libraryItems
withContext(Dispatchers.IO) { setUnreadBadge(current) }
setUnreadBadge(current)
libraryItems = current
view.onNextLibraryUpdate(libraryItems)
withContext(Dispatchers.Main) {
view.onNextLibraryUpdate(libraryItems)
}
}
}
/** Requests the library to be sorted. */
private fun requestSortUpdate() {
launchUI {
scope.launch {
var mangaMap = libraryItems
mangaMap = withContext(Dispatchers.IO) { applySort(mangaMap) }
mangaMap = applySort(mangaMap)
libraryItems = mangaMap
view.onNextLibraryUpdate(libraryItems)
withContext(Dispatchers.Main) {
view.onNextLibraryUpdate(libraryItems)
}
}
}