File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed
app/src/main/java/com/osfans/trime Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -314,8 +314,11 @@ object ColorManager {
314314 m : Map <String , Any ?>,
315315 key : String? ,
316316 ): Int? {
317- val value = getColorValue(m[key].toString())
318- return if (value is Int ) value else null
317+ m[key].let {
318+ if (it == null ) return null
319+ val value = getColorValue(it.toString())
320+ return if (value is Int ) value else null
321+ }
319322 }
320323
321324 // 返回drawable。 Config 2.0
@@ -335,13 +338,16 @@ object ColorManager {
335338 m : Map <String , Any ?>,
336339 key : String ,
337340 ): Drawable ? {
338- val value = getColorValue(m[key].toString())
339- if (value is Int ) {
340- return GradientDrawable ().apply { setColor(value) }
341- } else if (value is Drawable ) {
342- return value
341+ m[key].let {
342+ if (it == null ) return null
343+ val value = getColorValue(it.toString())
344+ if (value is Int ) {
345+ return GradientDrawable ().apply { setColor(value) }
346+ } else if (value is Drawable ) {
347+ return value
348+ }
349+ return null
343350 }
344- return null
345351 }
346352
347353 // 返回图片或背景的drawable,支持null参数。 Config 2.0
Original file line number Diff line number Diff line change @@ -13,8 +13,7 @@ import timber.log.Timber
1313
1414object ColorUtils {
1515 @JvmStatic
16- fun parseColor (s : String? ): Int? {
17- if (s == null ) return null
16+ fun parseColor (s : String ): Int? {
1817 val hex: String = if (s.startsWith(" #" )) s.replace(" #" , " 0x" ) else s
1918 return try {
2019 val completed =
You can’t perform that action at this time.
0 commit comments