xm
2021-12-01 6d73bf6e816570291865674bef8bce8972e4de3f
HDL_ON/UI/UI2/UserPage.cs
@@ -1,11 +1,13 @@
using System;
using HDL_ON.Entity;
using Shared;
using HDL_ON.UI.CSS;
using HDL_ON.DAL.Server;
namespace HDL_ON.UI
{
    public partial class UserPage : FrameLayout
    {
        #region 控件列表
        /// <summary>
        /// 当前区域
@@ -15,6 +17,7 @@
        /// 内容区域
        /// </summary>
        FrameLayout ContextView;
        //VerticalRefreshLayout ContextView;
        /// <summary>
        /// 导航栏区域
        /// </summary>
@@ -83,42 +86,74 @@
        #endregion
        #endregion
        /// <summary>
        /// 当前动画效果
        /// 0:收藏
        /// 1:分类
        /// 2:智能
        /// 3:个人
        /// </summary>
        int CurAnimationEffect = 0;
        public void LoadPage()
        {
            bodyView = this;
            bodyView.BackgroundColor = CSS.CSS_Color.MainBackgroundColor;
            ContextView = new FrameLayout()
            try
            {
                Height = Application.GetRealHeight(618+20),
                BackgroundColor = CSS.CSS_Color.BackgroundColor,
            };
            bodyView.AddChidren(ContextView);
                bodyView = this;
                bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
                ContextView = new FrameLayout()
                {
                    Height = Application.GetRealHeight(618 + 17),//导航栏底部界限
                    BackgroundColor = CSS_Color.BackgroundColor,
                };
                bodyView.AddChidren(ContextView);
            navigationView = new FrameLayout()
            {
                Y = Application.GetRealHeight(607),
                Height = Application.GetMinRealAverage(60),
            };
            bodyView.AddChidren(navigationView);
            if (MainPage.Increase)
            {
                //ContextView.Height = Application.GetRealHeight(618 + 20);
                navigationView.Y = Application.GetRealHeight(597+5);
                navigationView.Height = Application.GetRealHeight(70-5);
                navigationView = new FrameLayout()
                {
                    Y = Application.GetRealHeight(607),
                    Height = Application.GetMinRealAverage(60),
                    //BackgroundColor = CSS_Color.BackgroundColor
                };
                bodyView.AddChidren(navigationView);
                if (MainPage.Increase)
                {
                    //ContextView.Height = Application.GetRealHeight(618 + 20);
                    navigationView.Y = Application.GetRealHeight(597 + 5);
                    navigationView.Height = Application.GetRealHeight(70 - 5);
                }
                InitBottomView();
                LoadEventList();
                var homePage = new HomePage();
                ContextView.AddChidren(homePage);
                homePage.LoadPage();
                if (!MainPage.NoLoginMode)
                {
                    //注册推送ID
                    RegisteredPush();
                }
                //2020-12-07 增加版本检测更新方法
                HDLCommon.Current.CheckIfNeedForceUpdate();
#if __Android__
                //开启定位服务
                Shared.Application.StartGPSLocationService();
                if (DB_ResidenceData.Instance.NeedTip) {
                    DB_ResidenceData.Instance.LastTipTime = DateTime.Now;
                    if (CN.Jpush.Android.Api.JPushInterface.IsNotificationEnabled(Shared.Application.Activity) != 1)
                    {
                        Action action = () =>
                        {
                            CN.Jpush.Android.Api.JPushInterface.GoToAppNotificationSettings(Shared.Application.Activity);
                        };
                        Shared.Application.RunOnMainThread(() =>
                        {
                            new HDL_ON.UI.ConfirmDialog().ShowDialog(StringId.Tip, StringId.Android_MessagePushTip, action);
                        });
                    }
                }
#endif
            }
            InitBottomView();
            LoadEventList();
            catch (Exception ex)
            {
                MainPage.Log($"UserPage error {ex.Message}");
            }
        }
        /// <summary>
@@ -128,10 +163,10 @@
        {
            navigationSelectionView = new FrameLayout()
            {
                X = Application.GetMinRealAverage(0 - 94 * 3),
                X = Application.GetRealWidth(0 - 94 * 3),
                Y = Application.GetMinRealAverage(4),
                Width = Application.GetMinRealAverage(94 * 7),
                Height = Application.GetMinRealAverage(38),
                Width = Application.GetRealWidth(94 * 7),
                Height = Application.GetRealWidth(38),
                BackgroundImagePath = "Navigation/UserPageNavbg.png",
            };
            navigationView.AddChidren(navigationSelectionView);
@@ -139,10 +174,10 @@
            btnNavigationSelectionIcon = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetMinRealAverage(6),
                Width = Application.GetMinRealAverage(22),
                Height = Application.GetMinRealAverage(22),
                UnSelectedImagePath = "Navigation/CollectionIconOn.png",
                Y = Application.GetRealWidth(6),
                Width = Application.GetRealWidth(22),
                Height = Application.GetRealWidth(22),
                UnSelectedImagePath = "Navigation/HomePageIconOn.png",
            };
            navigationSelectionView.AddChidren(btnNavigationSelectionIcon);
@@ -154,7 +189,7 @@
            };
            navigationView.AddChidren(NavigationSubView);
            #region 收藏区域
#region 收藏区域
            collectionView = new FrameLayout() {
                Width  = Application.GetRealWidth(94),
            };
@@ -164,7 +199,7 @@
                Y = Application.GetRealHeight(5),
                Width = Application.GetMinRealAverage(22),
                Height = Application.GetMinRealAverage(22),
                UnSelectedImagePath = "Navigation/CollectionIcon.png",
                UnSelectedImagePath = "Navigation/HomePageIcon.png",
                SelectedImagePath = "Public/transparent.png",
                IsSelected = true,
            };
