浏览代码

To be more Kotliny 😂

An An 2 年之前
父节点
当前提交
41321e0096

+ 4 - 9
charts/src/main/java/com/github/aachartmodel/aainfographics/aaoptionsmodel/AAStates.kt

@@ -144,17 +144,12 @@ class AASVGAttributes {
         return this
     }
 
+    // convert to dictionary in kotlin with let
     fun toDic(): Map<String, Any> {
         val dic: MutableMap<String, Any> = HashMap()
-        if (strokeWidth != null) {
-            dic["stroke-width"] = strokeWidth!!
-        }
-        if (fill != null) {
-            dic["fill"] = fill!!
-        }
-        if (stroke != null) {
-            dic["stroke"] = stroke!!
-        }
+        strokeWidth?.let { dic["stroke-width"] = it }
+        fill?.let { dic["fill"] = it }
+        stroke?.let { dic["stroke"] = it }
         return dic
     }