From 925e55bc815de89575ec53880d3e059596fda6e6 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期六, 19 十二月 2020 13:23:46 +0800
Subject: [PATCH] Merge branch 'CJL' into NewFilePath

---
 HDL-ON_iOS/ViewController.cs  |   37 ++++++++++--------
 HDL_ON/Common/HDLCommon.cs    |   30 +++++++++++++++
 HDL-ON_Android/Application.cs |   45 ++++++++++++----------
 HDL-ON_iOS/Main.cs            |    8 ++--
 4 files changed, 79 insertions(+), 41 deletions(-)

diff --git a/HDL-ON_Android/Application.cs b/HDL-ON_Android/Application.cs
index f676103..3d80e26 100644
--- a/HDL-ON_Android/Application.cs
+++ b/HDL-ON_Android/Application.cs
@@ -67,24 +67,29 @@
                 //鑾峰彇鏋佸厜鎺ㄩ�両D
                 GetJPushRegistrationID(activity);
 
-                BaseActivity.NetworkStateChanged += (int obj) =>
+                BaseActivity.NetworkStateChanged += (int internetStatus) =>
                 {
-                    if (!IsEnterBackground)
-                    {
-                        //BusSocket.Stop();
-                        new System.Threading.Thread(() =>
-                        {
-                            System.Threading.Thread.Sleep(1000);
-                            //BusSocket.Start();
-                        })
-                        { IsBackground = true }.Start();
-                    }
-                    else
-                    {
-                        Console.WriteLine("HHH 缃戠粶鍙樺寲浣嗗浜庡悗鍙�");
-                    }
-                    MainPage.InternetStatus = obj;
+                    //if (!IsEnterBackground)
+                    //{
+                    //    ////BusSocket.Stop();
+                    //    //new System.Threading.Thread(() =>
+                    //    //{
+                    //    //    System.Threading.Thread.Sleep(1000);
+                    //    //    //BusSocket.Start();
+                    //    //})
+                    //    //{ IsBackground = true }.Start();
+
+                    //}
+                    //else
+                    //{
+                    //    Console.WriteLine("HHH 缃戠粶鍙樺寲浣嗗浜庡悗鍙�");
+                    //}
+
+                    //缃戠粶鍙樺寲澶勭悊
+                    HDLCommon.Current.UpdateInternetStatus((int)internetStatus, IsEnterBackground);
                 };
+                //寮�鍚畾浣嶆湇鍔�
+                Shared.Application.StartGPSLocationService();
             };
             BaseActivity.RefreshUIAction += (activity) =>
             {
@@ -108,19 +113,19 @@
             HDLUtils.SetAuthoritiesName("com.hdl.onpro.fileProvider");
 
             //Shared.Application.IsGpsEnable = true;
-
             //鑾峰彇缁忕含搴� 
             Shared.Application.LocationAction = (lon, lat) =>
             {
                 try
                 {
                     Shared.Application.LocationAction = null;
-                    Shared.Application.StopGPSLocationService();
                     new HDL_ON.DAL.Server.HttpServerRequest().GetCityInfo(lon.ToString(), lat.ToString());
+                    //鍏抽棴瀹氫綅鏈嶅姟
+                    Shared.Application.StopGPSLocationService();
                 }
-                catch
+                  catch(Exception ex)
                 {
-
+                    Utlis.WriteLine("GetCityInfo catch"+ ex.Message);
                 }
                 MainPage.Log($"缁忕含搴�:::{lon}:{lat}");
             };
diff --git a/HDL-ON_iOS/Main.cs b/HDL-ON_iOS/Main.cs
index a54f921..b35ec68 100644
--- a/HDL-ON_iOS/Main.cs
+++ b/HDL-ON_iOS/Main.cs
@@ -1,4 +1,5 @@
-锘縰sing HDL_ON;
+锘縰sing System;
+using HDL_ON;
 using HDL_ON.DAL.Server;
 using UIKit;
 
@@ -15,12 +16,11 @@
                 try
                 {
                     Shared.Application.LocationAction = null;
-                    Shared.Application.StopGPSLocationService();
                     new HDL_ON.DAL.Server.HttpServerRequest().GetCityInfo(lon.ToString(), lat.ToString());
                 }
-                catch
+                catch(Exception ex)
                 {
-
+                    Utlis.WriteLine("GetCityInfo catch"+ ex.Message);
                 }
 
             };
