|
|
|
|
@ -14,7 +14,9 @@ sealed interface MangaListFilter {
|
|
|
|
|
(tags.size <= 1 || parser.isMultipleTagsSupported) &&
|
|
|
|
|
(tagsExclude.isEmpty() || parser.isTagsExclusionSupported) &&
|
|
|
|
|
(contentRating.isEmpty() || parser.availableContentRating.containsAll(contentRating)) &&
|
|
|
|
|
(states.isEmpty() || parser.availableStates.containsAll(states))
|
|
|
|
|
(states.isEmpty() || parser.availableStates.containsAll(states) &&
|
|
|
|
|
(type.isEmpty() || parser.availableType.containsAll(type)) &&
|
|
|
|
|
(demographic.isEmpty() || parser.availableDemographic.containsAll(demographic)))
|
|
|
|
|
|
|
|
|
|
is Search -> parser.isSearchSupported
|
|
|
|
|
}
|
|
|
|
|
@ -35,10 +37,12 @@ sealed interface MangaListFilter {
|
|
|
|
|
@JvmField val locale: Locale?,
|
|
|
|
|
@JvmField val states: Set<MangaState>,
|
|
|
|
|
@JvmField val contentRating: Set<ContentRating>,
|
|
|
|
|
@JvmField val type: Set<Type>,
|
|
|
|
|
@JvmField val demographic: Set<Demographic>,
|
|
|
|
|
) : MangaListFilter {
|
|
|
|
|
|
|
|
|
|
override fun isEmpty(): Boolean =
|
|
|
|
|
tags.isEmpty() && tagsExclude.isEmpty() && locale == null && states.isEmpty() && contentRating.isEmpty()
|
|
|
|
|
tags.isEmpty() && tagsExclude.isEmpty() && locale == null && states.isEmpty() && contentRating.isEmpty() && type.isEmpty() && demographic.isEmpty()
|
|
|
|
|
|
|
|
|
|
fun newBuilder() = Builder(sortOrder)
|
|
|
|
|
.tags(tags)
|
|
|
|
|
@ -46,6 +50,8 @@ sealed interface MangaListFilter {
|
|
|
|
|
.locale(locale)
|
|
|
|
|
.states(states)
|
|
|
|
|
.contentRatings(contentRating)
|
|
|
|
|
.type(type)
|
|
|
|
|
.demographic(demographic)
|
|
|
|
|
|
|
|
|
|
class Builder(sortOrder: SortOrder) {
|
|
|
|
|
|
|
|
|
|
@ -55,6 +61,8 @@ sealed interface MangaListFilter {
|
|
|
|
|
private var _locale: Locale? = null
|
|
|
|
|
private var _states: Set<MangaState>? = null
|
|
|
|
|
private var _contentRating: Set<ContentRating>? = null
|
|
|
|
|
private var _type: Set<Type>? = null
|
|
|
|
|
private var _demographic: Set<Demographic>? = null
|
|
|
|
|
|
|
|
|
|
fun sortOrder(order: SortOrder) = apply {
|
|
|
|
|
_sortOrder = order
|
|
|
|
|
@ -80,6 +88,14 @@ sealed interface MangaListFilter {
|
|
|
|
|
_contentRating = rating
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun type(type: Set<Type>?) = apply {
|
|
|
|
|
_type = type
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun demographic(demographic: Set<Demographic>?) = apply {
|
|
|
|
|
_demographic = demographic
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun build() = Advanced(
|
|
|
|
|
sortOrder = _sortOrder,
|
|
|
|
|
tags = _tags.orEmpty(),
|
|
|
|
|
@ -87,6 +103,8 @@ sealed interface MangaListFilter {
|
|
|
|
|
locale = _locale,
|
|
|
|
|
states = _states.orEmpty(),
|
|
|
|
|
contentRating = _contentRating.orEmpty(),
|
|
|
|
|
type = _type.orEmpty(),
|
|
|
|
|
demographic = _demographic.orEmpty()
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|