Fix notification and add visual cues when triggering a second update (#7783)

This commit is contained in:
stevenyomi
2022-08-18 21:01:10 +08:00
committed by GitHub
parent 80b4b7bee6
commit 1f34f5277c
6 changed files with 21 additions and 21 deletions

View File

@@ -154,18 +154,15 @@ class LibraryUpdateService(
* @return true if service newly started, false otherwise
*/
fun start(context: Context, category: Category? = null, target: Target = Target.CHAPTERS): Boolean {
return if (!isRunning(context)) {
val intent = Intent(context, LibraryUpdateService::class.java).apply {
putExtra(KEY_TARGET, target)
category?.let { putExtra(KEY_CATEGORY, it.id) }
}
ContextCompat.startForegroundService(context, intent)
if (isRunning(context)) return false
true
} else {
instance?.addMangaToQueue(category?.id ?: -1)
false
val intent = Intent(context, LibraryUpdateService::class.java).apply {
putExtra(KEY_TARGET, target)
category?.let { putExtra(KEY_CATEGORY, it.id) }
}
ContextCompat.startForegroundService(context, intent)
return true
}
/**

View File

@@ -57,9 +57,9 @@ class LibraryController(
onDeleteClicked = ::showDeleteMangaDialog,
onClickFilter = ::showSettingsSheet,
onClickRefresh = {
if (LibraryUpdateService.start(context, it)) {
context.toast(R.string.updating_library)
}
val started = LibraryUpdateService.start(context, it)
context.toast(if (started) R.string.updating_library else R.string.update_already_running)
started
},
onClickInvertSelection = { presenter.invertSelection(presenter.activeCategory) },
onClickSelectAll = { presenter.selectAll(presenter.activeCategory) },