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 justStarted = false
if (recycler_layout.alpha == 0f) recycler_layout.animate().alpha(1f).setDuration(500) if (recycler_layout.alpha == 0f) recycler_layout.animate().alpha(1f).setDuration(500)
.start() .start()
} else if (justStarted && freshStart) { } else recycler_layout.alpha = 1f
if (justStarted && freshStart) {
scrollToHeader(activeCategory) scrollToHeader(activeCategory)
fast_scroller.translationX = 0f fast_scroller.translationX = 0f
view?.post { 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.ui.library.filter.FilterBottomSheet
import eu.kanade.tachiyomi.util.lang.removeArticles import eu.kanade.tachiyomi.util.lang.removeArticles
import eu.kanade.tachiyomi.util.system.executeOnIO 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_EXCLUDE
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_IGNORE import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_IGNORE
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.Companion.STATE_INCLUDE 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 */ /** Get favorited manga for library and sort and filter it */
fun getLibrary() { fun getLibrary() {
launchUI { scope.launch {
totalChapters = null totalChapters = null
val mangaMap = withContext(Dispatchers.IO) { val library = withContext(Dispatchers.IO) { getLibraryFromDB() }
val library = getLibraryFromDB() library.apply {
library.apply { setDownloadCount(library)
setDownloadCount(library) setUnreadBadge(library)
setUnreadBadge(library)
}
allLibraryItems = library
var mangaMap = library
mangaMap = applyFilters(mangaMap)
mangaMap = applySort(mangaMap)
mangaMap
} }
allLibraryItems = library
var mangaMap = library
mangaMap = applyFilters(mangaMap)
mangaMap = applySort(mangaMap)
val freshStart = libraryItems.isEmpty() val freshStart = libraryItems.isEmpty()
libraryItems = mangaMap libraryItems = mangaMap
view.onNextLibraryUpdate(libraryItems, freshStart) withContext(Dispatchers.Main) {
view.onNextLibraryUpdate(libraryItems, freshStart)
}
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
setTotalChapters() setTotalChapters()
} }
@ -473,48 +471,56 @@ class LibraryPresenter(
/** Requests the library to be filtered. */ /** Requests the library to be filtered. */
fun requestFilterUpdate() { fun requestFilterUpdate() {
launchUI { scope.launch {
var mangaMap = allLibraryItems var mangaMap = allLibraryItems
mangaMap = withContext(Dispatchers.IO) { applyFilters(mangaMap) } mangaMap = applyFilters(mangaMap)
mangaMap = withContext(Dispatchers.IO) { applySort(mangaMap) } mangaMap = applySort(mangaMap)
libraryItems = mangaMap libraryItems = mangaMap
view.onNextLibraryUpdate(libraryItems) withContext(Dispatchers.Main) {
view.onNextLibraryUpdate(libraryItems)
}
} }
} }
/** Requests the library to have download badges added/removed. */ /** Requests the library to have download badges added/removed. */
fun requestDownloadBadgesUpdate() { fun requestDownloadBadgesUpdate() {
launchUI { scope.launch {
val mangaMap = allLibraryItems val mangaMap = allLibraryItems
withContext(Dispatchers.IO) { setDownloadCount(mangaMap) } setDownloadCount(mangaMap)
allLibraryItems = mangaMap allLibraryItems = mangaMap
val current = libraryItems val current = libraryItems
withContext(Dispatchers.IO) { setDownloadCount(current) } setDownloadCount(current)
libraryItems = current libraryItems = current
view.onNextLibraryUpdate(libraryItems) withContext(Dispatchers.Main) {
view.onNextLibraryUpdate(libraryItems)
}
} }
} }
/** Requests the library to have unread badges changed. */ /** Requests the library to have unread badges changed. */
fun requestUnreadBadgesUpdate() { fun requestUnreadBadgesUpdate() {
launchUI { scope.launch {
val mangaMap = allLibraryItems val mangaMap = allLibraryItems
withContext(Dispatchers.IO) { setUnreadBadge(mangaMap) } setUnreadBadge(mangaMap)
allLibraryItems = mangaMap allLibraryItems = mangaMap
val current = libraryItems val current = libraryItems
withContext(Dispatchers.IO) { setUnreadBadge(current) } setUnreadBadge(current)
libraryItems = current libraryItems = current
view.onNextLibraryUpdate(libraryItems) withContext(Dispatchers.Main) {
view.onNextLibraryUpdate(libraryItems)
}
} }
} }
/** Requests the library to be sorted. */ /** Requests the library to be sorted. */
private fun requestSortUpdate() { private fun requestSortUpdate() {
launchUI { scope.launch {
var mangaMap = libraryItems var mangaMap = libraryItems
mangaMap = withContext(Dispatchers.IO) { applySort(mangaMap) } mangaMap = applySort(mangaMap)
libraryItems = mangaMap libraryItems = mangaMap
view.onNextLibraryUpdate(libraryItems) withContext(Dispatchers.Main) {
view.onNextLibraryUpdate(libraryItems)
}
} }
} }