private void InitScrollViewData(bool isFilter = false) { wrapContent.ResetChildPositions(); scrollview.ResetPosition(); JSONArray targetList; if (isFilter) { targetList = filteredRoomList; } else { targetList = roomList; } wrapContent.minIndex = -(targetList.Length - 1); wrapContent.onInitializeItem = UpdateRowDataOnScroll; Transform tempGameObject; bool canDrag = true; if (targetList.Length < wrapContent.transform.childCount) { canDrag = false; backgroundDragScrollView.enabled = false; } else { backgroundDragScrollView.enabled = true; } for (int i = 0; i < wrapContent.transform.childCount; i++) { tempGameObject = wrapContent.transform.GetChild(i); RoomRowScript tempRowScript = tempGameObject.GetComponent <RoomRowScript>(); tempRowScript.Init(scrollview); if (canDrag) { tempRowScript.dragScrollView.enabled = true; } else { tempRowScript.dragScrollView.enabled = false; } if (i < targetList.Length) { Utils.SetActive(tempGameObject.gameObject, true); tempRowScript.UpdateData(targetList[i].Obj); } else { Utils.SetActive(tempGameObject.gameObject, false); } } }
// void LoadListFriendFromServer() { // PopupManager.Instance.ShowLoadingPopup(); // isLoading = true; // for (int i = 0; i < wrapContent.transform.childCount; i++) { // wrapContent.transform.GetChild(i).gameObject.SetActive(false); // } // UserExtensionRequest.Instance.LoadFriendList(); // } public void InitScrollViewData(JSONArray mFriendList) { // friendList = mFriendList; isLoading = false; wrapContent.ResetChildPositions(); scrollview.currentMomentum = Vector3.zero; scrollview.ResetPosition(); Transform tempGameObject; wrapContent.minIndex = -(friendList.Length - 1); wrapContent.onInitializeItem = UpdateRowDataOnScroll; bool canDrag = true; if (friendList.Length <= STOP_DRAG_NUMB_ROW) { canDrag = false; backgroundDragScrollView.enabled = false; } else { backgroundDragScrollView.enabled = true; } for (int i = 0; i < wrapContent.transform.childCount; i++) { tempGameObject = wrapContent.transform.GetChild(i); if (!tempGameObject.gameObject.activeSelf) { Utils.SetActive(tempGameObject.gameObject, true); } FriendRowScript tempRowScript = tempGameObject.GetComponent <FriendRowScript>(); tempRowScript.Init(scrollview); if (canDrag) { tempRowScript.dragScrollView.enabled = true; } else { tempRowScript.dragScrollView.enabled = false; } if (i < friendList.Length) { Utils.SetActive(tempGameObject.gameObject, true); tempRowScript.UpdateRowData(friendList[i].Obj); } else { Utils.SetActive(tempGameObject.gameObject, false); } } }
private void InitScrollViewData(Tab selectedTab) { isLoading = false; wrapContent.ResetChildPositions(); scrollview.currentMomentum = Vector3.zero; scrollview.ResetPosition(); Transform tempGameObject; JSONArray targetList = null; switch (selectedTab) { case Tab.TOP_RICHER: targetList = topRicherList; break; case Tab.TOP_WINNER: targetList = topWinnerList; break; } wrapContent.minIndex = -(targetList.Length - 1); wrapContent.onInitializeItem = UpdateRowDataOnScroll; bool canDrag = true; if (targetList.Length <= STOP_DRAG_NUMB_ROW) { canDrag = false; backgroundDragScrollView.enabled = false; } else { backgroundDragScrollView.enabled = true; } for (int i = 0; i < wrapContent.transform.childCount; i++) { tempGameObject = wrapContent.transform.GetChild(i); if (!tempGameObject.gameObject.activeSelf) { Utils.SetActive(tempGameObject.gameObject, true); } TopPlayerRowScript tempRowScript = tempGameObject.GetComponent <TopPlayerRowScript>(); tempRowScript.Init(scrollview); if (canDrag) { tempRowScript.dragScrollView.enabled = true; } else { tempRowScript.dragScrollView.enabled = false; } if (i < targetList.Length) { Utils.SetActive(tempGameObject.gameObject, true); tempRowScript.UpdateRowData(targetList[i].Obj, currentTab); } else { Utils.SetActive(tempGameObject.gameObject, false); } } wrapperAnchor.ResetAndUpdateAnchors(); }