From 09bde2ffef953fa5e78a4320aa8bbe03276ed7c5 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 23 三月 2021 09:19:54 +0800 Subject: [PATCH] Merge branch 'WJC' into temp-wxr --- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs | 146 ++++++++++++++---------------------------------- 1 files changed, 44 insertions(+), 102 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs index 19bca3c..e65cb76 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs @@ -9,12 +9,13 @@ public class Method { /// <summary> - /// 绋嬪簭涓诲叆鍙� + /// 绾㈠瀹濈▼搴忎富鍏ュ彛 /// </summary> /// <param name="frame"></param> /// <param name="function"></param> public void MainView(FrameLayout frame, Entity.Function function,Action action) { + Pir pirDevice = new Pir(); if (function != null) {//鏁版嵁杞崲 @@ -32,7 +33,8 @@ MainPage.BasePageView.AddChidren(page); page.Show(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - page.BackAction += () => { + PirMain.BackAction += () => + { action?.Invoke(); }; }); @@ -211,25 +213,10 @@ var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Pir>(str); if (pirJosn != null) { - -/* 椤圭洰鈥淗DL-ON_iOS鈥濈殑鏈悎骞剁殑鏇存敼 -鍦ㄦ涔嬪墠: - if (null == Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId)) -鍦ㄦ涔嬪悗: - if (null == list.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId)) -*/ + if (null == PirDevice.Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId)) - { - - -/* 椤圭洰鈥淗DL-ON_iOS鈥濈殑鏈悎骞剁殑鏇存敼 -鍦ㄦ涔嬪墠: - Pir.pirDeviceList.Add(pirJosn); -鍦ㄦ涔嬪悗: - list.pirDeviceList.Add(pirJosn); -*/ + { PirDevice.Pir.pirDeviceList.Add(pirJosn); - } } } @@ -286,7 +273,7 @@ var pirDevice = Pir.pirDeviceList[i]; try { - var responsePackNew = PirSend.ControlList(pirDevice); + var responsePackNew = PirSend.ControlList(pirDevice.deviceId); if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") { var jArray = JArray.Parse(responsePackNew.Data.ToString()); @@ -331,57 +318,27 @@ /// 鑾峰彇鍗曚釜绾㈠瀹濋仴鎺у櫒鍒楄〃 /// </summary> /// <param name="action">鍥炶皟鍑芥暟</param> - public static void GetControlList(FrameLayout frame ,Action action, Pir pirDevice) + public static void GetControlList(FrameLayout frame, Action action, Pir pirDevice) { - Loading loading = new Loading(); - frame.AddChidren(loading); - loading.Start(); - new System.Threading.Thread(() => - { - try - { - - try - { - var responsePackNew = PirSend.ControlList(pirDevice); - if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") - { - var jArray = JArray.Parse(responsePackNew.Data.ToString()); - for (int a = 0; a < jArray.Count; a++) - { - var jay = jArray[a]; - //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄 - var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); - var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str); - if (pirJosn != null) - { - if (null == pirDevice.FunctioList.Find((c) => c.sid == pirJosn.sid)) - { - pirDevice.FunctioList.Add(pirJosn); - } - } - - } - } - - } - catch { } - - - } - catch { } - finally - { - - Application.RunOnMainThread(() => - { - loading.Hide(); - action(); - }); - } - - }) - { IsBackground = true }.Start(); + ThreadSend(new Control { deviceId = pirDevice.deviceId }, (responsePackNew) => + { + var jArray = JArray.Parse(responsePackNew.Data.ToString()); + for (int a = 0; a < jArray.Count; a++) + { + var jay = jArray[a]; + //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄 + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); + var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str); + if (pirJosn != null) + { + if (null == pirDevice.FunctioList.Find((c) => c.deviceId == pirJosn.deviceId)) + { + pirDevice.FunctioList.Add(pirJosn); + } + } + } + action(); + }, "鑾峰彇閬ユ帶鍣ㄥ垪琛�", "frame", frame, null); } /// <summary> @@ -392,37 +349,12 @@ /// <param name="action">鍥炶皟鍑芥暟</param> public void GetControl(FrameLayout frame, Control control, Action<Entity.Function> action) { - Entity.Function function = null; - //鍔犺浇log - Loading loading = new Loading(); - frame.AddChidren(loading); - loading.Start(); - new System.Threading.Thread(() => + ThreadSend(control, (responsePackNew) => { - try - { - // 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid) - var responsePackNew = PirSend.GetinfoBySid(control); - if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") - { - //var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data.ToString()); - function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(responsePackNew.Data.ToString()); - } - } - catch { } - finally - { - Application.RunOnMainThread(() => - { - loading.Hide(); - action(function); - }); - } - - }) - { IsBackground = true }.Start(); + var function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(responsePackNew.Data.ToString()); + action(function); + }, "鑾峰彇璁惧璇︽儏", "frame", frame, null); } - /// <summary> /// 鍙戦�佸懡浠ょ嚎绋� /// </summary> @@ -460,8 +392,18 @@ responsePackNew = PirSend.DeviceRename(control.deviceId, control.name); } - else if (str == "鍒犻櫎鎸夐敭") { - // responsePackNew = PirSend.CodeRemove(control.deviceId, control.name); + else if (str == "鍒犻櫎鎸夐敭") + { + // responsePackNew = PirSend.CodeRemove(control.deviceId, control.name); + } + else if (str == "鑾峰彇璁惧璇︽儏") + { + // 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid) + responsePackNew = PirSend.GetinfoBySid(control); + } + else if (str == "鑾峰彇閬ユ帶鍣ㄥ垪琛�") + { + responsePackNew = PirSend.ControlList(control.deviceId); } } catch { } @@ -519,7 +461,7 @@ str = buttondata; } - if (!string.IsNullOrEmpty(controldata)) + if (!string.IsNullOrEmpty(str)) { try { -- Gitblit v1.8.0