@@ -174,16 +209,17 @@
                Gravity = Gravity.CenterHorizontal,
                Y = btnCollectionIcon.Bottom,
                Height = Application.GetRealHeight(16),
                SelectedTextColor = CSS.CSS_Color.MainColor,
                TextColor =CSS.CSS_Color.FirstLevelTitleColor,
                TextSize = CSS.CSS_FontSize.PromptFontSize_SecondaryLevel,
                SelectedTextColor = CSS_Color.MainColor,
                TextColor =CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                TextID = StringId.Collection,
                TextAlignment = TextAlignment.Center,
                IsSelected = true,
            };
            collectionView.AddChidren(btnCollectionText);
            #endregion
#endregion
            #region 分类区域
#region 分类区域
            classificationView = new FrameLayout()
            {
                Width = Application.GetRealWidth(94),
@@ -205,16 +241,16 @@
                Gravity = Gravity.CenterHorizontal,
                Y = btnCollectionIcon.Bottom,
                Height = Application.GetRealHeight(16),
                SelectedTextColor = CSS.CSS_Color.MainColor,
                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
                TextSize = CSS.CSS_FontSize.PromptFontSize_SecondaryLevel,
                SelectedTextColor = CSS_Color.MainColor,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                TextID = StringId.Classification,
                TextAlignment = TextAlignment.Center,
            };
            classificationView.AddChidren(btnClassificationText);
            #endregion
#endregion
            #region 智能区域
#region 智能区域
            intellectualizationView = new FrameLayout()
            {
                Width = Application.GetRealWidth(94),
@@ -236,16 +272,16 @@
                Gravity = Gravity.CenterHorizontal,
                Y = btnCollectionIcon.Bottom,
                Height = Application.GetRealHeight(16),
                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
                SelectedTextColor = CSS.CSS_Color.MainColor,
                TextSize = CSS.CSS_FontSize.PromptFontSize_SecondaryLevel,
                TextColor = CSS_Color.FirstLevelTitleColor,
                SelectedTextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                TextID = StringId.Intellectualization,
                TextAlignment = TextAlignment.Center,
            };
            intellectualizationView.AddChidren(btnIntellectualizationText);
            #endregion
#endregion
            
            #region 个人中心
