Cleanup some tag stuff
This commit is contained in:
parent
b657af8d1c
commit
3f56c81c03
@ -135,14 +135,35 @@ class MangaInfoItemAdapter(
|
|||||||
var namespaceTags: List<NamespaceTagsItem> = emptyList()
|
var namespaceTags: List<NamespaceTagsItem> = emptyList()
|
||||||
if (source.isEhBasedSource() && metaTags != null && metaTags.all { it.key != null }) {
|
if (source.isEhBasedSource() && metaTags != null && metaTags.all { it.key != null }) {
|
||||||
namespaceTags = metaTags
|
namespaceTags = metaTags
|
||||||
.mapValues { values -> values.value.map { makeSearchChip(it.name, controller::performSearch, controller::performGlobalSearch, source.id, itemView.context, it.namespace, it.type) } }
|
.mapValues { values ->
|
||||||
|
values.value.map {
|
||||||
|
itemView.context.makeSearchChip(
|
||||||
|
it.name,
|
||||||
|
controller::performSearch,
|
||||||
|
controller::performGlobalSearch,
|
||||||
|
source.id,
|
||||||
|
it.namespace,
|
||||||
|
it.type
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
.map { NamespaceTagsItem(it.key!!, it.value) }
|
.map { NamespaceTagsItem(it.key!!, it.value) }
|
||||||
} else {
|
} else {
|
||||||
val genre = manga.getRaisedTags()
|
val genre = manga.getRaisedTags()
|
||||||
if (!genre.isNullOrEmpty()) {
|
if (!genre.isNullOrEmpty()) {
|
||||||
namespaceTags = genre
|
namespaceTags = genre
|
||||||
.groupBy { it.namespace }
|
.groupBy { it.namespace }
|
||||||
.mapValues { values -> values.value.map { makeSearchChip(it.name, controller::performSearch, controller::performGlobalSearch, source.id, itemView.context, it.namespace) } }
|
.mapValues { values ->
|
||||||
|
values.value.map {
|
||||||
|
itemView.context.makeSearchChip(
|
||||||
|
it.name,
|
||||||
|
controller::performSearch,
|
||||||
|
controller::performGlobalSearch,
|
||||||
|
source.id,
|
||||||
|
it.namespace
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
.map { NamespaceTagsItem(it.key, it.value) }
|
.map { NamespaceTagsItem(it.key, it.value) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@ import java.util.Locale
|
|||||||
object SourceTagsUtil {
|
object SourceTagsUtil {
|
||||||
fun getWrappedTag(sourceId: Long, namespace: String? = null, tag: String? = null, fullTag: String? = null): String? {
|
fun getWrappedTag(sourceId: Long, namespace: String? = null, tag: String? = null, fullTag: String? = null): String? {
|
||||||
return if (sourceId == EXH_SOURCE_ID || sourceId == EH_SOURCE_ID || sourceId in nHentaiSourceIds || sourceId in hitomiSourceIds) {
|
return if (sourceId == EXH_SOURCE_ID || sourceId == EH_SOURCE_ID || sourceId in nHentaiSourceIds || sourceId in hitomiSourceIds) {
|
||||||
val parsed = if (fullTag != null) {
|
val parsed = when {
|
||||||
parseTag(fullTag)
|
fullTag != null -> parseTag(fullTag)
|
||||||
} else if (namespace != null && tag != null) {
|
namespace != null && tag != null -> RaisedTag(namespace, tag, TAG_TYPE_DEFAULT)
|
||||||
RaisedTag(namespace, tag, TAG_TYPE_DEFAULT)
|
else -> null
|
||||||
} else null
|
}
|
||||||
if (parsed?.namespace != null) {
|
if (parsed?.namespace != null) {
|
||||||
when (sourceId) {
|
when (sourceId) {
|
||||||
in hitomiSourceIds -> wrapTagHitomi(parsed.namespace, parsed.name.substringBefore('|').trim())
|
in hitomiSourceIds -> wrapTagHitomi(parsed.namespace, parsed.name.substringBefore('|').trim())
|
||||||
|
@ -19,13 +19,13 @@ fun ChipGroup.setChipsExtended(items: List<String>?, onClick: (item: String) ->
|
|||||||
removeAllViews()
|
removeAllViews()
|
||||||
|
|
||||||
items?.forEach { item ->
|
items?.forEach { item ->
|
||||||
val chip = makeSearchChip(item, onClick, onLongClick, sourceId, context)
|
val chip = context.makeSearchChip(item, onClick, onLongClick, sourceId)
|
||||||
addView(chip)
|
addView(chip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun makeSearchChip(item: String, onClick: (item: String) -> Unit = {}, onLongClick: (item: String) -> Unit = {}, sourceId: Long, context: Context, namespace: String? = null, type: Int? = null): Chip {
|
fun Context.makeSearchChip(item: String, onClick: (item: String) -> Unit = {}, onLongClick: (item: String) -> Unit = {}, sourceId: Long, namespace: String? = null, type: Int? = null): Chip {
|
||||||
return Chip(context).apply {
|
return Chip(this).apply {
|
||||||
text = item
|
text = item
|
||||||
val search = if (namespace != null) {
|
val search = if (namespace != null) {
|
||||||
SourceTagsUtil.getWrappedTag(sourceId, namespace = namespace, tag = item)
|
SourceTagsUtil.getWrappedTag(sourceId, namespace = namespace, tag = item)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user