diff --git a/HDL-ON_iOS/ViewController.cs b/HDL-ON_iOS/ViewController.cs
index f589fc3..d95816c 100644
--- a/HDL-ON_iOS/ViewController.cs
+++ b/HDL-ON_iOS/ViewController.cs
@@ -73,23 +73,26 @@
         void UpdateStatus(object sender, EventArgs e)
         {
             internetStatus = Reachability.InternetConnectionStatus();
-            MainPage.Log($"缃戠粶鐘舵�佸彉鍖栵紝褰撳墠缃戠粶:{internetStatus}");
-            if (internetStatus == NetworkStatus.NotReachable)//娌℃湁缃戠粶杩炴帴 0
-            {
-                Control.Ins.GatewayOnline = false;
-                Control.Ins.IsRemote = false;
-                MainPage.InternetStatus = 0;
-            }
-            else if (internetStatus == NetworkStatus.ReachableViaCarrierDataNetwork)//3,4G鐨勭綉缁滆繛鎺� 1
-            {
-                Control.Ins.SearchLoaclGateway();
-                MainPage.InternetStatus = 1;
-            }
-            else if (internetStatus == NetworkStatus.ReachableViaWiFiNetwork)
-            {
-                Control.Ins.SearchLoaclGateway();
-                MainPage.InternetStatus = 2;
-            }
+            //MainPage.Log($"缃戠粶鐘舵�佸彉鍖栵紝褰撳墠缃戠粶:{internetStatus}");
+            //缃戠粶鍙樺寲澶勭悊
+            HDLCommon.Current.UpdateInternetStatus((int)internetStatus, SharedMethod.SharedMethod.IsBackground);
+
+            //if (internetStatus == NetworkStatus.NotReachable)//娌℃湁缃戠粶杩炴帴 0
+            //{
+            //    Control.Ins.GatewayOnline = false;
+            //    Control.Ins.IsRemote = false;
+            //    MainPage.InternetStatus = 0;
+            //}
+            //else if (internetStatus == NetworkStatus.ReachableViaCarrierDataNetwork)//3,4G鐨勭綉缁滆繛鎺� 1
+            //{
+            //    Control.Ins.SearchLoaclGateway();
+            //    MainPage.InternetStatus = 1;
+            //}
+            //else if (internetStatus == NetworkStatus.ReachableViaWiFiNetwork)
+            //{
+            //    Control.Ins.SearchLoaclGateway();
+            //    MainPage.InternetStatus = 2;
+            //}
         }
     }
 }
\ No newline at end of file
diff --git a/HDL_ON/Common/HDLCommon.cs b/HDL_ON/Common/HDLCommon.cs
old mode 100755
new mode 100644
index 02943ea..2ef00d9
--- a/HDL_ON/Common/HDLCommon.cs
+++ b/HDL_ON/Common/HDLCommon.cs
@@ -6,6 +6,7 @@
 using HDL_ON.UI;
 using HDL_ON.Entity;
 using System.Threading;
+using HDL_ON.DriverLayer;
 
 namespace HDL_ON
 {
@@ -381,6 +382,35 @@
         {
             return string.IsNullOrEmpty(userName) ? Language.StringByID(StringId.UsersWhoNameIsEmpty) : userName;
         }
+
+
+        /// <summary>
+        /// 鐩戝惉缃戠粶鍙樺寲鍚庡鐞嗕簨浠�
+        /// 鍒锋柊缃戠粶鐘舵��
+        /// </summary>
+        /// <param name="internetStatus">缃戠粶鍙樺寲</param>
+        /// <param name="IsEnterBackground">鏄惁杩涘叆浜嗗悗鍙�</param>
+        public void UpdateInternetStatus(int internetStatus, bool IsEnterBackground = false)
+        {
+            MainPage.Log($"缃戠粶鐘舵�佸彉鍖栵紝褰撳墠缃戠粶:{internetStatus} 鏄惁鍚庡彴:{IsEnterBackground.ToString()}");
+
+            if (internetStatus == 0)//娌℃湁缃戠粶杩炴帴 0
+            {
+                Control.Ins.GatewayOnline = false;
+                Control.Ins.IsRemote = false;
+                MainPage.InternetStatus = 0;
+            }
+            else if (internetStatus == 1)//3,4G鐨勭綉缁滆繛鎺� 1
+            {
+                Control.Ins.SearchLoaclGateway();
+                MainPage.InternetStatus = 1;
+            }
+            else if (internetStatus == 2)//WiFi缃戠粶
+            {
+                Control.Ins.SearchLoaclGateway();
+                MainPage.InternetStatus = 2;
+            }
+        }
         #endregion
     }
 }

--
Gitblit v1.8.0