From deac30b7071f3512d841b6eabf73bec9baa81077 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期三, 16 十二月 2020 13:08:13 +0800 Subject: [PATCH] 2020-12-16 1.主页和信息中心增加收到通知事件处理。2.主页时间格式显示优化处理 --- HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs | 20 +++--- HDL_ON/UI/UI2/1-HomePage/HomePage.cs | 1 HDL_ON/Common/HDLCommon.cs | 2 HDL_ON/Common/Utlis.cs | 52 ++++++++++++++++ .vs/HDL_APP_Project/xs/UserPrefs.xml | 25 ++++---- HDL_ON/HDL_ON.projitems | 1 HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs | 26 +++++--- 7 files changed, 92 insertions(+), 35 deletions(-) diff --git a/.vs/HDL_APP_Project/xs/UserPrefs.xml b/.vs/HDL_APP_Project/xs/UserPrefs.xml index 7f84e0f..27cf235 100644 --- a/.vs/HDL_APP_Project/xs/UserPrefs.xml +++ b/.vs/HDL_APP_Project/xs/UserPrefs.xml @@ -1,8 +1,10 @@ 锘�<Properties StartupConfiguration="{D998E133-F0DD-4760-BE3C-461632F54DA4}|Default"> <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.00008030-00014C392121802E" /> - <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/MainPage.cs"> + <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs"> <Files> - <File FileName="HDL_ON/UI/MainPage.cs" Line="57" Column="1" /> + <File FileName="HDL_ON/UI/UI2/1-HomePage/HomePage.cs" Line="1" Column="1" /> + <File FileName="HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs" Line="1" Column="1" /> + <File FileName="HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs" Line="1" Column="1" /> </Files> <Pads> <Pad Id="ProjectPad"> @@ -10,23 +12,20 @@ <Node name="HDL_APP_Project" expanded="True"> <Node name="HDL_ON" expanded="True"> <Node name="Common" expanded="True" /> - <Node name="Entity" expanded="True" /> + <Node name="DAL" expanded="True"> + <Node name="Server" expanded="True" /> + </Node> <Node name="UI" expanded="True"> - <Node name="UI0-Public" expanded="True"> - <Node name="Widget" expanded="True" /> - </Node> - <Node name="UI1-Login" expanded="True" /> <Node name="UI2" expanded="True"> - <Node name="1-HomePage" expanded="True" /> - <Node name="4-PersonalCenter" expanded="True"> - <Node name="AboutOn" expanded="True" /> + <Node name="1-HomePage" expanded="True"> + <Node name="MessageCenterPage.cs" selected="True" /> </Node> </Node> - <Node name="MainPage.cs" selected="True" /> </Node> </Node> - <Node name="HDL-ON_Android" expanded="True" /> - <Node name="HDL-ON_iOS" expanded="True" /> + <Node name="HDL-ON_iOS" expanded="True"> + <Node name="ViewController.cs" expanded="True" /> + </Node> </Node> </State> </Pad> diff --git a/HDL_ON/Common/HDLCommon.cs b/HDL_ON/Common/HDLCommon.cs index 9fecf94..d3f1eba 100644 --- a/HDL_ON/Common/HDLCommon.cs +++ b/HDL_ON/Common/HDLCommon.cs @@ -270,7 +270,7 @@ Shared.Application.RunOnMainThread(() => { new Alert(jpushMessageInfo.Title, jpushMessageInfo.Content, Language.StringByID(StringId.Close)).Show(); - //GetPushMessageAction?.Invoke(); + GetPushMessageAction?.Invoke(); }); return; } diff --git a/HDL_ON/Common/Utlis.cs b/HDL_ON/Common/Utlis.cs index 51066b8..62cb24e 100644 --- a/HDL_ON/Common/Utlis.cs +++ b/HDL_ON/Common/Utlis.cs @@ -8,7 +8,7 @@ /// <summary> /// 甯哥敤宸ュ叿绫� /// </summary> - public class Utlis + public static class Utlis { /// <summary> /// 鍏ㄥ眬鎵撳嵃 @@ -328,7 +328,55 @@ return Language.CurrentLanguage == "Chinese" ? LanguageTypeEnum.CHINESE.ToString() : LanguageTypeEnum.ENGLISH.ToString(); } - + + #region 鏃堕棿鏍煎紡杞崲 + private const int Second = 1; + private const int Minute = 60 * Second; + private const int Hour = 60 * Minute; + private const int Day = 24 * Hour; + private const int Month = 30 * Day; + + /// <summary> + /// 鏃堕棿杞崲 + /// 灏戜簬1澶� 鏄剧ず 鏃跺垎 + /// 灏戜簬涓�骞� 鏄剧ず 鏈堟棩 + /// 澶т簬涓�骞� 鏄剧ず 骞� + /// </summary> + /// <param name="dateTime"></param> + /// <returns></returns> + public static string ToFriendlyDisplay(this DateTime dateTime) + { + var ts = DateTime.Now - dateTime; + var delta = ts.TotalSeconds; + if (delta < 24 * Hour) + { + //鏄剧ず 鏃�:鍒� + return dateTime.ToString("HH:mm"); + } + else if (delta < 12 * Month) + { + //鏄剧ず 鏈�:鏃� + return dateTime.ToString("MM/dd"); + } + else + { //鏄剧ず 骞� + return dateTime.ToString("yyyy"); + } + } + /// <summary> + /// 鏃堕棿杞崲 + /// 灏戜簬1澶� 鏄剧ず 鏃跺垎 + /// 灏戜簬涓�骞� 鏄剧ず 鏈堟棩 + /// 澶т簬涓�骞� 鏄剧ず 骞� + /// </summary> + /// <param name="dateTime"></param> + /// <returns></returns> + public static string ToFriendlyDisplay(long unixTimeStamp) + { + return ToFriendlyDisplay(UnixToDateTimeMS(unixTimeStamp)); + } + #endregion + } diff --git a/HDL_ON/HDL_ON.projitems b/HDL_ON/HDL_ON.projitems index 871a4ee..65391d5 100644 --- a/HDL_ON/HDL_ON.projitems +++ b/HDL_ON/HDL_ON.projitems @@ -291,5 +291,6 @@ <Folder Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\RoomListManage\Transfer\" /> <Folder Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\RoomListManage\AddRoom\" /> <Folder Include="$(MSBuildThisFileDirectory)UI\BindingResidence\" /> + <Folder Include="$(MSBuildThisFileDirectory)Common\Utlis\" /> </ItemGroup> </Project> \ No newline at end of file diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs index b731e9e..52fdb68 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs @@ -376,6 +376,7 @@ // 鏌ヨ鏈娑堟伅骞舵樉绀� GetUnreadPushMessages(); + RegisterGetPushMessageAction(); } catch (Exception ex) { diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs index 8fbad13..1baab0e 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs @@ -404,7 +404,7 @@ { try { - return Utlis.UnixToDateTimeWithFormatMS(time, "HH:mm"); + return Utlis.ToFriendlyDisplay(time); } catch (Exception ex) { @@ -417,13 +417,15 @@ /// </summary> void RegisterGetPushMessageAction() { - //HDLCommon.GetPushMessageAction = () => { - // if (bodyView != null) - // { - // Utlis.WriteLine("GetPushMessageAction H鏀跺埌鎺ㄩ��"); - // GetUnreadPushMessages(); - // } - //}; + Action RegisterGetPushMessageAction = () => { + if (bodyView != null) + { + //Utlis.WriteLine("GetPushMessageAction H鏀跺埌鎺ㄩ��"); + GetUnreadPushMessages(); + } + }; + + HDLCommon.GetPushMessageAction = RegisterGetPushMessageAction; } /// <summary> @@ -431,7 +433,7 @@ /// </summary> void UnregisterGetPushMessageAction() { - //HDLCommon.GetPushMessageAction = null; + HDLCommon.GetPushMessageAction = null; } #endregion diff --git a/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs b/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs index 4f8def7..87d2684 100644 --- a/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs +++ b/HDL_ON/UI/UI2/1-HomePage/MessageCenterPage.cs @@ -44,11 +44,16 @@ /// </summary> List<PushMessageInfo> PushMessageInfoList = new List<PushMessageInfo>(); + /// <summary> + /// 椤甸潰鍏抽棴鏃堕棿 + /// </summary> + Action backAction; public override void RemoveFromParent() { UnregisterGetPushMessageAction(); base.RemoveFromParent(); + backAction?.Invoke(); } /// <summary> @@ -66,7 +71,8 @@ /// <param name="backAction"></param> public void LoadPage(Action backAction) { - new TopViewDiv(bodyView, Language.StringByID(StringId.MessageCenter)).LoadTopView(backAction); + this.backAction = backAction; + new TopViewDiv(bodyView, Language.StringByID(StringId.MessageCenter)).LoadTopView(); AddTopMenuView(); AddMessageView(); @@ -631,14 +637,14 @@ /// </summary> void RegisterGetPushMessageAction() { - //HDLCommon.GetPushMessageAction = () => - //{ - // if (bodyView != null) - // { - // Utlis.WriteLine("GetPushMessageAction M鏀跺埌鎺ㄩ��"); - // GetPushMessageList(showMesType); - // } - //}; + HDLCommon.GetPushMessageAction = () => + { + if (bodyView != null) + { + //Utlis.WriteLine("GetPushMessageAction M鏀跺埌鎺ㄩ��"); + GetPushMessageList(showMesType); + } + }; } /// <summary> @@ -646,7 +652,7 @@ /// </summary> void UnregisterGetPushMessageAction() { - //HDLCommon.GetPushMessageAction = null; + HDLCommon.GetPushMessageAction = null; } #if DEBUG -- Gitblit v1.8.0