From d8545fbd1b36a6766c57c987e5d89862b470fed9 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期四, 03 九月 2020 09:46:29 +0800 Subject: [PATCH] 2020-09-03 1.修改风扇默认为关状态。2.Alexa添加设备时,去掉空调和通用开关选择添加支持。 3.场景增加通用开关添加和发送控制支持,Alexa 的场景同样增加通用开关的支持。 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaDeviceListPage.cs | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 107 insertions(+), 8 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaDeviceListPage.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaDeviceListPage.cs index 9398296..82dc84f 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaDeviceListPage.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaDeviceListPage.cs @@ -319,6 +319,15 @@ DataString = device.AreaSceneID.ToString () }); } + } else if (common.Type == DeviceType.UniversalDevice) {//2020-09-02 鏂板閫氱敤寮�鍏� + var device = Newtonsoft.Json.JsonConvert.DeserializeObject<UniversalDevice> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); + if (device != null) { + uploadScene.DeviceListObject.Add (new AddCloudSceneDeviceData () { + Command = (int)Command.SetCommonSwitch, SubnetId = device.SubnetID, DeviceId = device.DeviceID, + DeviceName = device.Name, DeviceType = "UniversalDevice", LoopId = device.LoopID, + DataString = device.SendBytes[1].ToString(), + }); + } } } @@ -414,6 +423,7 @@ } } + alexaDeviceLista = ReadDeviceList (); Application.RunOnMainThread (() => { @@ -717,11 +727,53 @@ #endregion /// <summary> + /// + /// </summary> + /// <param name="bodyView"></param> + /// <param name="isScene"></param> + void AddTopTitleView (VerticalScrolViewLayout bodyView, bool isScene = false) { + var chooseTypeView = new RowLayout () { + Height = Application.GetRealHeight (80), + BackgroundColor = SkinStyle.Current.TitileView, + }; + bodyView.AddChidren (chooseTypeView); + Button btnEquipmentIcon = new Button () { + Width = Application.GetRealHeight (65), + Height = Application.GetRealHeight (65), + UnSelectedImagePath = "Item/LogicModule.png", + X = Application.GetRealWidth (30), + Gravity = Gravity.CenterVertical, + }; + chooseTypeView.AddChidren (btnEquipmentIcon); + + Button btnEquipmentType = new Button () { + Width = Application.GetRealHeight (460), + X = btnEquipmentIcon.Right, + TextAlignment = TextAlignment.CenterLeft, + Text = Language.StringByID (R.MyInternationalizationString.Device), + TextColor = SkinStyle.Current.TextColor1, + SelectedTextColor = SkinStyle.Current.DialogTextColor + }; + chooseTypeView.AddChidren (btnEquipmentType); + + if (isScene) { + btnEquipmentIcon.UnSelectedImagePath = "Scene/Scene.png"; + btnEquipmentType.Text = Language.StringByID (R.MyInternationalizationString.Scenes); + } + } + + /// <summary> /// 娣诲姞璁惧鐣岄潰 /// </summary> public void InitDevcieRow (List<UpdateDeviceObj> list, VerticalScrolViewLayout bodyView) { bodyView.RemoveAll (); + + if (list.Count > 0) { + //娣诲姞鏍囬 + AddTopTitleView (bodyView); + } + foreach (var device in list) { var rowView = new RowLayout () { Height = Application.GetRealHeight (110), @@ -747,10 +799,31 @@ alert.Show (); alert.ResultEventHandler += (s, dd) => { if (dd) { - if (DelDevice (device.Id)) { - rowView.RemoveFromParent (); - list.Remove (device); - } + //if (DelDevice (device.Id)) { + // rowView.RemoveFromParent (); + // list.Remove (device); + //} + + System.Threading.Tasks.Task.Run (() => { + Application.RunOnMainThread (() => { + MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load)); + }); + try { + var result = DelDevice (device.Id); + Application.RunOnMainThread (() => { + if (result) { + rowView.RemoveFromParent (); + list.Remove (device); + } + }); + + } catch { } finally { + + Application.RunOnMainThread (() => { + MainPage.Loading.Hide (); + }); + } + }); } }; }; @@ -762,6 +835,11 @@ /// </summary> public void InitSceneRow (List<SceneByRegion> list, VerticalScrolViewLayout bodyView) { + if (list.Count > 0) { + //娣诲姞鏍囬 + AddTopTitleView (bodyView, true); + } + foreach (var scene in list) { var rowView = new RowLayout () { Height = Application.GetRealHeight (110), @@ -793,10 +871,31 @@ alert.Show (); alert.ResultEventHandler += (s, dd) => { if (dd) { - if (DelScene (scene.SceneId)) { - rowView.RemoveFromParent (); - list.Remove (scene); - } + //if (DelScene (scene.SceneId)) { + // rowView.RemoveFromParent (); + // list.Remove (scene); + //} + + System.Threading.Tasks.Task.Run (() => { + Application.RunOnMainThread (() => { + MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load)); + }); + try { + var result = DelScene (scene.SceneId); + Application.RunOnMainThread (() => { + if (result) { + rowView.RemoveFromParent (); + list.Remove (scene); + } + }); + + } catch { } finally { + + Application.RunOnMainThread (() => { + MainPage.Loading.Hide (); + }); + } + }); } }; }; -- Gitblit v1.8.0