react-native-gizwits-sdk-v5 1.3.15 → 1.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.gizwits.reactnativegizwitssdkv5
|
|
2
2
|
import com.facebook.react.bridge.Callback
|
|
3
3
|
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.facebook.react.bridge.ReadableNativeMap
|
|
4
5
|
import com.gizwits.smart.sdk.GizDevice
|
|
5
6
|
import com.gizwits.smart.sdk.GizSDKManager
|
|
6
7
|
import com.gizwits.smart.sdk.exception.GizException
|
|
@@ -14,9 +15,17 @@ interface DeviceParams{
|
|
|
14
15
|
}
|
|
15
16
|
class RNGizParamsChecker {
|
|
16
17
|
companion object {
|
|
18
|
+
|
|
19
|
+
private fun convertReadableMapToJson(readableMap: ReadableMap): String {
|
|
20
|
+
val readableNativeMap = readableMap as ReadableNativeMap
|
|
21
|
+
val hashMap = readableNativeMap.toHashMap()
|
|
22
|
+
val gson = Gson()
|
|
23
|
+
return gson.toJson(hashMap)
|
|
24
|
+
}
|
|
25
|
+
|
|
17
26
|
fun <T : Any> check(options: ReadableMap, result: Callback, paramsType: Class<T>): T? {
|
|
18
27
|
val gson = Gson()
|
|
19
|
-
val jsonString = options
|
|
28
|
+
val jsonString = convertReadableMapToJson(options)
|
|
20
29
|
try {
|
|
21
30
|
return gson.fromJson(jsonString, paramsType)
|
|
22
31
|
} catch (e: JsonSyntaxException) {
|