From efad979b6fae76fb37a4de7e94e6bac0a85cb72c Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期二, 30 十一月 2021 13:14:28 +0800
Subject: [PATCH] 2021-11-30 1.修复乐橙Android,没调用拒接接口问题。

---
 HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs |   71 +++++++++++++++++++++++------------
 1 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
index 4a678e3..0c30e50 100644
--- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
+++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
@@ -30,21 +30,39 @@
         /// </summary>
         public static void LoadEvent_RefreshSecurityStatus()
         {
-            Application.RunOnMainThread(() =>
+            try
             {
-                if (bodyView != null)
+                Application.RunOnMainThread(() =>
                 {
-                    //foreach(var temp in FunctionList.List.securities)
-                    //{
-                    //    if(temp.status == "enable")
-                    //    {
-                    //        bodyView.btnSecurityStatus.IsSelected = true;
-                    //        return;
-                    //    }
-                    //}
-                    bodyView.btnSecurityStatus.IsSelected = SecurityCenter.Ins.InDefense;
-                }
-            });
+                    if (bodyView != null)
+                    {
+                        lock (FunctionList.List.securities)
+                        {
+                            bodyView.btnSecurityStatus.IsSelected = false;
+                            foreach (var temp in FunctionList.List.securities)
+                            {
+                                if (temp.status == "enable")
+                                {
+                                    if (temp.alarm)
+                                    {
+                                        bodyView.btnSecurityStatus.SelectedImagePath = "Collection/DefenseAlarmIcon.png";
+                                    }
+                                    else
+                                    {
+                                        bodyView.btnSecurityStatus.SelectedImagePath = "Collection/DefenseStatusIcon.png";
+                                    }
+                                    bodyView.btnSecurityStatus.IsSelected = true;
+                                    return;
+                                }
+                            }
+                        }
+                    }
+                });
+            }
+            catch (Exception ex)
+            {
+                MainPage.Log($"瀹夐槻涓婚〉鏇存柊寮傚父锛歿ex.Message}");
+            }
         }
 
         /// <summary>
@@ -203,7 +221,7 @@
             btn.MouseUpEventHandler += (sender, e) =>
             {
                 function.collect = false;
-                if (function.Spk_Prefix == FunctionCategory.Music)//澶勭悊闊充箰涓讳粠鍏崇郴
+                if (SPK.MusicSpkList().Contains(function.spk))//澶勭悊闊充箰涓讳粠鍏崇郴
                 {
                     if ((function as Music.A31MusicModel).ServerClientType == 1)
                     {
@@ -248,7 +266,6 @@
                 btnChangeScene.IsBold = false;
                 CurShowTypeIsFunction = true;
                 contentView.PageIndex = 0;
-
             };
 
             //var client = new BlufiClient();
@@ -280,7 +297,6 @@
                     btnChangeScene.TextSize = CSS.CSS_FontSize.TextFontSize;
                     btnChangeScene.IsSelected = false;
                     btnChangeScene.IsBold = false;
-                    CurShowTypeIsFunction = true;
                 }
                 else
                 {
@@ -290,7 +306,6 @@
                     btnChangeFunction.TextSize = CSS.CSS_FontSize.TextFontSize;
                     btnChangeFunction.IsSelected = false;
                     btnChangeFunction.IsBold = false;
-                    CurShowTypeIsFunction = false;
                 }
             };
         }
@@ -314,7 +329,15 @@
                                 if (function.spk == SPK.CurtainRoller || function.spk == SPK.CurtainShades || function.spk == SPK.CurtainTrietex ||
                                 function.spk == SPK.CurtainSwitch)//绐楀笜璁惧鏍规嵁鐧惧垎姣斿垽鏂紑鍏崇姸鎬�
                                 {
-                                    state = function.GetAttrState(FunctionAttributeKey.Percent) != "0";
+                                    if (function.GetAttribute(FunctionAttributeKey.Percent) != null)
+                                    {
+                                        state = function.GetAttrState(FunctionAttributeKey.Percent) != "0";
+                                    }else
+                                    {
+                                        if (function.GetAttrState(FunctionAttributeKey.OnOff) == "stop")
+                                            return;
+                                        state = function.trait_on_off.curValue.ToString() == "on";
+                                    }
                                 }
                                 else
                                 {
@@ -328,7 +351,7 @@
                                         btn.IsSelected = state;
                                         if (btn.Tag != null && btn.Tag.ToString() == "state")
                                         {
-                                            if (function.Spk_Prefix == FunctionCategory.Music)
+                                            if (SPK.MusicSpkList().Contains(function.spk))
                                             {
                                                 btn.Text = (function as Music.A31MusicModel).A31PlayStatus.Title;
                                             }
@@ -618,12 +641,12 @@
                     {
                         //鏈鐨勬秷鎭垪琛�
                         var unreadList = new List<PushMessageInfo>();
+                       
+                        var pushMessageInfoList = Newtonsoft.Json.JsonConvert.DeserializeObject<PushMessageInfoList>(result.Data.ToString());
 
-                        var pushMessageInfoList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PushMessageInfo>>(result.Data.ToString());
-
-                        if (pushMessageInfoList != null && pushMessageInfoList.Count > 0)
+                        if (pushMessageInfoList != null && pushMessageInfoList.list != null && pushMessageInfoList.list.Count > 0)
                         {
-                            foreach (var info in pushMessageInfoList)
+                            foreach (var info in pushMessageInfoList.list)
                             {
                                 if (!info.isRead)
                                 {
@@ -643,7 +666,7 @@
                             {
                                 Application.RunOnMainThread(() =>
                                 {
-                                    ShowMesBtnState(pushMessageInfoList[0], true);
+                                    ShowMesBtnState(pushMessageInfoList.list[0], true);
                                 });
                             }
                         }

--
Gitblit v1.8.0