Exemplo n.º 1
0
 public static void downloadUSBoxCompleted(object sender, DownloadStringCompletedEventArgs e)
 {
     try
     {
         if (e.Error == null && !e.Cancelled)
         {
             string       data      = e.Result;
             JObject      obj       = JObject.Parse(data);
             JArray       array     = (JArray)obj["subjects"];
             List <Movie> movieList = new List <Movie>();
             for (int i = 0; i < array.Count; i++)
             {
                 Movie movie = new Movie();
                 movie.id        = JsonParsers.getDouble(array[i], "subject", "id");
                 movie.posterUrl = JsonParsers.getTriple(array[i], "subject", "images", "small");
                 movie.money     = JsonParsers.getValue(array[i], "box");
                 movie.rating    = JsonParsers.getTriple(array[i], "subject", "rating", "average");
                 movie.title     = JsonParsers.getDouble(array[i], "subject", "title");
                 movie.star      = Util.getStarPath(movie.rating);
                 movieList.Add(movie);
             }
             usboxLongListSelector.ItemsSource = movieList;
             if (progressBar != null)
             {
                 progressBar.Visibility = Visibility.Collapsed;
             }
             loaded.isLoaded = true;
         }
         else
         {
             var wEx = e.Error as WebException;
             if (wEx.Status == WebExceptionStatus.RequestCanceled)
             {
                 if (App.isFromDormant)
                 {
                     App.isFromDormant = false;
                     parseUSBox();
                 }
             }
             else
             {
                 if (progressBar != null)
                 {
                     progressBar.Visibility = Visibility.Collapsed;
                 }
             }
         }
     }
     catch (WebException)
     {
         if (progressBar != null)
         {
             progressBar.Visibility = Visibility.Collapsed;
         }
         MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK);
     }
     loaded.isLoading = false;
 }
Exemplo n.º 2
0
 public void downloadSearchCompleted(object sender, DownloadStringCompletedEventArgs e)
 {
     try
     {
         if (e.Error == null && !e.Cancelled)
         {
             string       data      = e.Result;
             JObject      obj       = JObject.Parse(data);
             JArray       array     = (JArray)obj["subjects"];
             List <Movie> movieList = new List <Movie>();
             for (int i = 0; i < array.Count; i++)
             {
                 Movie movie = new Movie();
                 movie.id        = JsonParsers.getValue(array[i], "id");
                 movie.posterUrl = JsonParsers.getDouble(array[i], "images", "small");
                 movie.rating    = JsonParsers.getDouble(array[i], "rating", "average");
                 movie.title     = JsonParsers.getValue(array[i], "title");
                 movie.star      = Util.getStarPath(movie.rating);
                 movieList.Add(movie);
             }
             resultNumber.Text    = array.Count + "";
             selector.ItemsSource = movieList;
             if (progressBar != null)
             {
                 progressBar.Visibility = Visibility.Collapsed;
             }
         }
         else
         {
             var wEx = e.Error as WebException;
             if (wEx.Status == WebExceptionStatus.RequestCanceled)
             {
                 if (App.isFromDormant)
                 {
                     App.isFromDormant = false;
                     search(searchText);
                 }
             }
             if (progressBar != null)
             {
                 progressBar.Visibility = Visibility.Collapsed;
             }
         }
     }
     catch (WebException)
     {
         if (progressBar != null)
         {
             progressBar.Visibility = Visibility.Collapsed;
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Search
        /// </summary>
        /// <returns></returns>
        public async Task search()
        {
            String searchJson = await downloader.downloadString();

            JObject obj   = JObject.Parse(searchJson);
            JArray  array = (JArray)obj["subjects"];

            for (int i = 0; i < array.Count; i++)
            {
                Movie movie = new Movie();
                movie.id        = JsonParsers.getValue(array[i], "id");
                movie.posterUrl = JsonParsers.getDouble(array[i], "images", "small");
                movie.rating    = JsonParsers.getDouble(array[i], "rating", "average");
                movie.title     = JsonParsers.getValue(array[i], "title");
                movie.star      = Util.getStarPath(movie.rating);
                movieCollection.Add(movie);
            }
            resultNumber = array.Count;
        }
Exemplo n.º 4
0
        public async static Task <ObservableCollection <Movie> > getUSMovie()
        {
            String USHtml = await downloader.downloadString();

            JObject obj   = JObject.Parse(USHtml);
            JArray  array = (JArray)obj["subjects"];

            for (int i = 0; i < array.Count; i++)
            {
                Movie movie = new Movie();
                movie.id        = JsonParsers.getDouble(array[i], "subject", "id");
                movie.posterUrl = JsonParsers.getTriple(array[i], "subject", "images", "small");
                movie.money     = JsonParsers.getValue(array[i], "box");
                movie.rating    = JsonParsers.getTriple(array[i], "subject", "rating", "average");
                movie.title     = JsonParsers.getDouble(array[i], "subject", "title");
                movie.star      = Util.getStarPath(movie.rating);
                movieCollection.Add(movie);
            }

            return(movieCollection);
        }