Skip to content

Commit 0585aba

Browse files
committed
腾讯连连支持字符串枚举
http://tapd.oa.com/NEW_IOT/prong/stories/view/1020393192866423729 Change-Id: I056611c5d7eb630ffeb6748f2d79584715c3a5b6
1 parent dd44880 commit 0585aba

File tree

8 files changed

+29
-13
lines changed

8 files changed

+29
-13
lines changed

app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/DeviceModeInfoActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class DeviceModeInfoActivity : BaseActivity(), MyCallback {
6464
if (devModeInfo.define == null) return
6565

6666
var type = devModeInfo.define!!.get("type")
67-
if (type == "bool" || type == "enum") {
67+
if (type == "bool" || type == "enum" || type == "stringenum") {
6868
showMapDialog(pos, devModeInfo)
6969
} else if (type == "int") {
7070
showNumDialog(true, pos, devModeInfo)

app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/EditAutoicTaskActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ class EditAutoicTaskActivity : BaseActivity(), MyCallback {
834834
if (devModeInfo.id == task.actionId) {
835835
task.taskTip = devModeInfo.name
836836
var type = devModeInfo.define!!.get("type")
837-
if (type == "bool" || type == "enum") {
837+
if (type == "bool" || type == "enum" || type == "stringenum") {
838838
var mapJson = devModeInfo.define!!.getJSONObject("mapping")
839839
for (key in mapJson.keys) {
840840
if (key == task.taskKey) {

app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/EditManualTaskActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class EditManualTaskActivity : BaseActivity(), MyCallback {
164164
if (devModeInfo.id == task.actionId) {
165165
task.taskTip = devModeInfo.name
166166
var type = devModeInfo.define!!.get("type")
167-
if (type == "bool" || type == "enum") {
167+
if (type == "bool" || type == "enum" || type == "stringenum") {
168168
var mapJson = devModeInfo.define!!.getJSONObject("mapping")
169169
for (key in mapJson.keys) {
170170
if (key == task.taskKey) {

app/src/main/java/com/tencent/iot/explorer/link/kitlink/entity/DevicePropertyEntity.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,21 @@ class DevicePropertyEntity {
7979

8080
fun getValue(): String {
8181
return when {
82-
isEnumType() -> value?.toString() ?: "0"
82+
isEnumType() -> {
83+
if (valueType == "enum") {
84+
value?.toString() ?: "0"
85+
} else {
86+
var ret = "0"
87+
enumEntity?.mapping?.keys?.let {
88+
for (key in it) {
89+
ret = key
90+
break
91+
}
92+
}
93+
ret
94+
value?.toString() ?: ret
95+
}
96+
}
8397
isNumberType() -> value?.toString()?.toDouble()?.toInt()?.toString()
8498
?: numberEntity!!.min.toDouble().toInt().toString()
8599
isTimestampType() -> value?.toString() ?: "0"
@@ -134,7 +148,7 @@ class DevicePropertyEntity {
134148
}
135149

136150
fun isEnumType(): Boolean {
137-
if (valueType == "enum") {
151+
if (valueType == "enum" || valueType == "stringenum") {
138152
return true
139153
}
140154
return false

app/src/main/java/com/tencent/iot/explorer/link/kitlink/fragment/HomeFragment.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ class HomeFragment : BaseFragment(), HomeFragmentView, MyCallback, PayloadMessag
426426
devOption.id = devModeInfo.id
427427
devOption.res = res
428428
var type = devModeInfo.define!!.get("type")
429-
if (type == "bool" || type == "enum") {
429+
if (type == "bool" || type == "enum" || type == "stringenum") {
430430
var mapJson = devModeInfo.define!!.getJSONObject("mapping")
431431
devOption.mapJson = mapJson
432432
devOption.type = DevOption.TYPE_LIST
@@ -445,7 +445,7 @@ class HomeFragment : BaseFragment(), HomeFragmentView, MyCallback, PayloadMessag
445445
for (devData in dev.deviceDataList) {
446446
if (devModeInfo.id == devData.id) {
447447
var type = devModeInfo.define!!.get("type")
448-
if (type == "bool" || type == "enum") {
448+
if (type == "bool" || type == "enum" || type == "stringenum") {
449449
var mapJson = devModeInfo.define!!.getJSONObject("mapping")
450450
if (!TextUtils.isEmpty(devData.value)) {
451451
devOption.value = mapJson.getString(devData.value)
@@ -469,7 +469,7 @@ class HomeFragment : BaseFragment(), HomeFragmentView, MyCallback, PayloadMessag
469469
if (!hasValue) {
470470
var initData = DeviceDataEntity()
471471
initData.id = devModeInfo.id
472-
if (type == "bool" || type == "enum") {
472+
if (type == "bool" || type == "enum" || type == "stringenum") {
473473

474474
} else if (type == "int" || type == "float") {
475475

sdk/explorer-link-android/src/main/java/com/tencent/iot/explorer/link/core/auth/entity/ControlPanel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ControlPanel {
4747

4848
fun isEnumType(): Boolean {
4949
return when (valueType) {
50-
"enum" -> true
50+
"enum", "stringenum" -> true
5151
else -> false
5252
}
5353
}

sdk/explorer-link-android/src/main/java/com/tencent/iot/explorer/link/core/auth/entity/EventParam.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.tencent.iot.explorer.link.core.auth.entity
22

3+
import android.util.Log
34
import com.alibaba.fastjson.JSON
45
import com.tencent.iot.explorer.link.core.auth.util.JsonManager
56

@@ -20,7 +21,7 @@ class EventParam {
2021
"int", "float" -> {
2122
productDefine = JsonManager.parseJson(define, NumberDefine::class.java)
2223
}
23-
"enum" -> {
24+
"enum", "stringenum" -> {
2425
productDefine = JsonManager.parseJson(define, EnumDefine::class.java)
2526
}
2627
"bool" -> {
@@ -58,7 +59,7 @@ class EventParam {
5859

5960
fun isEnumType(): Boolean {
6061
return when (getType()) {
61-
"enum" -> true
62+
"enum", "stringenum" -> true
6263
else -> false
6364
}
6465
}

sdk/explorer-link-android/src/main/java/com/tencent/iot/explorer/link/core/auth/entity/ProductProperty.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.tencent.iot.explorer.link.core.auth.entity
22

3+
import android.util.Log
34
import com.alibaba.fastjson.JSON
45
import com.alibaba.fastjson.JSONObject
56
import com.tencent.iot.explorer.link.core.auth.util.JsonManager
@@ -28,7 +29,7 @@ class ProductProperty {
2829
"int", "float" -> {
2930
productDefine = JsonManager.parseJson(define, NumberDefine::class.java)
3031
}
31-
"enum" -> {
32+
"enum", "stringenum" -> {
3233
productDefine = JsonManager.parseJson(define, EnumDefine::class.java)
3334
}
3435
"bool" -> {
@@ -71,7 +72,7 @@ class ProductProperty {
7172

7273
fun isEnumType(): Boolean {
7374
return when (getType()) {
74-
"enum" -> true
75+
"enum", "stringenum" -> true
7576
else -> false
7677
}
7778
}

0 commit comments

Comments
 (0)