wei
2021-01-04 5c25f9546d0954befb202910540a5ac59af1adfe
HDL_ON/UI/MainPage.cs
@@ -44,10 +44,6 @@
        /// 无登录模式
        /// </summary>
        public static bool NoLoginMode = false;
        ///// <summary>
        ///// 远程模式
        ///// </summary>
        //public static bool IsRemote = false;
        /// <summary>
        /// 网络连接状态
        /// 0:无网络
@@ -180,6 +176,7 @@
                    Application.RunOnMainThread(() =>
                    {
                        waitPage.Hide();
                        waitPage.RemoveFromParent();
                        BaseView.RemoveAll();
                        BasePageView = new PageLayout();
                        BasePageView.ScrollEnabled = false;
@@ -207,9 +204,9 @@
                        BaseView.AddChidren(BasePageView);
                        //跳转页面----
                        var userPage = new UserPage();
                        BasePageView.AddChidren(userPage);
                        userPage.LoadPage();
                        var UserBasePage = new UserPage();
                        BasePageView.AddChidren(UserBasePage);
                        UserBasePage.LoadPage();
                        BasePageView.PageIndex = 0;
                        if (isFirstOpen)
@@ -240,46 +237,53 @@
        }
        /// <summary>
        /// 初始化app所需要的数据
        /// 后退事件
        /// 0:后退
        /// 1:有等待界面
        /// 2:无法再后退,可以执行退到桌面
        /// </summary>
        public static void InitializationData1()
        public static int LoadEvent_BackAction()
        {
            //new System.Threading.Thread(() =>
            //{
            //    int count = 0;
            //    while (count< 10)
            //    {
            //        if (Entity.DB_ResidenceData.Instance.CheckWhetherGatewayIdIsNull() )//|| Entity.DB_ResidenceData.residenceData.HomeGateway == null)
            //        {
            //            System.Threading.Thread.Sleep(200);
            //        }
            //        else
            //        {
            //            break;
            //        }
            //        count++;
            //    }
            //    if(Entity.DB_ResidenceData.Instance.CheckWhetherGatewayIdIsNull())
            //    {
            //        return;
            //    }
            //    //System.Threading.Thread.Sleep(2000);
            //    #region 读取云端数据--
            //    //todo数据覆盖处理
            //    //读取云端房间、楼层数据
            //    Entity.SpatialInfo.CurrentSpatial.DownloadRoomList();
            //    //读取云端设备数据
            //    Entity.FunctionList.List.DownloadFunctionList();
            //    //读取云端场景数据
            //    Entity.FunctionList.List.DownloadSceneList();
            //    //读取逻辑列表
            //    UI.UI2.Intelligence.Automation.MainView.GetLogicList();
            //    #endregion
            //})
            //{ IsBackground = true }.Start();
            int result = 0;
            Application.RunOnMainThread(() =>
            {
                if (BaseView.ChildrenCount>1)
                {
                    var view = BaseView.GetChildren(BaseView.ChildrenCount - 1);
                    if(view.GetType() == typeof(Loading))
                    {
                        var loading  = view as Loading;
                        if (loading.CurStatus == false)//有一些等待界面隐藏了,但是没有移除到,需要先移除
                        {
                            loading.RemoveFromParent();
                            result = LoadEvent_BackAction();
                        }
                        else
                        {
                            result = 1;//正在等待某些操作
                        }
                    }
                }
                else
                {
                    if (BasePageView.ChildrenCount > 1)
                    {
                        int index = BasePageView.ChildrenCount - 1;
                        var view = BasePageView.GetChildren(index);
                        if (view != null)
                        {
                            view.RemoveFromParent();
                        }
                    }
                    else
                    {
                        result = 2;//无法再后退,可以执行退到桌面
                    }
                }
            });
            return result;
        }
        /// <summary>
        /// 自定义日志输出
@@ -291,30 +295,6 @@
#endif
        }
        /// <summary>
        /// 生成13位时间戳
        /// </summary>
        /// <param name="value">时间</param>
        /// <returns></returns>
        public static long GetTimestamp13bit(DateTime value)
        {
            return new DateTimeOffset(value).ToUnixTimeSeconds();
        }
        /// <summary>
        /// 获取时间
        /// </summary>
        /// <param name="timestamp"></param>
        /// <returns></returns>
        public static DateTime GetDateTime (long timestamp)
        {
            long begtime = timestamp * 10000000;
            DateTime dt_1970 = new DateTime(1970, 1, 1, 0, 0, 0);
            long tricks_1970 = dt_1970.Ticks;//1970年1月1日刻度
            long time_tricks = tricks_1970 + begtime;//日志日期刻度
            DateTime dt = new DateTime(time_tricks);//转化为DateTime
            return dt;
        }
    }