public void GetInfo(string[] uids, string[] fields, bool emptyPictures, OKGetInfoCallback callback) { // Number of requests needed to obtain data for all required users, API limited by 100/request. int requestCounter = (uids.Length / 100) + ((uids.Length % 100 > 0) ? 1 : 0); HTTP.Response[] responseList = new Response[requestCounter]; int responseCounter = 0; int responseUserCount = 0; for (int j = 0; j < requestCounter; j++) { int requestIndex = j; // Find the remaining number of uids to send, maximum 100, and put these uids in list. int maxCount = Math.Min(100, uids.Length - j * 100); string[] requestUids = uids.Skip(j * 100).Take(maxCount).ToArray(); Api(OKMethod.Users.getInfo, new Dictionary <string, string> { { "uids", string.Join(",", requestUids) }, { "fields", string.Join(",", fields) }, { "emptyPictures", emptyPictures.ToString() } }, delegate(HTTP.Response response) { string error = response.Error; if (!string.IsNullOrEmpty(error)) { // In case of error, return a 0-element list callback(new OKUserInfo[0]); } else { // Store response responseList[requestIndex] = response; responseCounter++; // Count user response Array objects. responseUserCount += response.Array.Count; // Process data on last response received if (responseCounter == requestCounter) { OKUserInfo[] userInfos = new OKUserInfo[responseUserCount]; int responseIndex = 0; // Iterate all response objects and save all user response Array objects. for (int k = 0; k < requestCounter; k++) { ArrayList users = responseList[k].Array; for (int i = 0; i < users.Count; i++) { userInfos[responseIndex] = new OKUserInfo((Hashtable)users[i]); responseIndex++; } } callback(userInfos); } } } ); } }
public void GetInfo(string[] uids, string[] fields, bool emptyPictures, OKGetInfoCallback callback) { Api(OKMethod.Users.getInfo, new Dictionary <string, string> { { "uids", string.Join(",", uids) }, { "fields", string.Join(",", fields) }, { "emptyPictures", emptyPictures.ToString() } }, delegate(HTTP.Response response) { ArrayList users = response.Array; OKUserInfo[] userInfos = new OKUserInfo[users.Count]; for (int i = 0; i < users.Count; i++) { userInfos[i] = new OKUserInfo((Hashtable)users[i]); } callback(userInfos); } ); }
public void SetFriends(OKUserInfo[] friends) { // Store all friend objects foreach (OKUserInfo friend in friends) { Friend f = new Friend(friend.uid, friend.name, friend.pic128x128, defaultPhoto); friendObjectList.Add(f); } // Let's scale the friends container manually! (Explained below, why) RectTransform friendsContainerRect = friendsContainer.GetComponent(typeof(RectTransform)) as RectTransform; friendsContainerRect.sizeDelta = new Vector2(friendObjectList.Count * friendGap, friendsContainerRect.sizeDelta.y); int optimalObjectCount = (int)((Screen.width / friendGap) + 8); childCount = Math.Min(optimalObjectCount, friendObjectList.Count); // Fill initial children. int x = 0; for (int i = 0; i < childCount; i++) { TestFriendSlot newFriendSlot = (TestFriendSlot)Instantiate(friendPrefab); newFriendSlot.transform.SetParent(friendsContainer.transform, false); newFriendSlot.transform.localPosition = new Vector3(x * friendGap, newFriendSlot.transform.localPosition.y, 0); friendPrefabList.Add(newFriendSlot); newFriendSlot.SetFriend(friendObjectList[i]); x++; } if (this.friendObjectList.Count == 0) { NoFriends(); } else { noFriendsLabel.gameObject.SetActive(false); } UpdateScrollbar(); ScreenManager.AddOnScreenChanged(UpdateScrollbar); }
public void GetInfo(string[] uids, string[] fields, bool emptyPictures, OKGetInfoCallback callback) { // Number of requests needed to obtain data for all required users, API limited by 100/request. int requestCounter = (uids.Length / 100) + ((uids.Length % 100 > 0) ? 1 : 0); HTTP.Response[] responseList = new Response[requestCounter]; int responseCounter = 0; int responseUserCount = 0; for (int j = 0; j < requestCounter; j++) { int requestIndex = j; // Find the remaining number of uids to send, maximum 100, and put these uids in list. int maxCount = Math.Min(100, uids.Length - j * 100); string[] requestUids = uids.Skip(j * 100).Take(maxCount).ToArray(); Api(OKMethod.Users.getInfo, new Dictionary<string, string> { {"uids", string.Join(",", requestUids)}, {"fields", string.Join(",", fields)}, {"emptyPictures", emptyPictures.ToString()} }, delegate (HTTP.Response response) { string error = response.Error; if (!string.IsNullOrEmpty(error)) { // In case of error, return a 0-element list callback(new OKUserInfo[0]); } else { // Store response responseList[requestIndex] = response; responseCounter++; // Count user response Array objects. responseUserCount += response.Array.Count; // Process data on last response received if (responseCounter == requestCounter) { OKUserInfo[] userInfos = new OKUserInfo[responseUserCount]; int responseIndex = 0; // Iterate all response objects and save all user response Array objects. for (int k = 0; k < requestCounter; k++) { ArrayList users = responseList[k].Array; for (int i = 0; i < users.Count; i++) { userInfos[responseIndex] = new OKUserInfo((Hashtable) users[i]); responseIndex++; } } callback(userInfos); } } } ); } }