From 9511e30e508e91bc77c662e75587fcd16833f192 Mon Sep 17 00:00:00 2001 From: CaiYanPeng Date: Thu, 30 Sep 2021 09:06:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=93=9D=E7=89=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/Prefab/Panel/RowerHomeScript.cs | 23 ++++++++++++++++++- .../Scripts/UI/Prefab/ResultList/RouteItem.cs | 2 +- Assets/Scripts/UIManager.cs | 8 +++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs b/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs index 53abc74d..f9dbf035 100644 --- a/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs +++ b/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs @@ -1,6 +1,8 @@ using Assets.Scenes.Ride.Scripts; using Assets.Scripts; using Assets.Scripts.Apis.Models; +using Assets.Scripts.Ble.Service; +using Assets.Scripts.Devices; using Assets.Scripts.Devices.Ant; using Assets.Scripts.Devices.Ant.Interfaces; using Assets.Scripts.Devices.Ble; @@ -40,6 +42,11 @@ public class RowerHomeScript : PFUIPanel return null; } } + protected override void OnDestroy() + { + Debug.Log("銷毀"); + + } private IRowerDevice Rower { get @@ -81,6 +88,7 @@ public class RowerHomeScript : PFUIPanel bool isPause = false; protected override void Awake() { + spriteDict = new Dictionary() { {"Start",Resources.Load("Images/Rower/System_play")}, @@ -122,9 +130,21 @@ public class RowerHomeScript : PFUIPanel var mainNav = this.transform.Find("MainNav").GetComponent(); mainNav.ShowRowerTab(); transform.MyDOFade(); + App.MainDeviceAdapter.StartScan(); Init(); //transform.Find("Left/Rower").GetComponent().StartAnimation(); } + void Disconnect() + { + foreach(var d in App.MainDeviceAdapter.GetDevices()) + { + if ((d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && (d.Sensor == SensorType.Rower || d.Sensor == SensorType.HeartRate)) + { + d.Disconnect(); + } + } + App.MainDeviceAdapter.StopScan(); + } private void HandleStartOrPause() { //UIManager.ShowRowerResult(); @@ -244,6 +264,7 @@ public class RowerHomeScript : PFUIPanel Debug.Log(ex.Message); } UIManager.ShowRowerWelldone(model); + Disconnect(); Task.Run(()=> { var res = ConfigHelper.rowerApi.Add(model, files); @@ -294,6 +315,7 @@ public class RowerHomeScript : PFUIPanel Utils.showToast(null, "Please end this training."); return; } + Disconnect(); UIManager.ShowHomePanel(); } @@ -416,5 +438,4 @@ public class RowerHomeScript : PFUIPanel } } } - } diff --git a/Assets/Scripts/UI/Prefab/ResultList/RouteItem.cs b/Assets/Scripts/UI/Prefab/ResultList/RouteItem.cs index cae746e3..2a7f63d0 100644 --- a/Assets/Scripts/UI/Prefab/ResultList/RouteItem.cs +++ b/Assets/Scripts/UI/Prefab/ResultList/RouteItem.cs @@ -95,7 +95,7 @@ public class RouteItem : MonoBehaviour row1.Find("Distance").GetComponent().text = $"Distance:{result.TotalDistance}M"; row2.Find("Device").GetComponent().text = $"Rowing equipment:{result.ManufacturerName}"; left.Find("Progress").gameObject.SetActive(false); - left.Find("Main/Name").GetComponent().text = "Free rowing"; + left.Find("Main/Name").GetComponent().text = $"{result.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} Free rowing"; left.Find("Main/Time").GetComponent().text = $"{result.StartTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} ~ {result.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")}"; var rect = left.Find("Main").GetComponent(); rect.sizeDelta = new Vector2(399,rect.sizeDelta.y); diff --git a/Assets/Scripts/UIManager.cs b/Assets/Scripts/UIManager.cs index fc9b9033..c60944a6 100644 --- a/Assets/Scripts/UIManager.cs +++ b/Assets/Scripts/UIManager.cs @@ -224,10 +224,10 @@ public class UIManager : MonoBehaviour public static void ShowRowerPanel() { App.IsRowerMode = true; - App.MainDeviceAdapter.ClearDevice(); -#if UNITY_ANDROID || UNITY_IOS - App.MainDeviceAdapter.StartScan(); -#endif +// App.MainDeviceAdapter.ClearDevice(); +//#if UNITY_ANDROID || UNITY_IOS +// App.MainDeviceAdapter.StartScan(); +//#endif stack.Clear(); UIManager.Show(UIManager.Instance.RowerHomeScript, UIManager.Instance.MainPanel); }