Example #1
0
        async void GetHeroInfo(string heroId)
        {
            HeroesManager = new HeroesManager(new RestService(heroId));
            HeroAPI hero = await HeroesManager.GetTasksAsync();

            // Apparently the iOS system will automatically push the url
            // to https, which will result in no image found. Taking the
            // image source from stream works around that.
            string Image_Name = hero.data.results[0].thumbnail.path + "/standard_fantastic." +
                                hero.data.results[0].thumbnail.extension;

            Banner.Source = ImageSource.FromStream(() => new MemoryStream(new WebClient().DownloadData(Image_Name)));

            Banner.IsVisible = true;
            Description.Text = hero.data.results[0].description;
        }
Example #2
0
        public async Task <HeroAPI> RefreshDataAsync()
        {
            heroAPI = new HeroAPI();

            var uri = new Uri(string.Format(Constants.HeroInfoUrl + HeroId + Constants.Handshake, string.Empty));

            try
            {
                var response = await _client.GetAsync(uri);

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();

                    heroAPI = JsonConvert.DeserializeObject <HeroAPI>(content);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"\tERROR {0}", ex.Message);
            }

            return(heroAPI);
        }