Fixed bug with missing manga order in categoriess

This commit is contained in:
Jay 2020-01-15 22:36:08 -08:00
parent 7f2fd5f025
commit a119f9e794
4 changed files with 6 additions and 11 deletions

View File

@ -60,7 +60,7 @@ class CategoryGetResolver : DefaultGetResolver<Category>() {
flags = cursor.getInt(cursor.getColumnIndex(COL_FLAGS)) flags = cursor.getInt(cursor.getColumnIndex(COL_FLAGS))
val orderString = cursor.getString(cursor.getColumnIndex(COL_MANGA_ORDER)) val orderString = cursor.getString(cursor.getColumnIndex(COL_MANGA_ORDER))
if (orderString.firstOrNull()?.isLetter() == true) { if (orderString?.firstOrNull()?.isLetter() == true) {
mangaSort = orderString.first() mangaSort = orderString.first()
mangaOrder = emptyList() mangaOrder = emptyList()
} }

View File

@ -27,10 +27,8 @@ interface Category : Serializable {
this.name = name this.name = name
} }
fun createDefault(context: Context): Category = create(context.getString(R.string.default_columns)) fun createDefault(): Category = create("Default").apply {
.apply { id = 0 }
id =
0 }
} }
} }

View File

@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.library
import android.os.Bundle import android.os.Bundle
import com.jakewharton.rxrelay.BehaviorRelay import com.jakewharton.rxrelay.BehaviorRelay
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.cache.CoverCache 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
@ -12,7 +11,6 @@ import eu.kanade.tachiyomi.data.database.models.MangaImpl
import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
@ -202,7 +200,7 @@ class LibraryPresenter(
db.getTotalChapterManga().executeAsBlocking().associate { it.id!! to counter++ } db.getTotalChapterManga().executeAsBlocking().associate { it.id!! to counter++ }
} }
val catListing by lazy { val catListing by lazy {
val default = Category.createDefault(context) val default = Category.createDefault()
val defOrder = preferences.defaultMangaOrder().getOrDefault() val defOrder = preferences.defaultMangaOrder().getOrDefault()
if (defOrder.firstOrNull()?.isLetter() == true) default.mangaSort = defOrder.first() if (defOrder.firstOrNull()?.isLetter() == true) default.mangaSort = defOrder.first()
else default.mangaOrder = defOrder.split("/").mapNotNull { it.toLongOrNull() } else default.mangaOrder = defOrder.split("/").mapNotNull { it.toLongOrNull() }
@ -286,8 +284,7 @@ class LibraryPresenter(
*/ */
private fun getLibraryObservable(): Observable<Library> { private fun getLibraryObservable(): Observable<Library> {
return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable()) { dbCategories, libraryManga -> return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable()) { dbCategories, libraryManga ->
val categories = if (libraryManga.containsKey(0)) arrayListOf(Category.createDefault val categories = if (libraryManga.containsKey(0)) arrayListOf(Category.createDefault()) + dbCategories
(context.applicationContext)) + dbCategories
else dbCategories else dbCategories
this.categories = categories this.categories = categories

View File

@ -132,7 +132,7 @@ class SettingsLibraryController : SettingsController() {
key = Keys.defaultCategory key = Keys.defaultCategory
titleRes = R.string.default_category titleRes = R.string.default_category
val categories = listOf(Category.createDefault(context)) + dbCategories val categories = listOf(Category.createDefault()) + dbCategories
entries = listOf(context.getString(R.string.default_category_summary)) + entries = listOf(context.getString(R.string.default_category_summary)) +
categories.map { it.name }.toTypedArray() categories.map { it.name }.toTypedArray()
entryValues = listOf(-1) + categories.mapNotNull { it.id }.toList() entryValues = listOf(-1) + categories.mapNotNull { it.id }.toList()