mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 05:25:08 +01:00
Update library while restore happens
This commit is contained in:
parent
c21b91bc02
commit
41f4ea6f01
@ -77,6 +77,7 @@ class FullBackupRestore(context: Context, notifier: BackupNotifier) : AbstractBa
|
||||
|
||||
restoreProgress += 1
|
||||
showRestoreProgress(restoreProgress, restoreAmount, manga.title)
|
||||
LibraryUpdateService.callListener(manga)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
||||
import eu.kanade.tachiyomi.data.database.models.Track
|
||||
import eu.kanade.tachiyomi.data.database.models.TrackImpl
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import java.util.Date
|
||||
|
||||
@ -100,6 +101,7 @@ class LegacyBackupRestore(context: Context, notifier: BackupNotifier) : Abstract
|
||||
|
||||
restoreProgress += 1
|
||||
showRestoreProgress(restoreProgress, restoreAmount, manga.title)
|
||||
LibraryUpdateService.callListener(manga)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,7 +180,7 @@ class LibraryUpdateService(
|
||||
if (wakeLock.isHeld) {
|
||||
wakeLock.release()
|
||||
}
|
||||
listener?.onUpdateManga(LibraryManga())
|
||||
listener?.onUpdateManga()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ class LibraryUpdateService(
|
||||
stopSelf(startId)
|
||||
}
|
||||
if (target == Target.CHAPTERS) {
|
||||
listener?.onUpdateManga(LibraryManga())
|
||||
listener?.onUpdateManga()
|
||||
}
|
||||
job = GlobalScope.launch(handler) {
|
||||
when (target) {
|
||||
@ -626,9 +626,13 @@ class LibraryUpdateService(
|
||||
fun removeListener(listener: LibraryServiceListener) {
|
||||
if (this.listener == listener) this.listener = null
|
||||
}
|
||||
|
||||
fun callListener(manga: Manga) {
|
||||
listener?.onUpdateManga(manga)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface LibraryServiceListener {
|
||||
fun onUpdateManga(manga: LibraryManga)
|
||||
fun onUpdateManga(manga: Manga? = null)
|
||||
}
|
||||
|
@ -1165,9 +1165,9 @@ class LibraryController(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUpdateManga(manga: LibraryManga) {
|
||||
if (manga.id == null) adapter.notifyDataSetChanged()
|
||||
else presenter.updateManga(manga)
|
||||
override fun onUpdateManga(manga: Manga?) {
|
||||
if (manga == null) adapter.notifyDataSetChanged()
|
||||
else presenter.updateManga()
|
||||
}
|
||||
|
||||
private fun setSelection(position: Int, selected: Boolean = true) {
|
||||
|
@ -737,7 +737,7 @@ class LibraryPresenter(
|
||||
}
|
||||
|
||||
/** Called when Library Service updates a manga, update the item as well */
|
||||
fun updateManga(manga: LibraryManga) {
|
||||
fun updateManga() {
|
||||
scope.launch {
|
||||
getLibrary()
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
||||
import eu.kanade.tachiyomi.data.database.models.Track
|
||||
@ -599,8 +598,8 @@ class MangaDetailsPresenter(
|
||||
toggleFavorite()
|
||||
}
|
||||
|
||||
override fun onUpdateManga(manga: LibraryManga) {
|
||||
if (manga.id == this.manga.id) {
|
||||
override fun onUpdateManga(manga: Manga?) {
|
||||
if (manga?.id == this.manga.id) {
|
||||
fetchChapters()
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.recent_updates
|
||||
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.database.models.MangaChapter
|
||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
@ -92,7 +91,7 @@ class RecentChaptersPresenter(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUpdateManga(manga: LibraryManga) {
|
||||
override fun onUpdateManga(manga: Manga?) {
|
||||
getUpdates()
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
import eu.kanade.tachiyomi.data.database.models.History
|
||||
import eu.kanade.tachiyomi.data.database.models.HistoryImpl
|
||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
|
||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
@ -265,10 +264,10 @@ class RecentsPresenter(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUpdateManga(manga: LibraryManga) {
|
||||
if (manga.id == null && !LibraryUpdateService.isRunning()) {
|
||||
override fun onUpdateManga(manga: Manga?) {
|
||||
if (manga == null && !LibraryUpdateService.isRunning()) {
|
||||
scope.launch(Dispatchers.Main) { controller.setRefreshing(false) }
|
||||
} else if (manga.id == null) {
|
||||
} else if (manga == null) {
|
||||
scope.launch(Dispatchers.Main) { controller.setRefreshing(true) }
|
||||
} else {
|
||||
getRecents()
|
||||
|
Loading…
Reference in New Issue
Block a user