Fix single tag searching + multi tag searching by commas)
This commit is contained in:
parent
bb86196204
commit
ff49d055ab
@ -4,17 +4,17 @@ import android.view.Gravity
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.f2prateek.rx.preferences.Preference
|
import com.f2prateek.rx.preferences.Preference
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||||
import eu.davidea.flexibleadapter.items.IFilterable
|
import eu.davidea.flexibleadapter.items.IFilterable
|
||||||
|
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.widget.AutofitRecyclerView
|
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||||
import kotlinx.android.synthetic.main.catalogue_grid_item.view.*
|
import kotlinx.android.synthetic.main.catalogue_grid_item.view.*
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
|
||||||
|
|
||||||
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> {
|
||||||
@ -60,14 +60,21 @@ class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference
|
|||||||
override fun filter(constraint: String): Boolean {
|
override fun filter(constraint: String): Boolean {
|
||||||
return manga.title.contains(constraint, true) ||
|
return manga.title.contains(constraint, true) ||
|
||||||
(manga.author?.contains(constraint, true) ?: false) ||
|
(manga.author?.contains(constraint, true) ?: false) ||
|
||||||
(if (constraint.startsWith("-"))
|
if (constraint.contains(",")) {
|
||||||
manga.genre?.split(", ")?.find {
|
val genres = manga.genre?.split(", ")
|
||||||
it.toLowerCase() == constraint.substringAfter("-").toLowerCase()
|
constraint.split(",").all { containsGenre(it.trim(), genres) }
|
||||||
} == null
|
}
|
||||||
else
|
else containsGenre(constraint, manga.genre?.split(", "))
|
||||||
manga.genre?.split(", ")?.find {
|
}
|
||||||
it.toLowerCase() == constraint.toLowerCase() } != null
|
|
||||||
)
|
private fun containsGenre(tag: String, genres: List<String>?): Boolean {
|
||||||
|
return if (tag.startsWith("-"))
|
||||||
|
genres?.find {
|
||||||
|
it.trim().toLowerCase() == tag.substringAfter("-").toLowerCase()
|
||||||
|
} == null
|
||||||
|
else
|
||||||
|
genres?.find {
|
||||||
|
it.trim().toLowerCase() == tag.toLowerCase() } != null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
|
Loading…
Reference in New Issue
Block a user