Cleanup some tag stuff

This commit is contained in:
Jobobby04
2021-05-11 12:38:50 -04:00
parent b657af8d1c
commit 3f56c81c03
3 changed files with 31 additions and 10 deletions
+5 -5
View File
@@ -14,11 +14,11 @@ import java.util.Locale
object SourceTagsUtil {
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) {
val parsed = if (fullTag != null) {
parseTag(fullTag)
} else if (namespace != null && tag != null) {
RaisedTag(namespace, tag, TAG_TYPE_DEFAULT)
} else null
val parsed = when {
fullTag != null -> parseTag(fullTag)
namespace != null && tag != null -> RaisedTag(namespace, tag, TAG_TYPE_DEFAULT)
else -> null
}
if (parsed?.namespace != null) {
when (sourceId) {
in hitomiSourceIds -> wrapTagHitomi(parsed.namespace, parsed.name.substringBefore('|').trim())
+3 -3
View File
@@ -19,13 +19,13 @@ fun ChipGroup.setChipsExtended(items: List<String>?, onClick: (item: String) ->
removeAllViews()
items?.forEach { item ->
val chip = makeSearchChip(item, onClick, onLongClick, sourceId, context)
val chip = context.makeSearchChip(item, onClick, onLongClick, sourceId)
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 {
return Chip(context).apply {
fun Context.makeSearchChip(item: String, onClick: (item: String) -> Unit = {}, onLongClick: (item: String) -> Unit = {}, sourceId: Long, namespace: String? = null, type: Int? = null): Chip {
return Chip(this).apply {
text = item
val search = if (namespace != null) {
SourceTagsUtil.getWrappedTag(sourceId, namespace = namespace, tag = item)