瀏覽代碼

添加画廊作品数量的判空

leiyasi 1 年之前
父節點
當前提交
e92896d0d4
共有 1 個文件被更改,包括 14 次插入3 次删除
  1. 14 3
      GameClient/Assets/Game/HotUpdate/Views/Poem/PoemGalleryView.cs

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

@@ -451,7 +451,7 @@ namespace GFGGame
                 else
                 else
                 {
                 {
                     _list.numItems = (_galleryDatas.Count + 1) / 2;
                     _list.numItems = (_galleryDatas.Count + 1) / 2;
-                    _list1.numItems = (_galleryDatas.Count - 1) / 2;
+                    _list1.numItems = Mathf.Max(0, (_galleryDatas.Count - 1) / 2);
                 }
                 }
             }
             }
 
 
@@ -502,13 +502,24 @@ namespace GFGGame
 
 
         private void RenderListItem(int index, GObject obj)
         private void RenderListItem(int index, GObject obj)
         {
         {
-            long workId = _galleryDatas[index * 2];
+            int num = index * 2;
+            if (_galleryDatas.Count <= num)
+            {
+                return;
+            }
+            long workId = _galleryDatas[num];
             UpdateListItem(workId, obj);
             UpdateListItem(workId, obj);
         }
         }
 
 
         private void RenderListItem1(int index, GObject obj)
         private void RenderListItem1(int index, GObject obj)
         {
         {
-            long workId = _galleryDatas[index * 2 + 1];
+            int num = index * 2 + 1;
+            if (_galleryDatas.Count <= num)
+            {
+                return;
+            }
+
+            long workId = _galleryDatas[num];
             UpdateListItem(workId, obj);
             UpdateListItem(workId, obj);
         }
         }