File tree 3 files changed +29
-2
lines changed
android/src/main/java/com/tuya/smart/rnsdk/home
3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -78,13 +78,25 @@ class TuyaHomeModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
78
78
}
79
79
}
80
80
81
+ @ReactMethod
82
+ fun sortRoom (params : ReadableMap , promise : Promise ) {
83
+ if (ReactParamsCheck .checkParams(arrayOf(HOMEID , IDLIST ), params)) {
84
+ var list = ArrayList <Long >()
85
+ var length = (params.getArray(IDLIST ) as ReadableArray ).size()
86
+ for (index in 0 .. length - 1 ) {
87
+ list.add((params.getArray(IDLIST ) as ReadableArray ).getDouble(index).toLong())
88
+ }
89
+ getHomeInstance(params.getDouble(HOMEID ))?.sortRoom(list, getIResultCallback(promise))
90
+ }
91
+ }
92
+
81
93
/* 排序房间 */
82
94
@ReactMethod
83
95
fun sortHome (params : ReadableMap , promise : Promise ) {
84
96
if (ReactParamsCheck .checkParams(arrayOf(HOMEID , IDLIST ), params)) {
85
97
var list = ArrayList <Long >()
86
98
var length = (params.getArray(IDLIST ) as ReadableArray ).size()
87
- for (index in 0 .. length) {
99
+ for (index in 0 .. length - 1 ) {
88
100
list.add((params.getArray(IDLIST ) as ReadableArray ).getDouble(index).toLong())
89
101
}
90
102
getHomeInstance(params.getDouble(HOMEID ))?.sortHome(list, getIResultCallback(promise))
Original file line number Diff line number Diff line change @@ -153,7 +153,12 @@ @implementation TuyaRNHomeModule
153
153
154
154
self.currentHome = [self smartHomeWithParams: params];
155
155
156
- NSArray <TuyaSmartRoomModel *> * list = nil ;
156
+ NSMutableArray <TuyaSmartRoomModel *> * list = [NSMutableArray array ];
157
+ for (NSNumber * homeId in params[@" idList" ] ) {
158
+ TuyaSmartRoomModel *room = [[TuyaSmartRoomModel alloc ] init ];
159
+ room.roomId = [homeId longLongValue ];
160
+ [list addObject: room];
161
+ }
157
162
158
163
[self .currentHome sortRoomList: list success: ^{
159
164
[TuyaRNUtils resolverWithHandler: resolver];
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ export type DeviceDetailResponse = {
31
31
name : string ;
32
32
dps : DeviceDps ;
33
33
homeDisplayOrder : number ;
34
+ roomId : number ;
34
35
} ;
35
36
export type GetHomeDetailResponse = {
36
37
deviceList : DeviceDetailResponse [ ] ;
@@ -65,3 +66,12 @@ export type DismissHomeParams = {
65
66
export function dismissHome ( params : DismissHomeParams ) : Promise < string > {
66
67
return tuya . dismissHome ( params ) ;
67
68
}
69
+
70
+ export type SortRoomsParams = {
71
+ idList : number [ ] ;
72
+ homeId : number ;
73
+ } ;
74
+
75
+ export function sortRoom ( params : SortRoomsParams ) : Promise < string > {
76
+ return tuya . sortRoom ( params ) ;
77
+ }
You can’t perform that action at this time.
0 commit comments