From 8b9ce384b26c414db32f98e94e088f5334869c2d Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期三, 13 十一月 2019 15:36:28 +0800 Subject: [PATCH] 全部合并了代码,安卓和 IOS 都测试通过了 --- ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs | 314 ++++++++++++++++++++++------------------------------ 1 files changed, 132 insertions(+), 182 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs index f39ebc4..1819ec7 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs @@ -1,6 +1,5 @@ 锘縰sing System; using System.Collections.Generic; -using Com.Amap.Api.Location; using Shared.Common; using ZigBee.Device; using static ZigBee.Device.BindObj; @@ -14,14 +13,8 @@ /// <param name="common">Common.</param> public void Changed(CommonDevice common) { - //if (common.Type != ZigBee.Device.DeviceType.OnOffSwitch) - //{ - // return; - //} - Shared.Application.RunOnMainThread(() => { - //var dev = common as Panel; }); } @@ -154,44 +147,6 @@ return; } } - //if (oldModeID != 65535 && oldModeID != currentModeID) - //{ - //var bindResult = await currentKey.ClearBindInfoAsync(); - //if (bindResult.clearBindInfoResponseData != null) - //{ - // if (bindResult.clearBindInfoResponseData.Result != 0) - // { - // Application.RunOnMainThread(() => - // { - // new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - // }); - // CommonPage.Loading.Hide(); - // this.RemoveFromParent(); - // btnFinifh.Enable = true; - // return; - // } - // else - // { - // currentKey.bindList.Clear(); - // } - //} - //} - //else - //{ - // foreach (var bindedDev in currentKey.bindList) - // { - // for (int i = 0; i < targetList.Count; i++) - // { - // var de = targetList[i]; - // if (de.DeviceAddr == bindedDev.BindMacAddr && de.DeviceEpoint == bindedDev.BindEpoint) - // { - // oldTargetList.Add(de); - // targetList.RemoveAt(i); - // i--; - // } - // } - // } - //} //2銆侀厤缃ā寮� Panel.SetWritableValueResponAllData temp = null; @@ -237,155 +192,146 @@ temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Wcd_Down_Stop); break; } - if (temp != null && temp.setWritableValueResponData != null && temp.setWritableValueResponData.Status == 0) + if (temp != null && temp.setWritableValueResponData != null) { - ////鍒犻櫎琚嬀鎺夌殑鏁版嵁 - //foreach (var delDev in oldTargetList) - //{ - // var delDev1 = new BindObj.BindListResponseObj(); - // delDev1.BindType = 0; - // delDev1.BindCluster = currentClusterID; - // delDev1.BindMacAddr = delDev.DeviceAddr; - // delDev1.BindEpoint = delDev.DeviceEpoint; - // var result = await BindInfo.RemoveTargets(delDev1, currentKey); - - // if (result == 0) - // { - // var bindSc = currentKey.bindList.Find(obj => - // (obj.BindType == 0 - // && obj.BindCluster == currentClusterID - // && obj.BindMacAddr == delDev.DeviceAddr - // && obj.BindEpoint == delDev.DeviceEpoint - // )); - // currentKey.bindList.Remove(bindSc); - // } - //} - - //3銆佺粦瀹氭柊鐨勬暟鎹� - var addBindeDev = new AddBindData(); - addBindeDev.DeviceAddr = currentKey.DeviceAddr; - addBindeDev.Epoint = currentKey.DeviceEpoint; - - foreach (var de in targetList) + if (temp.setWritableValueResponData.Status == 0) { - if (de.DeviceAddr != null) - { - var addBindInfo = new AddBindListObj(); - addBindInfo.BindType = 0; - addBindInfo.BindCluster = currentClusterID; - addBindInfo.BindMacAddr = de.DeviceAddr; - addBindInfo.BindEpoint = de.DeviceEpoint; - addBindeDev.BindList.Add(addBindInfo); - } - } + //3銆佺粦瀹氭柊鐨勬暟鎹� + var addBindeDev = new AddBindData(); + addBindeDev.DeviceAddr = currentKey.DeviceAddr; + addBindeDev.Epoint = currentKey.DeviceEpoint; - var dev = new AddedDeviceBindResponseAllData(); - dev = await currentKey.AddDeviceBindAsync(addBindeDev); - if (dev.addedDeviceBindResponseData == null) - { - Application.RunOnMainThread(() => + foreach (var de in targetList) { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - }); - btnFinifh.Enable = true; - btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; - } - else - { - foreach (var ab in dev.addedDeviceBindResponseData?.BindList) - { - switch (ab.Result) + if (de.DeviceAddr != null) { - case 0: - currentKey.bindList.Add((BindListResponseObj)ab); + var addBindInfo = new AddBindListObj(); + addBindInfo.BindType = 0; + addBindInfo.BindCluster = currentClusterID; + addBindInfo.BindMacAddr = de.DeviceAddr; + addBindInfo.BindEpoint = de.DeviceEpoint; + addBindeDev.BindList.Add(addBindInfo); + } + } - for (int i = 0; i < targetList.Count; i++) - { - var de = targetList[i]; - var sc1 = new SceneUI(); - if (de.DeviceAddr == null) - { - sc1 = (SceneUI)de; + var dev = new AddedDeviceBindResponseAllData(); + dev = await currentKey.AddDeviceBindAsync(addBindeDev); + if (dev.addedDeviceBindResponseData == null) + { + Application.RunOnMainThread(() => + { + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); + }); + btnFinifh.Enable = true; + btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; + } + else + { + foreach (var ab in dev.addedDeviceBindResponseData?.BindList) + { + switch (ab.Result) + { + case 0: + currentKey.bindList.Add((BindListResponseObj)ab); - if (sc1.Id == ab.BindScenesId) - { - targetList.RemoveAt(i); - i--; - } - } - } - isFinish = true; - break; - case 1: - Application.RunOnMainThread(() => - { - new Tip() + for (int i = 0; i < targetList.Count; i++) { - MaxWidth = 150, - Text = Language.StringByID(R.MyInternationalizationString.BindErrorAbsence), - Direction = AMPopTipDirection.Up, - CloseTime = 1 - }.Show(btnFinifh); - }); - break; - case 2: - var abr = dev.addBindResultResponseData?.Result; - switch (dev.addBindResultResponseData?.Result) - { - case 0: - currentKey.bindList.Add((BindListResponseObj)ab); - for (int i = 0; i < targetList.Count; i++) + var de = targetList[i]; + var sc1 = new SceneUI(); + if (de.DeviceAddr == null) { - var de = targetList[i]; - if (de.DeviceAddr == ab.BindMacAddr && de.DeviceEpoint == ab.BindEpoint) + sc1 = (SceneUI)de; + + if (sc1.Id == ab.BindScenesId) { targetList.RemoveAt(i); i--; } } - isFinish = true; - break; - case 140: - Application.RunOnMainThread(() => + } + //isFinish = true; + break; + case 1: + Application.RunOnMainThread(() => + { + new Tip() { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFull), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - }); - break; - default: - Application.RunOnMainThread(() => - { - new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - }); - break; - } - break; - case 3: - Application.RunOnMainThread(() => - { - new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindErrorExisted), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - }); - break; - case 4: - Application.RunOnMainThread(() => - { - new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - }); - break; - default: - Application.RunOnMainThread(() => - { - new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - }); - break; + MaxWidth = 150, + Text = Language.StringByID(R.MyInternationalizationString.BindErrorAbsence), + Direction = AMPopTipDirection.Up, + CloseTime = 1 + }.Show(btnFinifh); + }); + break; + case 2: + var abr = dev.addBindResultResponseData?.Result; + switch (dev.addBindResultResponseData?.Result) + { + case 0: + currentKey.bindList.Add((BindListResponseObj)ab); + for (int i = 0; i < targetList.Count; i++) + { + var de = targetList[i]; + if (de.DeviceAddr == ab.BindMacAddr && de.DeviceEpoint == ab.BindEpoint) + { + targetList.RemoveAt(i); + i--; + } + } + //isFinish = true; + break; + case 140: + Application.RunOnMainThread(() => + { + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFull), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); + }); + break; + default: + Application.RunOnMainThread(() => + { + new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindUnknownError), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); + }); + break; + } + break; + case 3: + Application.RunOnMainThread(() => + { + new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindErrorExisted), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); + }); + break; + case 4: + Application.RunOnMainThread(() => + { + new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); + }); + break; + default: + Application.RunOnMainThread(() => + { + new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindUnknownError), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); + }); + break; + } } } + } + else + { + Application.RunOnMainThread(() => + { + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ChangeBindMode), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh); + }); + btnFinifh.Enable = true; + btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; + return; } } else { Application.RunOnMainThread(() => { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ChangeBindMode), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh); + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh); }); btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; @@ -395,19 +341,23 @@ catch { } finally { - if (isFinish) + //if (isFinish) + //{ + // if (action != null) + // { + // action(currentKey.bindList); + // } + // this.RemoveFromParent(); + //} + //else + //{ + // this.RemoveFromParent(); + //} + if (action != null) { - if (action != null) - { - action(currentKey.bindList); - - } - this.RemoveFromParent(); + action(currentKey.bindList); } - else - { - this.RemoveFromParent(); - } + this.RemoveFromParent(); CommonPage.Loading.Hide(); btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; -- Gitblit v1.8.0