#region 个人中心
            personalCenterView = new FrameLayout()
            {
                Width = Application.GetRealWidth(94),
@@ -269,27 +305,29 @@
                Gravity = Gravity.CenterHorizontal,
                Y = btnCollectionIcon.Bottom,
                Height = Application.GetRealHeight(16),
                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
                SelectedTextColor = CSS.CSS_Color.MainColor,
                TextSize = CSS.CSS_FontSize.PromptFontSize_SecondaryLevel,
                TextColor = CSS_Color.FirstLevelTitleColor,
                SelectedTextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                TextID = StringId.Personal,
                TextAlignment = TextAlignment.Center,
            };
            personalCenterView.AddChidren(btnPersonalCenterText);
            #endregion
#endregion
            var homePage = new HomePage();
            ContextView.AddChidren(homePage);
            homePage.LoadPage();
        }
        /// <summary>
        /// 切换到收藏界面
        /// </summary>
        void ChooseCollection()
        public void ChooseCollection()
        {
            CurAnimationEffect = 0;
            if (MainPage.CurPageIndex == 0)
            {
                return;
            }
            btnClassificationIcon.IsSelected = false;
            btnIntellectualizationIcon.IsSelected = false;
            btnPersonalCenterIcon.IsSelected = false;
@@ -297,25 +335,27 @@
            btnClassificationText.IsSelected = false;
            btnIntellectualizationText.IsSelected = false;
            btnPersonalCenterText.IsSelected = false;
            #region 移动动画
            var distance = navigationSelectionView.X - collectionView.X + Application.GetMinRealAverage(94*3);
#region 移动动画
            //移动距离
            var distance = navigationSelectionView.X - collectionView.X + Application.GetRealWidth(94*3);
            int total = 10;
            int sleepTime = 300;
            if (distance > 200)
            {
                sleepTime = 600;
                sleepTime = 400;
                total = 30;
            }
            else if (distance > 100)
            {
                sleepTime = 450;
                total = 20;
            }
            distance /= total;
            new System.Threading.Thread(() => {
                int index = 0;
                while (index < total+1) {
                    if (CurAnimationEffect != 0)
                MainPage.CurPageIndex = 0;
                while (index < total+1)
                {
                    if (MainPage.CurPageIndex != 0)
                    {
                        break;
                    }
@@ -328,7 +368,7 @@
                        }
                        else
                        {
                            navigationSelectionView.X = collectionView.X - Application.GetMinRealAverage(94 * 3);
                            navigationSelectionView.X = collectionView.X - Application.GetRealWidth(94 * 3);
                            btnCollectionText.IsSelected = true;
                            btnCollectionIcon.IsSelected = true;
                            btnClassificationIcon.IsSelected = false;
@@ -337,10 +377,11 @@
                            btnClassificationText.IsSelected = false;
                            btnIntellectualizationText.IsSelected = false;
                            btnPersonalCenterText.IsSelected = false;
                            btnNavigationSelectionIcon.UnSelectedImagePath = "Navigation/HomePageIconOn.png";
                        }
                        if (index == (total/2))
                        {
                            btnNavigationSelectionIcon.UnSelectedImagePath = "Navigation/CollectionIconOn.png";
                            btnNavigationSelectionIcon.UnSelectedImagePath = "Navigation/HomePageIconOn.png";
                        }
                        //旋转
                        btnNavigationSelectionIcon.SetRotation(-36f * index);
@@ -348,8 +389,13 @@
                    System.Threading.Thread.Sleep(sleepTime / total);
                    index++;
                }
            }) { IsBackground = true }.Start();
            #endregion
                Application.RunOnMainThread(() =>
                {
                    btnNavigationSelectionIcon.SetRotation(0f);
                });
            }) { IsBackground = true ,Priority = System.Threading.ThreadPriority.Highest}.Start();
#endregion
            ContextView.RemoveAll();
            var homePage = new HomePage();
            ContextView.AddChidren(homePage);
