Exemple #1
0
 private void LoadBattle()
 {
     var request = new HttpRequestGet();
     var listBattle = request.GetListObject(new List<Battle>(), "battles");
     listBattle.ContinueWith(delegate(Task<object> tmp)
     {
         var test = tmp.Result as List<Battle>;
         if (test != null)
         {
             foreach (var item in test)
             {
                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                     () =>
                     {
                         item.artist_one.image = "http://soonzikapi.herokuapp.com/assets/usersImage/avatars/" +
                                                 item.artist_one.image;
                         item.artist_two.image = "http://soonzikapi.herokuapp.com/assets/usersImage/avatars/" +
                                                 item.artist_two.image;
                         ListBattles.Add(item);
                     });
             }
         }
     });
 }
Exemple #2
0
 private void LoadTweet()
 {
     ListTweets = new ObservableCollection<Tweets>();
     var req = new HttpRequestGet();
     var listTweets = req.GetListObject(new List<Tweets>(), "tweets");
     listTweets.ContinueWith(delegate(Task<object> tmp)
     {
         var res = tmp.Result as List<Tweets>;
         if (res != null)
         {
             foreach (var item in res)
             {
                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                     () =>
                     {
                         ListTweets.Insert(0, item);
                         //ListTweets.Add(item);
                     });
             }
         }
     });
 }
Exemple #3
0
 public void LoadContent()
 {
     ListArtiste = new ObservableCollection<User>();
     ListMusique = new ObservableCollection<Music>();
     ListInfluences = new ObservableCollection<Influence>();
     ListAmbiance = new ObservableCollection<Ambiance>();
     var request = new HttpRequestGet();
     try
     {
         var listIdentities = request.GetIdentities(new List<Identities>(), Singleton.Singleton.Instance().CurrentUser.id.ToString(), Singleton.Singleton.Instance().SecureKey);
         listIdentities.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<Identities>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     if (item.provider == "soundcloud")
                     {
                         var post = new HttpRequestPost();
                         var result = post.GetMusicalPast(item.uid, Singleton.Singleton.Instance().SecureKey,
                             Singleton.Singleton.Instance().CurrentUser.id.ToString());
                         result.ContinueWith(delegate(Task<string> t) { var res = t.Result; });
                     }
                 }
             }
         });
         var listGenre = request.GetListObject(new List<Influence>(), "influences");
         listGenre.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<Influence>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                         () => { ListInfluences.Add(item); });
                 }
             }
         });
         var listUser = request.GetListObject(new List<User>(), "users");
         listUser.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<User>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     var res = request.GetArtist(new Artist(), "users", item.id.ToString());
                     res.ContinueWith(delegate(Task<object> obj)
                     {
                         CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                             () =>
                             {
                                 var art = obj.Result as Artist;
                                 item.profilImage =
                                     new BitmapImage(new Uri(Constant.UrlImageUser + item.image,
                                         UriKind.RelativeOrAbsolute));
                                 if (art != null && art.artist)
                                     ListArtiste.Add(item);
                             });
                     });
                 }
             }
         });
         ValidateKey.GetValideKey();
         var listZik = request.GetSuggest(new List<Music>(), "music");
         listZik.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<Music>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                         CoreDispatcherPriority.Normal,
                         () =>
                         {
                             item.album.imageAlbum =
                                 new BitmapImage(new Uri(Constant.UrlImageAlbum + item.album.image,
                                     UriKind.RelativeOrAbsolute));
                             ListMusique.Add(item);
                         });
                 }
             }
         });
         var listAmb = request.GetListObject(new List<Ambiance>(), "ambiances");
         listAmb.ContinueWith(delegate(Task<object> task)
         {
             var test = listAmb.Result as List<Ambiance>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                         CoreDispatcherPriority.Normal,
                         () =>
                         {
                             var ambiance = request.GetObject(new Ambiance(), "ambiances", item.id.ToString());
                             ambiance.ContinueWith(delegate(Task<object> task1)
                             {
                                 var am = task1.Result as Ambiance;
                                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                                     CoreDispatcherPriority.Normal,
                                     () =>
                                     {
                                         foreach (var music in am.musics)
                                         {
                                             music.album.imageAlbum =
                                                 new BitmapImage(
                                                     new Uri(Constant.UrlImageAlbum + music.album.image,
                                                         UriKind.RelativeOrAbsolute));
                                         }
                                         ListAmbiance.Add(am);
                                     });
                             });
                         });
                 }
             }
         });
     }
     catch (Exception e)
     {
         //new MessageDialog("probleme reseau : " + e.Message).ShowAsync();
     }
 }
Exemple #4
0
 private void LoadComment()
 {
     TextComment = "";
     var request = new HttpRequestGet();
     ListCommAlbum = new ObservableCollection<Comments>();
     var elem = "albums/" + TheAlbum.id + "/comments";
     var listCom = request.GetListObject(new List<Comments>(), elem);
     listCom.ContinueWith(delegate(Task<object> tmp)
     {
         var res = tmp.Result as List<Comments>;
         if (res != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             {
                 foreach (var item in res)
                 {
                     ListCommAlbum.Add(item);
                 }
             });
         }
     });
 }
Exemple #5
0
 public void Charge()
 {
     ListFriend = new ObservableCollection<User>();
     ListFriend = Singleton.Singleton.Instance().CurrentUser.friends;
     var request = new HttpRequestGet();
     var ListPack = request.GetListObject(new List<Pack>(), "packs");
     CompleteListPack = new ObservableCollection<Pack>();
     ListPack.ContinueWith(delegate(Task<object> obj)
     {
         var res = obj.Result as List<Pack>;
         if (res != null)
         {
             foreach (var pack in res)
             {
                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                     () => { CompleteListPack.Add(pack); });
             }
         }
     });
 }