From 0e1c6c25b1b0961d324811ff2132717a80f99efe Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期日, 26 四月 2020 14:15:05 +0800 Subject: [PATCH] 2020-04-26 1.添加住宅和修改住宅时,改为子线程操作。 2.远程连接模式时,禁用搜索网关和添加设备。3.修复切换住宅时,提示远程连接Loading不关闭问题。 --- Crabtree/ON/Application.cs | 103 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 62 insertions(+), 41 deletions(-) diff --git a/Crabtree/ON/Application.cs b/Crabtree/ON/Application.cs index 231d2e0..6a5a33e 100644 --- a/Crabtree/ON/Application.cs +++ b/Crabtree/ON/Application.cs @@ -3,8 +3,8 @@ using Android.Content; using Android.Net; using Android.OS; -using CN.Jpush.Android.Api; -using CN.Jpush.Android.Service; +//using CN.Jpush.Android.Api; +//using CN.Jpush.Android.Service; using Java.Lang; using Java.Util; using Java.Util.Zip; @@ -42,12 +42,26 @@ [Android.App.Application] public class Application : Android.App.Application { + static void reStartApp (Android.App.Application application) + { + var intent = new Intent (application, typeof (BaseActivity)); + intent.AddFlags (ActivityFlags.NewTask); + application.StartActivity (intent); + Android.OS.Process.KillProcess (Android.OS.Process.MyPid ()); + } + public Application (IntPtr handle, Android.Runtime.JniHandleOwnership ownerShip) : base (handle, ownerShip) { } public override void OnCreate () { - initAll (); + if (Shared.Application.Activity != null) { + reStartApp (this); + return; + } + //Shared.Application.IsGpsEnable = false; base.OnCreate (); + + initAll (); } /// <summary> @@ -61,10 +75,9 @@ //BaseActivity.KeepScreenON = false; - BaseActivity.BackKeyAction = () => { if (Shared.SimpleControl.MainPage.Loading != null) { - Console.WriteLine (MainPage.Loading.CurStatus); + Utlis.WriteLine (MainPage.Loading.CurStatus); if (Shared.SimpleControl.MainPage.Loading.CurStatus) { Shared.SimpleControl.MainPage.Loading.Hide (); return; @@ -73,7 +86,7 @@ //if(BaseActivity.VerifyDateTime == DateTime.MaxValue) { } else try { var lastView = Shared.Application.MainPage.GetChildren (Shared.Application.MainPage.ChildrenCount - 1); - Console.WriteLine ("lastView " + lastView); + Utlis.WriteLine ("lastView " + lastView); if (MainPage.Loading.CurStatus) { return; } @@ -82,26 +95,26 @@ BaseActivity.VerifyDateTime = DateTime.MaxValue; return; } else { - Console.WriteLine ("Remove Dialog!!!!"); + Utlis.WriteLine ("Remove Dialog!!!!"); var lastView2 = Shared.Application.MainPage.GetChildren (Shared.Application.MainPage.ChildrenCount - 2); lastView.RemoveFromParent (); lastView2.RemoveFromParent (); - Console.WriteLine ("Remove Dialog End!!!!"); + Utlis.WriteLine ("Remove Dialog End!!!!"); BaseActivity.VerifyDateTime = DateTime.MinValue; return; } } } catch (System.Exception ezx) { - Console.WriteLine (ezx.Message); + Utlis.WriteLine (ezx.Message); } if (SharedMethod.SharedMethod.CurPageLayout != null) { if (SharedMethod.SharedMethod.CurPageLayout.ChildrenCount > 1) { - Console.WriteLine ("Remove PageLayout Children!!!!"); + Utlis.WriteLine ("Remove PageLayout Children!!!!"); SharedMethod.SharedMethod.CurPageLayout.GetChildren (SharedMethod.SharedMethod.CurPageLayout.ChildrenCount - 1).RemoveFromParent (); - Console.WriteLine ("Remove PageLayout Children End!!!!"); + Utlis.WriteLine ("Remove PageLayout Children End!!!!"); BaseActivity.VerifyDateTime = DateTime.MinValue; } else { - Console.WriteLine ("BaseActivity.VerifyDateTime = DateTime.MaxValue"); + Utlis.WriteLine ("BaseActivity.VerifyDateTime = DateTime.MaxValue"); BaseActivity.VerifyDateTime = DateTime.MaxValue; } } @@ -113,17 +126,18 @@ init (); BaseActivity.OnCreateActoin += (activity, application) => { Microsoft.AppCenter.AppCenter.Start ("d0f0f0c5-88af-494b-93af-9a667801b7a3", typeof (Microsoft.AppCenter.Analytics.Analytics), typeof (Microsoft.AppCenter.Crashes.Crashes)); - //淇濆瓨鑾峰彇鐨勬瀬鍏夋湇鍔″櫒涓婄殑娉ㄥ唽ID鍒版湰鍦版枃浠� - var tokenID = JPushInterface.GetRegistrationID (activity); - if (!string.IsNullOrEmpty (tokenID) && UserConfig.Instance.tokenID != tokenID) { - UserConfig.Instance.tokenID = tokenID; - UserConfig.Instance.SaveUserConfig (); - } + ////淇濆瓨鑾峰彇鐨勬瀬鍏夋湇鍔″櫒涓婄殑娉ㄥ唽ID鍒版湰鍦版枃浠� + //var tokenID = JPushInterface.GetRegistrationID (activity); + //if (!string.IsNullOrEmpty (tokenID) && UserConfig.Instance.tokenID != tokenID) { + // UserConfig.Instance.tokenID = tokenID; + // UserConfig.Instance.SaveUserConfig (); + //} BaseActivity.NetworkStateChanged += (int obj) => { - Console.WriteLine ("NetworkStateChanged " + obj); + Utlis.WriteLine ("NetworkStateChanged " + obj); UserConfig.Instance.internetStatus = obj; UserConfig.Instance.SaveUserConfig (); - EquipmentPublicClass.CheckLinkRemote (obj); + //缃戠粶鍙樺寲閫氱煡 + EquipmentPublicClass.CheckLinkRemote (obj, false); }; }; BaseActivity.RefreshUIAction += (activity) => { @@ -144,6 +158,7 @@ BaseActivity.OnDestroyAction += (activity) => { BusSocket.Stop (); }; + HDLUtils.SetAuthoritiesName ("com.hdl.crabtreenew.fileProvider"); } public static bool IsShowTip = true; void init () @@ -151,35 +166,41 @@ Shared.Application.Skin = UserConfig.Instance.CurrentSkinName; SkinStyle.Current.ChangeColor (); UserConfig.Instance.phoneName = Android.OS.Build.Manufacturer; - //璁剧疆鏋佸厜璋冭瘯妯″紡锛屼负false鏃跺彧鎵撳嵃璀﹀憡淇℃伅 - JPushInterface.SetDebugMode (false); - JPushInterface.Init (this);//淇濆瓨鎵嬫満鍚嶇О鍒版湰鍦版枃浠� + ////璁剧疆鏋佸厜璋冭瘯妯″紡锛屼负false鏃跺彧鎵撳嵃璀﹀憡淇℃伅 + //JPushInterface.SetDebugMode (false); + //JPushInterface.Init (this);//淇濆瓨鎵嬫満鍚嶇О鍒版湰鍦版枃浠� //鑾峰彇缁忕含搴� Shared.Application.LocationAction = (arg1, arg2) => { - Shared.Application.LocationAction = null; - System.Threading.Tasks.Task.Run (() => { - while (true) { - try { - Shared.SimpleControl.CommonPage.AirQuality = new service.hdlcontrol.com_WebServiceAirQuality.WebServiceAirQuality ().GetAirQuality (arg2.ToString (), arg1.ToString ()); - if (Shared.SimpleControl.CommonPage.AirQuality != null) - break; - } catch { } - } - Shared.Application.RunOnMainThread (() => { - if (CommonPage.RefreshAir != null) - CommonPage.RefreshAir (); + + try { + Shared.Application.LocationAction = null; + Shared.Application.StopGPSLocationService (); + + System.Threading.Tasks.Task.Run (() => { + while (true) { + try { + Shared.SimpleControl.CommonPage.AirQuality = new service.hdlcontrol.com_WebServiceAirQuality.WebServiceAirQuality ().GetAirQuality (arg2.ToString (), arg1.ToString ()); + if (Shared.SimpleControl.CommonPage.AirQuality != null) + break; + } catch { } + } + Shared.Application.RunOnMainThread (() => { + if (CommonPage.RefreshAir != null) + CommonPage.RefreshAir (); + }); }); - }); + } catch { + } }; } void checkSomeInfo () { - RemoteInfo.Current.ReadMsgList (UserConfig.Instance.tokenID, IsShowTip); - JPushInterface.ClearAllNotifications (this); + //RemoteInfo.Current.ReadMsgList (UserConfig.Instance.tokenID, IsShowTip); + //JPushInterface.ClearAllNotifications (this); IsShowTip = true; var status = isNetworkAvailable (this); - Console.WriteLine ("status!!!" + status); + Utlis.WriteLine ("status!!!" + status); int internetStatus = 0; if (status) { var isWifi = isWifiConnected (this); @@ -189,8 +210,8 @@ internetStatus = 1; } } - Console.WriteLine (""); - Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote (internetStatus,false); + Utlis.WriteLine (""); + Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote (internetStatus, false); } bool isNetworkAvailable (Context context) -- Gitblit v1.8.0