@@ -360,7 +406,10 @@
        /// </summary>
        void ChooseClassification()
        {
            CurAnimationEffect = 1;
            if (MainPage.CurPageIndex == 1)
            {
                return;
            }
            btnCollectionIcon.IsSelected = false;
            btnIntellectualizationIcon.IsSelected = false;
            btnPersonalCenterIcon.IsSelected = false;
@@ -368,22 +417,26 @@
            btnClassificationText.IsSelected = false;
            btnIntellectualizationText.IsSelected = false;
            btnPersonalCenterText.IsSelected = false;
            #region 移动动画
            var distance = navigationSelectionView.X - classificationView.X + Application.GetMinRealAverage(94 * 3);
#region 移动动画
            var distance = navigationSelectionView.X - classificationView.X + Application.GetRealWidth(94 * 3);
            int total = 10;
            int sleepTime = 300;
            if (distance > 100 || distance < -100)
            {
                sleepTime = 450;
                total = 20;
            }
            distance /= total;
            new System.Threading.Thread(() =>
            {
                if (MainPage.CurPageIndex == 1)
                {
                    return;
                }
                MainPage.CurPageIndex = 1;
                int index = 0;
                while (index < total+1)
                {
                    if (CurAnimationEffect != 1)
                    if (MainPage.CurPageIndex != 1)
                    {
                        break;
                    }
@@ -396,7 +449,7 @@
                        }
                        else
                        {
                            navigationSelectionView.X = classificationView.X - Application.GetMinRealAverage(94 * 3);
                            navigationSelectionView.X = classificationView.X - Application.GetRealWidth(94 * 3);
                            btnClassificationText.IsSelected = true;
                            btnClassificationIcon.IsSelected = true;
                            btnCollectionIcon.IsSelected = false;
@@ -405,6 +458,7 @@
                            btnCollectionText.IsSelected = false;
                            btnIntellectualizationText.IsSelected = false;
                            btnPersonalCenterText.IsSelected = false;
                            btnNavigationSelectionIcon.UnSelectedImagePath = "Navigation/ClassificationIconOn.png";
                        }
                        if (index == (total / 2 ))
                        {
@@ -423,9 +477,14 @@
                    System.Threading.Thread.Sleep(sleepTime / total);
                    index++;
                }
                Application.RunOnMainThread(() =>
                {
                    btnNavigationSelectionIcon.SetRotation(0f);
                });
            })
            { IsBackground = true }.Start();
            #endregion
            { IsBackground = true, Priority = System.Threading.ThreadPriority.Highest }.Start();
#endregion
            ContextView.RemoveAll();
            var classificaitionView = new ClassificationPage();
            ContextView.AddChidren(classificaitionView);
@@ -438,7 +497,10 @@
        /// </summary>
        void ChooseIntellectualization()
        {
            CurAnimationEffect = 2;
            if (MainPage.CurPageIndex == 2)
            {
                return;
            }
            btnCollectionText.IsSelected = false;
            btnClassificationText.IsSelected = false;
            btnIntellectualizationText.IsSelected = false;
@@ -446,21 +508,25 @@
            btnCollectionIcon.IsSelected = false;
            btnClassificationIcon.IsSelected = false;
            btnPersonalCenterIcon.IsSelected = false;
            #region 移动动画
            var distance = navigationSelectionView.X - intellectualizationView.X + Application.GetMinRealAverage(94 * 3);
#region 移动动画
            var distance = navigationSelectionView.X - intellectualizationView.X + Application.GetRealWidth(94 * 3);
            int total = 10;
            int sleepTime = 300;
            if (distance > 100 || distance < -100)
            {
                sleepTime = 450;
                total = 20;
            }
            distance /= total;
            new System.Threading.Thread(() => {
                if (MainPage.CurPageIndex == 2)
                {
                    return;
                }
                MainPage.CurPageIndex = 2;
                int index = 0;
                while (index < total+1)
                {
                    if(CurAnimationEffect!=2)
                    if(MainPage.CurPageIndex!=2)
                    {
                        break;
                    }
@@ -473,7 +539,7 @@
                        }
                        else
                        {
                            navigationSelectionView.X = intellectualizationView.X - Application.GetMinRealAverage(94 * 3);
                            navigationSelectionView.X = intellectualizationView.X - Application.GetRealWidth(94 * 3);
                            btnIntellectualizationText.IsSelected = true;
                            btnIntellectualizationIcon.IsSelected = true;
                            btnCollectionText.IsSelected = false;
@@ -482,6 +548,7 @@
                            btnCollectionIcon.IsSelected = false;
                            btnClassificationIcon.IsSelected = false;
                            btnPersonalCenterIcon.IsSelected = false;
                            btnNavigationSelectionIcon.UnSelectedImagePath = "Navigation/IntellectualizationIconOn.png";
                        }
                        if (index == (total / 2 ))
                        {
@@ -500,18 +567,31 @@
                    System.Threading.Thread.Sleep(sleepTime / total);
                    index++;
                }
                Application.RunOnMainThread(() =>
                {
                    btnNavigationSelectionIcon.SetRotation(0f);
                });
            })
            { IsBackground = true }.Start();
            #endregion
            { IsBackground = true, Priority = System.Threading.ThreadPriority.Highest }.Start();
#endregion
            ContextView.RemoveAll();
            var intelligenceView = new IntelligencePage();
            ContextView.AddChidren(intelligenceView);
            intelligenceView.LoadPage();
        }
        /// <summary>
        /// 切换到个人中心界面
        /// </summary>
        void ChoosePersonalCenter()
        public void ChoosePersonalCenter()
        {
            CurAnimationEffect = 3;
            if (MainPage.CurPageIndex == 3)
            {
                return;
            }
            btnCollectionText.IsSelected = false;
            btnClassificationText.IsSelected = false;
            btnIntellectualizationText.IsSelected = false;
@@ -519,26 +599,26 @@
            btnCollectionIcon.IsSelected = false;
            btnClassificationIcon.IsSelected = false;
            btnIntellectualizationIcon.IsSelected = false;
            #region 移动动画
            var distance = navigationSelectionView.X - personalCenterView.X + Application.GetMinRealAverage(94 * 3);
#region 移动动画
            var distance = navigationSelectionView.X - personalCenterView.X + Application.GetRealWidth(94 * 3);
            int total = 10;
            int sleepTime = 300;
            if (distance < -200)
            {
                sleepTime = 600;
                sleepTime = 400;
                total = 30;
            }
            else if (distance < -100)
            {
                sleepTime = 450;
                total = 20;
            }
            distance /= total;
            new System.Threading.Thread(() => {
                MainPage.CurPageIndex = 3;
                int index = 0;
                while (index < total+1)
                {
                    if (CurAnimationEffect != 3)
                    if (MainPage.CurPageIndex != 3)
                    {
                        break;
                    }
@@ -551,7 +631,7 @@
                        }
                        else
                        {
                            navigationSelectionView.X = personalCenterView.X - Application.GetMinRealAverage(94 * 3);
                            navigationSelectionView.X = personalCenterView.X - Application.GetRealWidth(94 * 3);
                            btnPersonalCenterText.IsSelected = true;
                            btnPersonalCenterIcon.IsSelected = true;
                            btnCollectionText.IsSelected = false;
@@ -560,6 +640,7 @@
                            btnCollectionIcon.IsSelected = false;
                            btnClassificationIcon.IsSelected = false;
                            btnIntellectualizationIcon.IsSelected = false;
                            btnNavigationSelectionIcon.UnSelectedImagePath = "Navigation/PersonalCenterIconOn.png";
                        }
                        if (index == (total / 2 ))
                        {
@@ -571,10 +652,13 @@
                    System.Threading.Thread.Sleep(sleepTime / total);
                    index++;
                }
                Application.RunOnMainThread(() =>
                {
                    btnNavigationSelectionIcon.SetRotation(0f);
                });
            })
            { IsBackground = true }.Start();
            #endregion
            { IsBackground = true, Priority = System.Threading.ThreadPriority.Highest }.Start();
#endregion
            ContextView.RemoveAll();
            var personalCenterPage = new UI.PersonalCenterPage();
@@ -582,5 +666,12 @@
            personalCenterPage.LoadView();
        }
        /// <summary>
        /// 注册推送
        /// </summary>
        void RegisteredPush()
        {
            new HttpServerRequest().RegisteredPush();
        }
    }
}