fix: 启动时闪退
This commit is contained in:
parent
2c7194cda7
commit
bd3f952108
|
|
@ -743,7 +743,13 @@ class App : Application(), IApp, SketchFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getColorByAttr(context: Context, attrId: Int): Int {
|
override fun getColorByAttr(context: Context, attrId: Int): Int {
|
||||||
return getColorByAttr(context, attrId, ThemeUtil.getCurrentTheme())
|
return when (attrId) {
|
||||||
|
R.attr.colorPrimary, R.attr.colorNewPrimary, R.attr.colorAccent -> {
|
||||||
|
getColorByAttr(context, attrId, ThemeUtil.getCurrentTheme(checkDynamic = true))
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> getColorByAttr(context, attrId, ThemeUtil.getCurrentTheme())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getColorById(context: Context, colorId: Int): Int {
|
override fun getColorById(context: Context, colorId: Int): Int {
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,10 @@ object ThemeUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun getCurrentTheme(theme: String = getRawTheme()): String {
|
fun getCurrentTheme(
|
||||||
|
theme: String = getRawTheme(),
|
||||||
|
checkDynamic: Boolean = false,
|
||||||
|
): String {
|
||||||
var nowTheme = theme
|
var nowTheme = theme
|
||||||
if (isTranslucentTheme(nowTheme)) {
|
if (isTranslucentTheme(nowTheme)) {
|
||||||
val colorTheme =
|
val colorTheme =
|
||||||
|
|
@ -289,7 +292,7 @@ object ThemeUtil {
|
||||||
} else {
|
} else {
|
||||||
THEME_TRANSLUCENT_LIGHT
|
THEME_TRANSLUCENT_LIGHT
|
||||||
}
|
}
|
||||||
} else if (isUsingDynamicTheme() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
} else if (checkDynamic && isUsingDynamicTheme() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
nowTheme = "${nowTheme}_dynamic"
|
nowTheme = "${nowTheme}_dynamic"
|
||||||
}
|
}
|
||||||
return nowTheme
|
return nowTheme
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue