mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Update stats details library if something is removed/migrated
This commit is contained in:
parent
4b56d84428
commit
35d81dfd97
4 changed files with 27 additions and 2 deletions
|
@ -5,8 +5,12 @@ import android.view.Menu
|
||||||
import android.view.MenuInflater
|
import android.view.MenuInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet
|
||||||
|
import eu.kanade.tachiyomi.ui.more.stats.details.StatsDetailsController
|
||||||
import eu.kanade.tachiyomi.util.view.collapse
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
|
import eu.kanade.tachiyomi.util.view.previousController
|
||||||
|
|
||||||
class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bundle) {
|
class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bundle) {
|
||||||
|
|
||||||
|
@ -87,6 +91,22 @@ class FilteredLibraryController(bundle: Bundle? = null) : LibraryController(bund
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
|
super.onChangeStarted(handler, type)
|
||||||
|
if (type == ControllerChangeType.POP_ENTER) {
|
||||||
|
updateStatsPage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deleteMangasFromLibrary() {
|
||||||
|
super.deleteMangasFromLibrary()
|
||||||
|
updateStatsPage()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateStatsPage() {
|
||||||
|
(previousController as? StatsDetailsController)?.updateLibrary()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {}
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {}
|
||||||
override fun toggleCategoryVisibility(position: Int) {}
|
override fun toggleCategoryVisibility(position: Int) {}
|
||||||
override fun hasActiveFiltersFromPref(): Boolean = false
|
override fun hasActiveFiltersFromPref(): Boolean = false
|
||||||
|
|
|
@ -2109,7 +2109,7 @@ open class LibraryController(
|
||||||
startActivity(Intent.createChooser(intent, context.getString(R.string.share)))
|
startActivity(Intent.createChooser(intent, context.getString(R.string.share)))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteMangasFromLibrary() {
|
open fun deleteMangasFromLibrary() {
|
||||||
val mangas = selectedMangas.toList()
|
val mangas = selectedMangas.toList()
|
||||||
presenter.removeMangaFromLibrary(mangas)
|
presenter.removeMangaFromLibrary(mangas)
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
|
|
|
@ -1078,11 +1078,12 @@ class LibraryPresenter(
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Undo the removal of the manga once in library */
|
/** Undo the removal of the manga once in library */
|
||||||
fun reAddMangas(mangas: List<Manga>) {
|
fun reAddMangas(mangas: List<Manga) {
|
||||||
presenterScope.launch {
|
presenterScope.launch {
|
||||||
val mangaToAdd = mangas.distinctBy { it.id }
|
val mangaToAdd = mangas.distinctBy { it.id }
|
||||||
mangaToAdd.forEach { it.favorite = true }
|
mangaToAdd.forEach { it.favorite = true }
|
||||||
db.insertMangas(mangaToAdd).executeOnIO()
|
db.insertMangas(mangaToAdd).executeOnIO()
|
||||||
|
(controller as? FilteredLibraryController)?.updateStatsPage()
|
||||||
getLibrary()
|
getLibrary()
|
||||||
mangaToAdd.forEach { db.insertManga(it).executeAsBlocking() }
|
mangaToAdd.forEach { db.insertManga(it).executeAsBlocking() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,6 +231,10 @@ class StatsDetailsController :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateLibrary() {
|
||||||
|
presenter.libraryMangas = presenter.getLibrary()
|
||||||
|
}
|
||||||
|
|
||||||
/** Set the toolbar to fully transparent or colored and translucent */
|
/** Set the toolbar to fully transparent or colored and translucent */
|
||||||
private fun colorToolbar(isColor: Boolean) {
|
private fun colorToolbar(isColor: Boolean) {
|
||||||
if (isColor == toolbarIsColored) return
|
if (isColor == toolbarIsColored) return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue