fix detekt

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2025-02-17 16:36:40 +01:00
parent f418955e1d
commit edcadbcd37
No known key found for this signature in database
GPG Key ID: F7AA2A8B65B50220
2 changed files with 26 additions and 20 deletions

View File

@ -29,8 +29,7 @@ class ChatUtils {
if (individualHashMap != null) {
val type = individualHashMap["type"]
resultMessage = if (type == "user" || type == "guest" || type == "call" || type == "email" ||
type == "circle"
resultMessage = if (type == "user" || type == "guest" || type == "call" || type == "email"
) {
resultMessage?.replace("{$key}", "@" + individualHashMap["name"])
} else if (type == "geo-location") {

View File

@ -144,7 +144,20 @@ class MessageUtils(val context: Context) {
}
}
else -> {
val spannable = SpannableStringBuilder(messageStringInternal)
messageStringInternal = defaultMessageParameters(messageStringInternal, individualHashMap, key)
}
}
}
}
return messageStringInternal
}
private fun defaultMessageParameters(
messageString: Spanned,
individualHashMap: HashMap<String?, String?>,
key: String?
):Spanned {
val spannable = SpannableStringBuilder(messageString)
val placeholder = "{$key}"
val replacementText = individualHashMap["name"]
var start = spannable.indexOf(placeholder)
@ -154,18 +167,12 @@ class MessageUtils(val context: Context) {
spannable.setSpan(
StyleSpan(Typeface.BOLD),
start,
start + replacementText!!
.length,
start + replacementText!!.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
start = spannable.indexOf(placeholder, start + replacementText.length)
}
messageStringInternal = spannable
}
}
}
}
return messageStringInternal
return spannable
}
fun getRenderedMarkdownText(context: Context, markdown: String, textColor: Int): Spanned {