mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Library search for source
This commit is contained in:
parent
a20ad68fe3
commit
144418434b
2 changed files with 9 additions and 1 deletions
|
@ -36,6 +36,9 @@ open class SourceManager(private val context: Context) {
|
||||||
if (overwrite || !sourcesMap.containsKey(source.id)) {
|
if (overwrite || !sourcesMap.containsKey(source.id)) {
|
||||||
sourcesMap[source.id] = source
|
sourcesMap[source.id] = source
|
||||||
}
|
}
|
||||||
|
if (overwrite || !stubSourcesMap.containsKey(source.id)) {
|
||||||
|
stubSourcesMap[source.id] = StubSource(source.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun unregisterSource(source: Source) {
|
internal fun unregisterSource(source: Source) {
|
||||||
|
|
|
@ -13,13 +13,18 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||||
import kotlinx.android.synthetic.main.catalogue_grid_item.view.card
|
import kotlinx.android.synthetic.main.catalogue_grid_item.view.card
|
||||||
import kotlinx.android.synthetic.main.catalogue_grid_item.view.gradient
|
import kotlinx.android.synthetic.main.catalogue_grid_item.view.gradient
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference<Boolean>) :
|
class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference<Boolean>) :
|
||||||
AbstractFlexibleItem<LibraryHolder>(), IFilterable<String> {
|
AbstractFlexibleItem<LibraryHolder>(), IFilterable<String> {
|
||||||
|
|
||||||
|
private val sourceManager: SourceManager = Injekt.get()
|
||||||
|
|
||||||
var downloadCount = -1
|
var downloadCount = -1
|
||||||
|
|
||||||
override fun getLayoutRes(): Int {
|
override fun getLayoutRes(): Int {
|
||||||
|
@ -48,7 +53,6 @@ class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference
|
||||||
holder: LibraryHolder,
|
holder: LibraryHolder,
|
||||||
position: Int,
|
position: Int,
|
||||||
payloads: List<Any?>?) {
|
payloads: List<Any?>?) {
|
||||||
|
|
||||||
holder.onSetValues(this)
|
holder.onSetValues(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +66,7 @@ class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference
|
||||||
return manga.title.contains(constraint, true) ||
|
return manga.title.contains(constraint, true) ||
|
||||||
(manga.author?.contains(constraint, true) ?: false) ||
|
(manga.author?.contains(constraint, true) ?: false) ||
|
||||||
(manga.artist?.contains(constraint, true) ?: false) ||
|
(manga.artist?.contains(constraint, true) ?: false) ||
|
||||||
|
sourceManager.getOrStub(manga.source).name.contains(constraint, true) ||
|
||||||
if (constraint.contains(",")) {
|
if (constraint.contains(",")) {
|
||||||
val genres = manga.genre?.split(", ")
|
val genres = manga.genre?.split(", ")
|
||||||
constraint.split(",").all { containsGenre(it.trim(), genres) }
|
constraint.split(",").all { containsGenre(it.trim(), genres) }
|
||||||
|
|
Loading…
Reference in a new issue