HDL-ON_Android/Application.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDL-ON_iOS/Main.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDL-ON_iOS/ViewController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDL_ON/Common/HDLCommon.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
HDL-ON_Android/Application.cs
@@ -67,24 +67,29 @@ //获取极光推送ID 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}"); }; HDL-ON_iOS/Main.cs
@@ -1,4 +1,5 @@ using HDL_ON; using 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); } }; 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; //} } } } HDL_ON/Common/HDLCommon.csold mode 100755 new mode 100644
@@ -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 } }