mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Use color parser
This commit is contained in:
parent
ddadefdbd6
commit
1cb91ca5df
1 changed files with 4 additions and 3 deletions
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package im.vector.app.features.home.room.detail.timeline.helper
|
package im.vector.app.features.home.room.detail.timeline.helper
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
import androidx.annotation.VisibleForTesting
|
import androidx.annotation.VisibleForTesting
|
||||||
|
@ -69,10 +70,10 @@ class MatrixItemColorProvider @Inject constructor(
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (colorText.first() == '#') {
|
if (colorText.length == 1) {
|
||||||
(colorText.substring(1).toLong(radix = 16) or 0xff000000L).toInt()
|
|
||||||
} else {
|
|
||||||
colorProvider.getColor(getUserColorByIndex(colorText.toInt()))
|
colorProvider.getColor(getUserColorByIndex(colorText.toInt()))
|
||||||
|
} else {
|
||||||
|
Color.parseColor(colorText)
|
||||||
}
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
Timber.e(e, "Unable to parse color $colorText")
|
Timber.e(e, "Unable to parse color $colorText")
|
||||||
|
|
Loading…
Reference in a new issue