Readded refresh button for single category libraries

Long pressing the library icon now updates the ui on library and recents
This commit is contained in:
Jay 2020-04-30 00:29:39 -04:00
parent 6e99caf458
commit 2e4af90b63
4 changed files with 19 additions and 12 deletions

View File

@ -241,14 +241,15 @@ class LibraryUpdateService(
} else {
val categoriesToUpdate =
preferences.libraryUpdateCategories().getOrDefault().map(String::toInt)
if (categoriesToUpdate.isNotEmpty()) {
categoryIds.addAll(categoriesToUpdate)
if (categoriesToUpdate.isNotEmpty())
db.getLibraryMangas().executeAsBlocking()
.filter { it.category in categoriesToUpdate }
.distinctBy { it.id }
else
.filter { it.category in categoriesToUpdate }.distinctBy { it.id }
} else {
categoryIds.addAll(db.getCategories().executeAsBlocking().mapNotNull { it.id } + 0)
db.getLibraryMangas().executeAsBlocking().distinctBy { it.id }
}
}
if (target == Target.CHAPTERS && preferences.updateOnlyNonCompleted()) {
listToUpdate = listToUpdate.filter { it.status != SManga.COMPLETED }
}
@ -339,12 +340,13 @@ class LibraryUpdateService(
Timber.e(exception)
stopSelf(startId)
}
if (target == Target.CHAPTERS) {
job = GlobalScope.launch(handler) {
job = if (target == Target.CHAPTERS) {
listener?.onUpdateManga(LibraryManga())
GlobalScope.launch(handler) {
updateChaptersJob(mangaToAdd)
}
} else {
job = GlobalScope.launch(handler) {
GlobalScope.launch(handler) {
updateTrackings(mangaToAdd)
}
}

View File

@ -154,7 +154,7 @@ class LibraryHeaderItem(
else -> {
catProgress.gone()
checkboxImage.gone()
updateButton.visInvisIf(!(category.isFirst == true && category.isLast == true))
updateButton.visInvisIf(category.id ?: 0 > -1)
}
}
}

View File

@ -204,7 +204,7 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle),
setPadding(dl_bottom_sheet.sheetBehavior?.isHideable == true)
}
fun reEnableSwipe() {
fun setRefreshing(refresh: Boolean) {
swipe_refresh.isRefreshing = false
}

View File

@ -242,8 +242,13 @@ class RecentsPresenter(
}
override fun onUpdateManga(manga: LibraryManga) {
if (manga.id == null) scope.launch(Dispatchers.Main) { controller.reEnableSwipe() }
else getRecents()
if (manga.id == null && !LibraryUpdateService.isRunning()) {
scope.launch(Dispatchers.Main) { controller.setRefreshing(false) }
} else if (manga.id == null) {
scope.launch(Dispatchers.Main) { controller.setRefreshing(true) }
} else {
getRecents()
}
}
/**