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
|
restoreProgress += 1
|
||||||
showRestoreProgress(restoreProgress, restoreAmount, manga.title)
|
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.MangaImpl
|
||||||
import eu.kanade.tachiyomi.data.database.models.Track
|
import eu.kanade.tachiyomi.data.database.models.Track
|
||||||
import eu.kanade.tachiyomi.data.database.models.TrackImpl
|
import eu.kanade.tachiyomi.data.database.models.TrackImpl
|
||||||
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
@ -100,6 +101,7 @@ class LegacyBackupRestore(context: Context, notifier: BackupNotifier) : Abstract
|
|||||||
|
|
||||||
restoreProgress += 1
|
restoreProgress += 1
|
||||||
showRestoreProgress(restoreProgress, restoreAmount, manga.title)
|
showRestoreProgress(restoreProgress, restoreAmount, manga.title)
|
||||||
|
LibraryUpdateService.callListener(manga)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,7 +180,7 @@ class LibraryUpdateService(
|
|||||||
if (wakeLock.isHeld) {
|
if (wakeLock.isHeld) {
|
||||||
wakeLock.release()
|
wakeLock.release()
|
||||||
}
|
}
|
||||||
listener?.onUpdateManga(LibraryManga())
|
listener?.onUpdateManga()
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ class LibraryUpdateService(
|
|||||||
stopSelf(startId)
|
stopSelf(startId)
|
||||||
}
|
}
|
||||||
if (target == Target.CHAPTERS) {
|
if (target == Target.CHAPTERS) {
|
||||||
listener?.onUpdateManga(LibraryManga())
|
listener?.onUpdateManga()
|
||||||
}
|
}
|
||||||
job = GlobalScope.launch(handler) {
|
job = GlobalScope.launch(handler) {
|
||||||
when (target) {
|
when (target) {
|
||||||
@ -626,9 +626,13 @@ class LibraryUpdateService(
|
|||||||
fun removeListener(listener: LibraryServiceListener) {
|
fun removeListener(listener: LibraryServiceListener) {
|
||||||
if (this.listener == listener) this.listener = null
|
if (this.listener == listener) this.listener = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun callListener(manga: Manga) {
|
||||||
|
listener?.onUpdateManga(manga)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LibraryServiceListener {
|
interface LibraryServiceListener {
|
||||||
fun onUpdateManga(manga: LibraryManga)
|
fun onUpdateManga(manga: Manga? = null)
|
||||||
}
|
}
|
||||||
|
@ -1165,9 +1165,9 @@ class LibraryController(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUpdateManga(manga: LibraryManga) {
|
override fun onUpdateManga(manga: Manga?) {
|
||||||
if (manga.id == null) adapter.notifyDataSetChanged()
|
if (manga == null) adapter.notifyDataSetChanged()
|
||||||
else presenter.updateManga(manga)
|
else presenter.updateManga()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setSelection(position: Int, selected: Boolean = true) {
|
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 */
|
/** Called when Library Service updates a manga, update the item as well */
|
||||||
fun updateManga(manga: LibraryManga) {
|
fun updateManga() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
getLibrary()
|
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.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category
|
import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
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.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
||||||
import eu.kanade.tachiyomi.data.database.models.Track
|
import eu.kanade.tachiyomi.data.database.models.Track
|
||||||
@ -599,8 +598,8 @@ class MangaDetailsPresenter(
|
|||||||
toggleFavorite()
|
toggleFavorite()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUpdateManga(manga: LibraryManga) {
|
override fun onUpdateManga(manga: Manga?) {
|
||||||
if (manga.id == this.manga.id) {
|
if (manga?.id == this.manga.id) {
|
||||||
fetchChapters()
|
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.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
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.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaChapter
|
import eu.kanade.tachiyomi.data.database.models.MangaChapter
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
@ -92,7 +91,7 @@ class RecentChaptersPresenter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUpdateManga(manga: LibraryManga) {
|
override fun onUpdateManga(manga: Manga?) {
|
||||||
getUpdates()
|
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.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.History
|
import eu.kanade.tachiyomi.data.database.models.History
|
||||||
import eu.kanade.tachiyomi.data.database.models.HistoryImpl
|
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.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
|
import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
@ -265,10 +264,10 @@ class RecentsPresenter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUpdateManga(manga: LibraryManga) {
|
override fun onUpdateManga(manga: Manga?) {
|
||||||
if (manga.id == null && !LibraryUpdateService.isRunning()) {
|
if (manga == null && !LibraryUpdateService.isRunning()) {
|
||||||
scope.launch(Dispatchers.Main) { controller.setRefreshing(false) }
|
scope.launch(Dispatchers.Main) { controller.setRefreshing(false) }
|
||||||
} else if (manga.id == null) {
|
} else if (manga == null) {
|
||||||
scope.launch(Dispatchers.Main) { controller.setRefreshing(true) }
|
scope.launch(Dispatchers.Main) { controller.setRefreshing(true) }
|
||||||
} else {
|
} else {
|
||||||
getRecents()
|
getRecents()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user