Explorar o código

千山万水bug修复,相册列表排序代码整理为前后端共享.

hexiaojie %!s(int64=2) %!d(string=hai) anos
pai
achega
41f417823f

+ 9 - 21
GameClient/Assets/Game/HotUpdate/Data/PoemPhotoDataManager.cs

@@ -39,8 +39,9 @@ namespace GFGGame
             {
                 poemPhotoDatas = WsqsPhotoInfos;
             }
+            
             poemPhotoDatas.Add(photoData);
-            SortInfos(poemPhotoDatas);
+            poemPhotoDatas.SortInfos();
         }
         public void Remove(List<long> pictureIds, int sourceType)
         {
@@ -66,7 +67,8 @@ namespace GFGGame
                     }
                 }
             }
-            SortInfos(poemPhotoDatas);
+            
+            poemPhotoDatas.SortInfos();
         }
 
         public void ChangeLockingState(long pictureId, bool state, int sourceType)
@@ -88,8 +90,8 @@ namespace GFGGame
                     break;
                 }
             }
-            SortInfos(poemPhotoDatas);
-
+            
+            poemPhotoDatas.SortInfos();
         }
 
 
@@ -112,24 +114,10 @@ namespace GFGGame
                     break;
                 }
             }
-            SortInfos(poemPhotoDatas);
-
-        }
-        private List<PoemPhotoData> SortInfos(List<PoemPhotoData> photoInfos)
-        {
-            photoInfos.Sort((PoemPhotoData a, PoemPhotoData b) =>
-            {
-                if (a.ToppingStatus && !b.ToppingStatus) return -1;
-                if (b.ToppingStatus && !a.ToppingStatus) return 1;
-
-                if (a.CreationTime < b.CreationTime) return 1;
-                if (a.CreationTime > b.CreationTime) return -1;
-
-                return 0;
-            });
-
-            return photoInfos;
+            
+            poemPhotoDatas.SortInfos();
         }
+        
         public PoemPhotoData GetPersonalPhotoDataById(long pictureId)
         {
             for (int i = 0; i < PersonalPhotoInfos.Count; i++)

+ 0 - 90
GameClient/Assets/Game/HotUpdate/Utils/ListUtil.cs

@@ -1,90 +0,0 @@
-using System.Collections.Generic;
-
-namespace GFGGame
-{
-    public class ListUtil
-    {
-        /// <summary>
-        /// 用来做泛型数据切换,上一条,下一条...
-        /// </summary>
-        /// <param name="list"></param>
-        /// <param name="type"></param>
-        /// <param name="currentIndex">当前处于的索引</param>
-        /// <param name="newIndex">操作数据之后返回的数据的索引,也就是最新的索引</param>
-        /// <typeparam name="T"></typeparam>
-        /// <returns></returns>
-        public static T Navigate<T>(List<T> list, NavigateType type, int currentIndex, out int newIndex) where T : new()
-        {
-            if (type == NavigateType.Previous)
-            {
-                //如果已经是最前面的一条数据,则切换到最后一条数据,形成一个切换循环
-                if (currentIndex <= 0)
-                {
-                    currentIndex = list.Count - 1;
-                    newIndex = currentIndex;
-                    return list[currentIndex];
-                }
-            }
-            else if (type == NavigateType.Next)
-            {
-                //如果已经是最后一条数据,则切换到第一条数据,形成一个切换循环
-                if (currentIndex >= list.Count - 1)
-                {
-                    currentIndex = 0;
-                    newIndex = currentIndex;
-                    return list[currentIndex];
-                }
-            }
-            else
-            {
-                newIndex = currentIndex;
-                return list[currentIndex];
-            }
-
-            int previousIndex = currentIndex - 1;
-            int nextIndex = currentIndex + 1;
-
-            if (previousIndex < 0 && nextIndex >= list.Count)
-            {
-                newIndex = currentIndex;
-                return list[currentIndex];
-            }
-
-            if (type == NavigateType.Previous && previousIndex >= 0)
-            {
-                newIndex = previousIndex;
-                return list[previousIndex];
-            }
-
-            if (type == NavigateType.Next && nextIndex < list.Count)
-            {
-                newIndex = nextIndex;
-                return list[nextIndex];
-            }
-
-            newIndex = currentIndex;
-            return list[currentIndex];
-        }
-
-        /// <summary>
-        /// 动作枚举
-        /// </summary>
-        public enum NavigateType
-        {
-            /// <summary>
-            /// 不作切换动作,返回当前索引的数据
-            /// </summary>
-            None = 0,
-
-            /// <summary>
-            /// 上一条
-            /// </summary>
-            Previous = 1,
-
-            /// <summary>
-            /// 下一条
-            /// </summary>
-            Next = 2
-        }
-    }
-}

+ 0 - 3
GameClient/Assets/Game/HotUpdate/Utils/ListUtil.cs.meta

@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: 250cd1df042041008c95c9cad474dbcb
-timeCreated: 1685762914

+ 3 - 3
GameClient/Assets/Game/HotUpdate/Views/Poem/PoemPhotoView.cs

@@ -119,7 +119,7 @@ namespace GFGGame
                 _photoInfos = PoemPhotoDataManager.Instance.PersonalPhotoInfos;
                 _sourceType = (int)PictureSourceType.PersonalAlbum;
                 _ui.m_list.numItems = _photoInfos.Count;
-
+                _ui.m_txtCount.text = string.Format("({0}/{1})", _photoInfos.Count, GlobalCfgArray.globalCfg.maxPhotoCount);
             }
             else
             {
@@ -128,10 +128,10 @@ namespace GFGGame
                 _photoInfos = PoemPhotoDataManager.Instance.WsqsPhotoInfos;
                 _sourceType = (int)PictureSourceType.WanShuiQianShan;
                 _ui.m_listTravel.numItems = _photoInfos.Count;
-
+                _ui.m_txtCount.text = string.Format("({0}/{1})", _photoInfos.Count, GlobalCfgArray.globalCfg.maxTravelCount);
             }
 
-            _ui.m_txtCount.text = string.Format("({0}/{1})", _photoInfos.Count, GlobalCfgArray.globalCfg.maxPhotoCount);
+           
             _ui.m_btnConfirmDelete.m_txtTitle.text = string.Format("删除({0}/{1})", _listDelete.Count, _photoInfos.Count);
         }