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

View File

@ -154,7 +154,7 @@ class LibraryHeaderItem(
else -> { else -> {
catProgress.gone() catProgress.gone()
checkboxImage.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) setPadding(dl_bottom_sheet.sheetBehavior?.isHideable == true)
} }
fun reEnableSwipe() { fun setRefreshing(refresh: Boolean) {
swipe_refresh.isRefreshing = false swipe_refresh.isRefreshing = false
} }

View File

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