From f441a3c49f8b5cedee3e4def6fbb448ef40eb9cb Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期三, 10 六月 2020 14:46:58 +0800
Subject: [PATCH] Crabtree-ON 2020-06-10 基于最新HDL ON 优化问题,Crabtree-ONAPP部分功能同步修改优化调整 1. 增加大图片大文件上传处理. 2.远程连接交互提示,由原来的Loading修改成顶部Tip提示。 3.灯光全开、全关和场景控制多线程发送,和HDLON同样加锁处理。 4.Android ,判断移动网络失败,网络监测修复方法修改,后台前台切换优化。

---
 Crabtree/ON.Ios/AppDelegate.cs |  102 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 81 insertions(+), 21 deletions(-)

diff --git a/Crabtree/ON.Ios/AppDelegate.cs b/Crabtree/ON.Ios/AppDelegate.cs
index 1793927..813897b 100644
--- a/Crabtree/ON.Ios/AppDelegate.cs
+++ b/Crabtree/ON.Ios/AppDelegate.cs
@@ -33,7 +33,7 @@
     // The UIApplicationDelegate for the application. This class is responsible for launching the
     // User Interface of the application, as well as listening (and optionally responding) to application events from iOS.FinishLaunching
     [Register ("AppDelegate")]
-    public class AppDelegate : BaseApplicationDelegate
+    public class AppDelegate : BaseApplicationDelegateForHdlOn
     {
         public override UIWindow Window{
             get;
@@ -73,7 +73,9 @@
         public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
         {
             AppCenter.Start ("44cbdfbf-d33e-4e92-a795-1c4452e54d3e", typeof (Analytics), typeof (Crashes));
-            Console.WriteLine ("FinishedLaunching");
+            Utlis.WriteLine ("FinishedLaunching");
+            //Shared.Application.IsGpsEnable = false;
+
             base.FinishedLaunching (application, launchOptions);
 
 
@@ -109,7 +111,7 @@
             }
 
             if (UIApplication.SharedApplication.ApplicationIconBadgeNumber > 0) {
-                RemoteInfo.Current.ReadMsgList (NSUserDefaults.StandardUserDefaults.StringForKey ("PushDeviceToken"), true);
+                //RemoteInfo.Current.ReadMsgList (NSUserDefaults.StandardUserDefaults.StringForKey ("PushDeviceToken"), true);
             }
             //if (UserConfig.Instance.SkinCode == 0) {
                 application.StatusBarStyle = UIStatusBarStyle.DarkContent;
@@ -162,23 +164,23 @@
 
         public override void DidReceiveRemoteNotification (UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
         {
-            Console.WriteLine ("DidReceiveRemoteNotification:" + application.ApplicationState.ToString ());
+            Utlis.WriteLine ("DidReceiveRemoteNotification:" + application.ApplicationState.ToString ());
 
             UserConfig.Instance.SaveUserConfig ();
 
-            RemoteInfo.Current.ReadMsgList (NSUserDefaults.StandardUserDefaults.StringForKey ("PushDeviceToken"),
-                                            application.ApplicationState == UIApplicationState.Active ? true : false);
+            //RemoteInfo.Current.ReadMsgList (NSUserDefaults.StandardUserDefaults.StringForKey ("PushDeviceToken"),
+            //                                application.ApplicationState == UIApplicationState.Active ? true : false);
             UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
         }
 
         public override void ReceivedRemoteNotification (UIApplication application, NSDictionary userInfo)
         {
             if (application.ApplicationState == UIApplicationState.Active) {
-                Console.WriteLine ("ReceivedRemoteNotification1");
+                Utlis.WriteLine ("ReceivedRemoteNotification1");
             } else if (application.ApplicationState == UIApplicationState.Background) {
-                Console.WriteLine ("ReceivedRemoteNotification2");
+                Utlis.WriteLine ("ReceivedRemoteNotification2");
             } else if (application.ApplicationState == UIApplicationState.Inactive) {
-                Console.WriteLine ("ReceivedRemoteNotification3");
+                Utlis.WriteLine ("ReceivedRemoteNotification3");
             }
 
             //string extKey1 = "PushResType"; 
@@ -188,38 +190,96 @@
 
         public override void OnResignActivation (UIApplication application)
         {
-            Console.WriteLine ("OnResignActivation");
-            Shared.BusSocket.Stop ();
+            Utlis.WriteLine ("OnResignActivation");
+            //Shared.BusSocket.Stop ();
+            //BusSocketStop ();
         }
 
         public override void DidEnterBackground (UIApplication application)
         {
             SharedMethod.SharedMethod.IsBackground = true;
-            Console.WriteLine ("DidEnterBackground");
+            Utlis.WriteLine ("DidEnterBackground");
+            BusSocketStop ();
         }
 
         public override void WillEnterForeground (UIApplication application)
         {
             SharedMethod.SharedMethod.IsBackground = false;
-            Console.WriteLine ("WillEnterForeground");
+            Utlis.WriteLine ("WillEnterForeground");
             //if (UIApplication.SharedApplication.ApplicationIconBadgeNumber > 0)
             //    RemoteInfo.Current.ReadMsgList (NSUserDefaults.StandardUserDefaults.StringForKey ("PushDeviceToken"), true);
             UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
             // Called as part of the transiton from background to active state.
             // Here you can undo many of the changes made on entering the background.
+            BusSocketStart ();
         }
 
         public override void WillTerminate (UIApplication application)
         {
-            Console.WriteLine ("WillTerminate");
+            Utlis.WriteLine ("WillTerminate");
             // Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
         }
 
         public override void OnActivated (UIApplication application)
         {
-            Console.WriteLine ("OnActivated");
+            Utlis.WriteLine ("OnActivated");
             base.OnActivated (application);
 
+            //BusSocketStart ();
+            ////鏈変簺绯荤粺鐗堟湰杩欓噷鍚姩姣旇鍥炬帶鍒跺櫒蹇�
+            //if (!Shared.SimpleControl.MainPage.Showed) {
+            //    System.Threading.Tasks.Task.Run (() => {
+            //        while (true) {
+            //            System.Threading.Thread.Sleep (10);
+            //            if (Shared.SimpleControl.MainPage.Showed) {
+            //                break;
+            //            }
+            //        }
+            //        Shared.Application.RunOnMainThread (() => {
+            //            Shared.BusSocket.Start (6000);
+            //            Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote ((int)Reachability.InternetConnectionStatus (),false);
+            //            //RemoteInfo.Current.ReadMsgList (NSUserDefaults.StandardUserDefaults.StringForKey ("PushDeviceToken"), true);
+            //            if (SmartHome.WiFiSet.refreshView != null) {
+            //                SmartHome.WiFiSet.refreshView ();
+            //            }
+            //        });
+            //    });
+            //    return;
+            //}
+            //Shared.BusSocket.Start (6000);
+            //Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote ((int)Reachability.InternetConnectionStatus (), false);
+            //if (SmartHome.WiFiSet.refreshView != null) {
+            //    SmartHome.WiFiSet.refreshView ();
+            //}
+
+
+            //com.freeview.global.Video.FVapplicationDidBecomeActive (application);
+        }
+
+        //DateTime closeTime = DateTime.MinValue;
+        /// <summary>
+        /// BusSocketStop
+        /// </summary>
+        void BusSocketStop ()
+        {
+            Shared.BusSocket.Stop ();
+            //closeTime = DateTime.Now;
+        }
+
+
+        /// <summary>
+        /// BusSocketStart
+        /// </summary>
+        void BusSocketStart ()
+        {
+
+            //if (closeTime == DateTime.MinValue) {
+            //    closeTime = DateTime.Now;
+            //} else if (closeTime.AddMinutes (2) > DateTime.Now) {
+            //    // MqttCommon.DisConnectRemoteMqttClient ();
+            //}
+
+            var netStatus = (int)Reachability.InternetConnectionStatus ();
             //鏈変簺绯荤粺鐗堟湰杩欓噷鍚姩姣旇鍥炬帶鍒跺櫒蹇�
             if (!Shared.SimpleControl.MainPage.Showed) {
                 System.Threading.Tasks.Task.Run (() => {
@@ -231,23 +291,23 @@
                     }
                     Shared.Application.RunOnMainThread (() => {
                         Shared.BusSocket.Start (6000);
-                        Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote ((int)Reachability.InternetConnectionStatus ());
-                        RemoteInfo.Current.ReadMsgList (NSUserDefaults.StandardUserDefaults.StringForKey ("PushDeviceToken"), true);
+                        Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote (netStatus, false);
+                        //RemoteInfo.Current.ReadMsgList (true);
                         if (SmartHome.WiFiSet.refreshView != null) {
                             SmartHome.WiFiSet.refreshView ();
                         }
                     });
                 });
                 return;
+            } else {
+                Shared.BusSocket.Start (6000);
+                Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote (netStatus, false);
+                //RemoteInfo.Current.ReadMsgList (true);
             }
-            Shared.BusSocket.Start (6000);
-            Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote ((int)Reachability.InternetConnectionStatus ());
             if (SmartHome.WiFiSet.refreshView != null) {
                 SmartHome.WiFiSet.refreshView ();
             }
 
-
-            //com.freeview.global.Video.FVapplicationDidBecomeActive (application);
         }
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0