Make GalleryTagGroup groupName immutable and nonnull
This commit is contained in:
1 parent
97090a4dc6
commit
a64c7d9f22
3 files changed
+27
-30
No files matched your search
@@ -20,6 +20,6 @@ import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
class GalleryTagGroup(
|
||||
private val mTagList: ArrayList<String> = arrayListOf(),
|
||||
var groupName: String? = null,
|
||||
val groupName: String,
|
||||
private val mTagList: MutableList<String> = mutableListOf(),
|
||||
) : Parcelable, MutableList<String> by mTagList
|
||||
@@ -281,11 +281,10 @@ object GalleryDetailParser {
|
||||
|
||||
private fun parseTagGroup(element: Element): GalleryTagGroup? {
|
||||
return try {
|
||||
val group = GalleryTagGroup()
|
||||
var nameSpace = element.child(0).text()
|
||||
// Remove last ':'
|
||||
nameSpace = nameSpace.substring(0, nameSpace.length - 1)
|
||||
group.groupName = nameSpace
|
||||
val group = GalleryTagGroup(nameSpace)
|
||||
val tags = element.child(1).children()
|
||||
tags.forEach {
|
||||
var tag = it.text()
|
||||
|
||||
@@ -33,33 +33,31 @@ fun GalleryTags(
|
||||
fun String.translate() = ehTags?.takeIf { it.initialized }?.getTranslation(tag = this) ?: this
|
||||
fun String.translate(prefix: String?) = ehTags?.takeIf { it.initialized }?.getTranslation(prefix = prefix, tag = this) ?: this
|
||||
Column(modifier) {
|
||||
tags.forEach {
|
||||
tags.forEach { tagGroup ->
|
||||
Row {
|
||||
it.groupName?.run {
|
||||
BaseRoundText(
|
||||
text = translate(),
|
||||
isGroup = true,
|
||||
)
|
||||
val prefix = EhTagDatabase.namespaceToPrefix(this)
|
||||
FlowRow {
|
||||
it.forEach {
|
||||
val weak = it.startsWith('_')
|
||||
val real = it.removePrefix("_")
|
||||
val translated = real.translate(prefix)
|
||||
val tag = this@run + ":" + real
|
||||
val hapticFeedback = LocalHapticFeedback.current
|
||||
BaseRoundText(
|
||||
text = translated,
|
||||
weak = weak,
|
||||
modifier = Modifier.combinedClickable(
|
||||
onClick = { onTagClick(tag) },
|
||||
onLongClick = {
|
||||
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
onTagLongClick(translated, tag)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
BaseRoundText(
|
||||
text = tagGroup.groupName.translate(),
|
||||
isGroup = true,
|
||||
)
|
||||
val prefix = EhTagDatabase.namespaceToPrefix(tagGroup.groupName)
|
||||
FlowRow {
|
||||
tagGroup.forEach {
|
||||
val weak = it.startsWith('_')
|
||||
val real = it.removePrefix("_")
|
||||
val translated = real.translate(prefix)
|
||||
val tag = tagGroup.groupName + ":" + real
|
||||
val hapticFeedback = LocalHapticFeedback.current
|
||||
BaseRoundText(
|
||||
text = translated,
|
||||
weak = weak,
|
||||
modifier = Modifier.combinedClickable(
|
||||
onClick = { onTagClick(tag) },
|
||||
onLongClick = {
|
||||
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
onTagLongClick(translated, tag)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user