private IEnumerator FriendsToShareLocation() { WWWForm form = new WWWForm(); form.AddField("id", FB.UserId); Dictionary <long, string> friends = new Dictionary <long, string>(); yield return(WebService.POST(SERVER_URL + "/usuario/friendsShareLocationRequest", form, (status, response) => { if (status) { var json = new JSONObject(response); if (json.list != null) { foreach (var item in json.list) { var id = Convert.ToInt64(item.GetField("id").str); var nombre = item.GetField("nombre").str; friends.Add(id, nombre); } } } } )); //Esperar que se refresque el valores yield return(new WaitForEndOfFrame()); //Get Item Template Transform itemTemplate = (Resources.Load("GUI/FriendShareLocationItem") as GameObject).transform; //Get Parent Transform parent = UIUtils.FindGUI("MenuShareLocationFriendSelection/ScrollView").transform; int k = 0; foreach (var usuario in friends) { var id = usuario.Key; WWW photo = new WWW("https://graph.facebook.com/" + id + "/picture?width=50&height=50"); //?access_token=" + FB.AccessToken); Texture2D textFb2 = new Texture2D(50, 50, TextureFormat.DXT5, false); //TextureFormat must be DXT5 yield return(photo); photo.LoadImageIntoTexture(textFb2); var friendItem = GameObject.Instantiate(itemTemplate.gameObject) as GameObject; friendItem.name = "ItemFriend" + k; friendItem.transform.parent = parent; friendItem.transform.localScale = itemTemplate.localScale; //Agregando la posicion relativa del hijo con relacion al padre friendItem.transform.localPosition = new Vector3( itemTemplate.localPosition.x, itemTemplate.localPosition.y - 60f * k, itemTemplate.localPosition.z ); friendItem.transform.FindChild("Image").GetComponent <UITexture>().mainTexture = textFb2; friendItem.transform.FindChild("Label").GetComponent <UILabel>().text = usuario.Value; var checkBoxGameObject = friendItem.transform.FindChild("CheckBox"); checkBoxGameObject.name = checkBoxGameObject.name + friendItem.name; checkBoxGameObject.GetComponent <UIToggle>().value = false; var menu = MenuManager.GetInstance().GetCurrentMenu() as MenuShareLocationFriendSelection; var checkBox = new CheckBox(checkBoxGameObject.name); checkBox.OnChangeEvent += new OnChangeEventHandler(menu.OnChangeCheckBox); checkBox.ObjectTag = new { idUsuario = id }; menu.GetCheckBoxList().Add(checkBox); friendItem.GetComponent <BoxCollider>().enabled = true; k++; } }
public IEnumerator UserFriendsPendingToFollow() { var idUser = ""; if (Application.platform == RuntimePlatform.WindowsEditor) { idUser = "******"; } else { idUser = FB.UserId; } Dictionary <long, string> usuarioFriendsFacebook = new Dictionary <long, string>(); using (var sqlite = new SQLiteService()) { var query = "SELECT idFollower, nombre FROM UserFollowingNotification WHERE idUsuarioFacebook = '" + idUser + "'"; using (var reader = sqlite.SelectQuery(query)) { while (reader.Read()) { var id = Convert.ToInt64(Convert.ToString(reader["idFollower"])); var nombre = Convert.ToString(reader["nombre"]); usuarioFriendsFacebook.Add(id, nombre); } } } Transform itemTemplate = (Resources.Load("GUI/PendingFriendFollowingItem") as GameObject).transform; //Get Parent Transform parent = UIUtils.FindGUI("MenuReceiveFollowingRequest/ScrollView").transform; int k = 0; foreach (var usuario in usuarioFriendsFacebook) { var id = usuario.Key; var url = ("https://graph.facebook.com/" + id + "/picture?width=128&height=128&access_token=" + FB.AccessToken); WWW photo = new WWW(url); Texture2D textFb2 = new Texture2D(128, 128, TextureFormat.DXT5, false); //TextureFormat must be DXT5 yield return(photo); photo.LoadImageIntoTexture(textFb2); var friendItem = GameObject.Instantiate(itemTemplate.gameObject) as GameObject; friendItem.name = "ItemFriend" + k; friendItem.transform.parent = parent; friendItem.transform.localScale = itemTemplate.localScale; //Agregando la posicion relativa del hijo con relacion al padre friendItem.transform.localPosition = new Vector3( itemTemplate.localPosition.x, itemTemplate.position.y - 60f * k, itemTemplate.localPosition.z ); friendItem.transform.FindChild("Image").GetComponent <UITexture>().mainTexture = textFb2; friendItem.transform.FindChild("Label").GetComponent <UILabel>().text = usuario.Value; var menu = MenuManager.GetInstance().GetCurrentMenu() as MenuReceiveFollowingRequest; var button = new Button(friendItem.name); button.OnTouchEvent += new OnTouchEventHandler(menu.OnTouchButton); button.ObjectTag = new { follower = id, name = usuario.Value, texture = textFb2, index = k }; menu.GetButtonList().Add(button); k++; } }
private IEnumerator Friends() { WWWForm form = new WWWForm(); form.AddField("id", FB.UserId); Dictionary <long, object> followedFriends = new Dictionary <long, object>(); yield return(WebService.POST(SERVER_URL + "/usuario/friendFindRequest", form, (status, response) => { if (status) { Debug.Log("friendFindRequest -> " + response); var data = new JSONObject(response); if (data.list.Count > 0) { for (int i = 0; i < data.list.Count; ++i) { var followed = Convert.ToInt64(data.list[i].GetField("id").str); var nombre = Convert.ToString(data.list[i].GetField("nombre").str); var ubicacion = Convert.ToString(data.list[i].GetField("ubicacion").str); var fecha = Convert.ToString(data.list[i].GetField("fecha").str); var obj = new { nombre, ubicacion, fecha }; followedFriends.Add(followed, obj); } } } } )); yield return(new WaitForEndOfFrame()); Transform itemTemplate = (Resources.Load("GUI/PendingFriendFollowingItem") as GameObject).transform; Transform parent = UIUtils.FindGUI("MenuFindFriendSelection/ScrollView").transform; int k = 0; foreach (var usuario in followedFriends) { var id = usuario.Key; WWW photo = new WWW("https://graph.facebook.com/" + id + "/picture?width=250&height=250"); //?access_token=" + FB.AccessToken); Texture2D texture = new Texture2D(250, 250, TextureFormat.DXT5, false); //TextureFormat must be DXT5 yield return(photo); photo.LoadImageIntoTexture(texture); var friendItem = GameObject.Instantiate(itemTemplate.gameObject) as GameObject; friendItem.name = "ItemFriend" + k; friendItem.transform.parent = parent; friendItem.transform.localScale = itemTemplate.localScale; //Agregando la posicion relativa del hijo con relacion al padre friendItem.transform.localPosition = new Vector3( itemTemplate.localPosition.x, itemTemplate.localPosition.y - 60f * k, itemTemplate.localPosition.z ); var nombre = Convert.ToString(usuario.Value.GetType().GetProperty("nombre").GetValue(usuario.Value, null)); var ubicacion = Convert.ToString(usuario.Value.GetType().GetProperty("ubicacion").GetValue(usuario.Value, null)); var fecha = Convert.ToString(usuario.Value.GetType().GetProperty("fecha").GetValue(usuario.Value, null)); friendItem.transform.FindChild("Image").GetComponent <UITexture>().mainTexture = texture; friendItem.transform.FindChild("Label").GetComponent <UILabel>().text = nombre; var menu = MenuManager.GetInstance().GetCurrentMenu() as MenuFindFriendSelection; var button = new Button(friendItem.name); button.ObjectTag = new { ubicacion, nombre, texture, fecha }; button.OnTouchEvent += new OnTouchEventHandler(menu.OnTouchButton); menu.GetButtonList().Add(button); k++; } }
private IEnumerator FollowingUserFriends() { bool IsConnectionAvailable = false; string responseJson = string.Empty; yield return(WebService.GET("https://graph.facebook.com/me/friends?access_token=" + FB.AccessToken, (status, response) => { if (status) { IsConnectionAvailable = status; responseJson = response; } } )); //Esperar que se refresque el valores yield return(new WaitForSeconds(0.5f)); if (IsConnectionAvailable) { Dictionary <long, string> usuarioFriendsFacebook = new Dictionary <long, string>(); var json = new JSONObject(responseJson); if (json.HasField("data")) { var data = json.GetField("data"); foreach (var item in data.list) { var id = 0L; var name = string.Empty; if (item.HasField("id")) { id = Convert.ToInt64(item.GetField("id").str); } if (item.HasField("name")) { name = item.GetField("name").str; } usuarioFriendsFacebook.Add(id, name); //if (Application.platform == RuntimePlatform.WindowsEditor) //{ // StartCoroutine(SendUserFacebookId(new Usuario() { idUsuarioFacebook = id, apellido = item.GetField("last_name").str, nombre = item.GetField("fist_name").str })); //} } } //Filtrar usuario que no han sido enviadas WWWForm form = new WWWForm(); form.AddField("id", FB.UserId); yield return(WebService.POST(SERVER_URL + "/usuario/following", form, (status, response) => { if (status) { var data = new JSONObject(response); for (int i = 0; i < data.list.Count; ++i) { var idFollowing = Convert.ToInt64(data.list[i].GetField("id").str); if (usuarioFriendsFacebook.ContainsKey(idFollowing)) { usuarioFriendsFacebook.Remove(idFollowing); } } } } )); yield return(new WaitForSeconds(0.5f)); //Get Item Template Transform itemTemplate = (Resources.Load("GUI/FriendFollowingItem") as GameObject).transform; //Get Parent Transform parent = UIUtils.FindGUI("MenuSendFollowingRequest/ScrollView").transform; int k = 0; foreach (var usuario in usuarioFriendsFacebook) { var id = usuario.Key; WWW photo = new WWW("https://graph.facebook.com/" + id + "/picture?width=50&height=50"); //?access_token=" + FB.AccessToken); Texture2D textFb2 = new Texture2D(50, 50, TextureFormat.DXT5, false); //TextureFormat must be DXT5 yield return(photo); photo.LoadImageIntoTexture(textFb2); var friendItem = GameObject.Instantiate(itemTemplate.gameObject) as GameObject; friendItem.name = "ItemFriend" + k; friendItem.transform.parent = parent; friendItem.transform.localScale = itemTemplate.localScale; //Agregando la posicion relativa del hijo con relacion al padre friendItem.transform.localPosition = new Vector3( itemTemplate.localPosition.x, itemTemplate.localPosition.y - 60f * k, itemTemplate.localPosition.z ); friendItem.transform.FindChild("Image").GetComponent <UITexture>().mainTexture = textFb2; friendItem.transform.FindChild("Label").GetComponent <UILabel>().text = usuario.Value; var checkBoxGameObject = friendItem.transform.FindChild("CheckBox"); checkBoxGameObject.name = checkBoxGameObject.name + friendItem.name; checkBoxGameObject.GetComponent <UIToggle>().value = false; var menu = MenuManager.GetInstance().GetCurrentMenu() as MenuSendFollowingRequest; var checkBox = new CheckBox(checkBoxGameObject.name); checkBox.OnChangeEvent += new OnChangeEventHandler(menu.OnChangeCheckBox); checkBox.ObjectTag = new { idUsuario = id }; menu.GetCheckBoxList().Add(checkBox); friendItem.GetComponent <BoxCollider>().enabled = true; k++; } } }