fixing a crash at text highlighting

This commit is contained in:
tibbi 2019-01-22 21:40:53 +01:00
parent 2fcdd2de0e
commit 26e4a66596
2 changed files with 7 additions and 7 deletions

View file

@ -7,7 +7,7 @@ buildscript {
propMinSdkVersion = 21
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '5.6.11'
propVersionName = '5.6.12'
kotlin_version = '1.3.11'
}

View file

@ -263,14 +263,14 @@ fun String.highlightTextPart(textToHighlight: String, color: Int, highlightAll:
// handle cases when we search for 643, but in reality the string contains it like 6-43
if (ignoreCharsBetweenDigits && indexes.isEmpty()) {
val regex = TextUtils.join("(\\D*)", textToHighlight.toCharArray().toTypedArray())
val pattern = Pattern.compile(regex)
val result = pattern.matcher(normalizeString())
if (result.find()) {
try {
try {
val regex = TextUtils.join("(\\D*)", textToHighlight.toCharArray().toTypedArray())
val pattern = Pattern.compile(regex)
val result = pattern.matcher(normalizeString())
if (result.find()) {
spannableString.setSpan(ForegroundColorSpan(color), result.start(), result.end(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE)
} catch (ignored: Exception) {
}
} catch (ignored: Exception) {
}
return spannableString