fix ClearDatabaseController

This commit is contained in:
jmir1 2021-11-21 23:49:26 +01:00
parent 88c47395fb
commit fca59aa7aa
6 changed files with 25 additions and 6 deletions

View file

@ -81,7 +81,7 @@ class LocalAnimeSource(private val context: Context) : AnimeCatalogueSource {
private val json: Json by injectLazy()
override val id = ID
override val name = context.getString(R.string.local_source)
override val name = context.getString(R.string.local_anime_source)
override val lang = "other"
override val supportsLatest = true

View file

@ -84,7 +84,7 @@ class LocalSource(private val context: Context) : CatalogueSource {
private val json: Json by injectLazy()
override val id = ID
override val name = context.getString(R.string.local_source)
override val name = context.getString(R.string.local_manga_source)
override val lang = "other"
override val supportsLatest = true

View file

@ -123,10 +123,24 @@ class ClearDatabaseController :
fun setItems(items: List<AbstractFlexibleItem<out FlexibleViewHolder>>) {
launchUI {
val animeItems = adapter?.currentItems?.filterIsInstance<ClearDatabaseAnimeSourceItem>()
?: emptyList()
adapter?.clear()
adapter?.addItems(0, animeItems)
adapter?.addItems(adapter?.itemCount ?: 0, items)
}
}
fun setItemsAnime(items: List<AbstractFlexibleItem<out FlexibleViewHolder>>) {
launchUI {
val mangaItems = adapter?.currentItems?.filterIsInstance<ClearDatabaseSourceItem>()
?: emptyList()
adapter?.clear()
adapter?.addItems(0, items)
adapter?.addItems(adapter?.itemCount ?: 0, mangaItems)
}
}
override fun configureFab(fab: ExtendedFloatingActionButton) {
fab.setIconResource(R.drawable.ic_delete_24dp)
fab.setText(R.string.action_delete)

View file

@ -23,7 +23,7 @@ class ClearDatabasePresenter : BasePresenter<ClearDatabaseController>() {
super.onCreate(savedState)
getDatabaseAnimeSourcesObservable()
.subscribeOn(Schedulers.io())
.subscribeLatestCache(ClearDatabaseController::setItems)
.subscribeLatestCache(ClearDatabaseController::setItemsAnime)
getDatabaseSourcesObservable()
.subscribeOn(Schedulers.io())
.subscribeLatestCache(ClearDatabaseController::setItems)

View file

@ -19,7 +19,7 @@ class ClearDatabaseSourceItemHolder(view: View, adapter: FlexibleAdapter<*>) : F
fun bind(source: AnimeSource, count: Int) {
binding.title.text = source.toString()
binding.description.text = itemView.context.getString(R.string.clear_database_source_item_count, count)
binding.description.text = itemView.context.resources.getQuantityString(R.plurals.clear_database_source_item_count, count)
itemView.post {
when {
@ -32,7 +32,7 @@ class ClearDatabaseSourceItemHolder(view: View, adapter: FlexibleAdapter<*>) : F
fun bind(source: Source, count: Int) {
binding.title.text = source.toString()
binding.description.text = itemView.context.getString(R.string.clear_database_source_item_count, count)
binding.description.text = itemView.context.resources.getQuantityString(R.plurals.clear_database_source_item_count, count)
itemView.post {
when {

View file

@ -530,7 +530,10 @@
<string name="pref_auto_clear_chapter_cache">Clear chapter/episode cache on app close</string>
<string name="pref_clear_database">Clear database</string>
<string name="pref_clear_database_summary">Delete history for anime and manga that are not saved in your library</string>
<string name="clear_database_source_item_count">%1$d non-library entries in database</string>
<plurals name="clear_database_source_item_count">
<item quantity="one">1 non-library entry in database</item>
<item quantity="other">%1$d non-library entries in database</item>
</plurals>
<string name="clear_database_confirmation">Are you sure? Completed episodes and chapters and progress of non-library entries will be lost</string>
<string name="clear_database_completed">Entries deleted</string>
<string name="database_clean">Database clean</string>
@ -605,6 +608,8 @@
<!-- Do not translate "WebView" -->
<string name="http_error_hint">Check website in WebView</string>
<string name="local_source">Local source</string>
<string name="local_manga_source">Local manga source</string>
<string name="local_anime_source">Local anime source</string>
<string name="other_source">Other</string>
<string name="last_used_source">Last used</string>
<string name="pinned_sources">Pinned</string>