Beispiel #1
0
        public ScrollView LoadLore(ChampionStatic champion)
        {
            var loreView = new ScrollView();

            if (!DependencyService.Get <ISaveAndLoad>().FileExists("haveyou"))
            {
                var adView = new AdMobView {
                    WidthRequest = 320, HeightRequest = 50
                };
                loreView = new ScrollView
                {
                    Content = new StackLayout
                    {
                        Children =
                        {
                            adView,
                            new HtmlLabel {
                                Text = champion.Lore
                            }
                        }
                    }
                };
            }
            else
            {
                loreView = new ScrollView
                {
                    Content = new StackLayout
                    {
                        Children =
                        {
                            new HtmlLabel {
                                Text = champion.Lore
                            }
                        }
                    }
                };
            }
            return(loreView);
        }
        public PreviousGamePage(ObservableCollection <GroupedPrevious> grouped)
        {
            Title = "Previous Game";
            var imageTemplate = new DataTemplate(typeof(ExpandedGameCell));

            listView = new ListView
            {
                IsGroupingEnabled   = true,
                ItemTemplate        = imageTemplate,
                ItemsSource         = grouped,
                HasUnevenRows       = true,
                GroupDisplayBinding = new Binding("LongName")
            };
            if (!DependencyService.Get <ISaveAndLoad>().FileExists("haveyou"))
            {
                var adView = new AdMobView {
                    WidthRequest = 320, HeightRequest = 50
                };
                listView.Header = adView;
            }
            Content = listView;
        }
Beispiel #3
0
        public ScrollView LoadTips(ChampionStatic champion)
        {
            var tipsView = new ScrollView();

            var stack = new StackLayout();

            if (!DependencyService.Get <ISaveAndLoad>().FileExists("haveyou"))
            {
                var adView = new AdMobView {
                    WidthRequest = 320, HeightRequest = 50
                };
                stack.Children.Add(adView);
            }

            stack.Children.Add(new HtmlLabel {
                Text = "<u>Ally Tips</u>", FontSize = 20
            });

            for (int i = 0; i < champion.AllyTips.Count; i++)
            {
                stack.Children.Add(new HtmlLabel {
                    Text = champion.AllyTips[i] + "\n\n"
                });
            }

            stack.Children.Add(new HtmlLabel {
                Text = "<u>Enemy Tips</u>", FontSize = 20
            });
            for (int i = 0; i < champion.EnemyTips.Count; i++)
            {
                stack.Children.Add(new HtmlLabel {
                    Text = champion.EnemyTips[i] + "\n\n"
                });
            }

            tipsView.Content = stack;
            return(tipsView);
        }
Beispiel #4
0
        public DownloadImages(Summoner summoner)
        {
            NavigationPage.SetHasNavigationBar(this, true);
            ToolbarItems.Add(infoIcon);
            Title             = summoner.Name;
            infoIcon.Clicked += (sender, e) =>
            {
                if ((App.FavoriteDatabase.GetItems().Where(item => item.Name == summoner.Name && item.Region == summoner.Region.ToString().ToUpper()).ToList().Count > 0))
                {
                    UserDialogs.Instance.AlertAsync(summoner.Name + " is already in your favorites, do you really love them that much? ;)", "Error", "Okay");
                }
                else
                {
                    UserDialogs.Instance.AlertAsync(summoner.Name + " has been added to your favorites", "Favorite Added", "Okay");
                    App.FavoriteDatabase.SaveItem(new SearchesAndFavorites {
                        Name = summoner.Name, Region = summoner.Region.ToString().ToUpper(), Icon = icon, summonerID = (int)summoner.Id
                    });
                }
            };

            var adView = new AdMobView {
                WidthRequest = 320, HeightRequest = 50
            };

            var stackLayout = new StackLayout
            {
                Children =
                {
                    grid,
                    memeTest,
                    contentVue,
                    adView
                }
            };

            Content = stackLayout;
        }
Beispiel #5
0
        public SearchTabPage()
        {
            searchBar = new CustomSearchBar {
                Placeholder = "Search Summoner"
            };

            searchBar.SearchButtonPressed += async(sender, e) =>
            {
                string searchText = searchBar.Text.Replace(" ", "");
                searchBar.Text = "";
                searchBar.Unfocus();
                try
                {
                    UserDialogs.Instance.ShowLoading("Loading", MaskType.Black);
                    var summoner = await App.api.GetSummonerAsync(region, searchText);

                    icon = string.Format(icon, summoner.Region, summoner.Id);
                    var test = new SearchedSummonerPage(summoner, summoner.Region);
                    UserDialogs.Instance.HideLoading();
                    await Navigation.PushAsync(test);
                }
                catch
                {
                    UserDialogs.Instance.HideLoading();
                    await UserDialogs.Instance.AlertAsync("Try again", "Summoner not found!", "Okay");
                }
            };

            picker       = new Picker();
            picker.Title = "Region";

            picker.Items.Add(Region.euw.ToString().ToUpper());
            picker.Items.Add(Region.eune.ToString().ToUpper());
            picker.Items.Add(Region.na.ToString().ToUpper());
            picker.Items.Add(Region.kr.ToString().ToUpper());
            picker.Items.Add(Region.br.ToString().ToUpper());
            picker.Items.Add(Region.lan.ToString().ToUpper());
            picker.Items.Add(Region.las.ToString().ToUpper());
            picker.Items.Add(Region.oce.ToString().ToUpper());
            picker.Items.Add(Region.ru.ToString().ToUpper());
            picker.Items.Add(Region.tr.ToString().ToUpper());

            picker.SelectedIndex = 0;

            picker.SelectedIndexChanged += (sender, args) =>
            {
                switch (picker.SelectedIndex)
                {
                case 0:
                    region = Region.euw;
                    break;

                case 1:
                    region = Region.eune;
                    break;

                case 2:
                    region = Region.na;
                    break;

                case 3:
                    region = Region.kr;
                    break;

                case 4:
                    region = Region.br;
                    break;

                case 5:
                    region = Region.lan;
                    break;

                case 6:
                    region = Region.las;
                    break;

                case 7:
                    region = Region.oce;
                    break;

                case 8:
                    region = Region.ru;
                    break;

                case 9:
                    region = Region.tr;
                    break;
                }
            };
            var adView = new AdMobView {
                WidthRequest = 320, HeightRequest = 50
            };

            Content = new StackLayout
            {
                Children =
                {
                    searchBar,
                    picker,
                    adView
                }
            };
        }
        //Loads the current game if there is one
        public static async Task <ContentView> loadCurrentGameView(Summoner summoner, Region region, Page SearchPage)
        {
            var gameView = new ContentView();

            var currentTemplate = new DataTemplate(typeof(ImageCell));

            currentTemplate.SetBinding(TextCell.TextProperty, "Name");
            currentTemplate.SetBinding(ImageCell.ImageSourceProperty, "Icon");
            currentTemplate.SetBinding(TextCell.DetailProperty, "Rank");
            try
            {
                var currentGame = await api.GetCurrentGameAsync(App.PlatformToRegion(region), summoner.Id);

                grouped = new ObservableCollection <GroupedSummoners>();
                var blueTeam = new GroupedSummoners {
                    LongName = "Blue Team", ShortName = "B"
                };
                var redTeam = new GroupedSummoners {
                    LongName = "Red Team", ShortName = "R"
                };

                var list   = new ListView();
                var idList = new List <string>();
                summoners = new List <Summoner>();
                for (int i = 0; i < currentGame.Participants.Count; i++)
                {
                    idList.Add(currentGame.Participants[i].SummonerName);
                }
                summoners = await api.GetSummonersAsync(region, idList);

                for (int i = 0; i < currentGame.Participants.Count; i++)
                {
                    for (int j = 0; j < summoners.Count; j++)
                    {
                        if (currentGame.Participants[i].SummonerName == summoners[j].Name)
                        {
                            var champPlayed = await staticApi.GetChampionAsync(region, (int)currentGame.Participants[i].ChampionId, new List <ChampionData> {
                                ChampionData.image
                            });

                            try
                            {
                                allLeagues = await api.GetLeaguesAsync(region, new List <int> {
                                    (int)summoners[j].Id
                                });

                                ranked5v5League = allLeagues[summoners[j].Id].Single(x => x.Queue == Queue.RankedSolo5x5);
                                div             = ranked5v5League.Entries.Where(x => x.PlayerOrTeamId == summoners[j].Id.ToString()).Select(x => x.Division).Single();

                                if (currentGame.Participants[i].TeamId == 100)
                                {
                                    blueTeam.Add(new CurrentGamePlayers(summoners[j].Name,
                                                                        ranked5v5League.Tier + " " + div,
                                                                        (int)currentGame.Participants[i].ChampionId,
                                                                        champPlayed.Icon,
                                                                        summoners[i].Region));
                                }
                                else if (currentGame.Participants[i].TeamId == 200)
                                {
                                    redTeam.Add(new CurrentGamePlayers(summoners[j].Name,
                                                                       ranked5v5League.Tier + " " + div,
                                                                       (int)currentGame.Participants[i].ChampionId,
                                                                       champPlayed.Icon,
                                                                       summoners[i].Region));
                                }
                            }
                            catch
                            {
                                if (currentGame.Participants[i].TeamId == 100)
                                {
                                    blueTeam.Add(new CurrentGamePlayers(summoners[j].Name,
                                                                        "Level " + summoners[i].Level,
                                                                        (int)currentGame.Participants[i].ChampionId,
                                                                        champPlayed.Icon,
                                                                        summoners[i].Region));
                                }
                                else if (currentGame.Participants[i].TeamId == 200)
                                {
                                    redTeam.Add(new CurrentGamePlayers(summoners[j].Name,
                                                                       "Level " + summoners[i].Level,
                                                                       (int)currentGame.Participants[i].ChampionId,
                                                                       champPlayed.Icon,
                                                                       summoners[i].Region));
                                }
                            }
                        }
                    }
                }
                grouped.Add(blueTeam);
                grouped.Add(redTeam);

                list.ItemsSource         = grouped;
                list.IsGroupingEnabled   = true;
                list.GroupDisplayBinding = new Binding("LongName");
                list.ItemTemplate        = currentTemplate;

                list.ItemTapped += async(object sender, ItemTappedEventArgs e) =>
                {
                    var myListView = (ListView)sender;
                    var myItem     = (CurrentGamePlayers)myListView.SelectedItem;
                    try
                    {
                        UserDialogs.Instance.ShowLoading("Loading " + myItem.Name, MaskType.Black);
                        var summonerAsync = await api.GetSummonerAsync(myItem.Region, myItem.Name);

                        var page = SearchPage.Navigation.NavigationStack.Last();
                        var test = new SearchedSummonerPage(summonerAsync, myItem.Region);
                        UserDialogs.Instance.HideLoading();
                        await SearchPage.Navigation.PushAsync(test);

                        SearchPage.Navigation.RemovePage(page);
                    }
                    catch
                    {
                        UserDialogs.Instance.Alert("Whoops", "Something went wrong", "Okay");
                    }
                };
                if (!DependencyService.Get <ISaveAndLoad>().FileExists("haveyou"))
                {
                    var adView = new AdMobView {
                        WidthRequest = 320, HeightRequest = 50
                    };
                    list.Header = adView;
                }
                gameView.Content = list;
            }
            catch
            {
                gameView.Content = new Label {
                    Text = summoner.Name + " is not in an active game. Please try again later if the summoner is currently in game."
                };
            }
            return(gameView);
        }
        public static async Task <ListView> loadRanked(Summoner summoner, Region region, Page SearchPage)
        {
            var allItems          = App.itemList;
            var allSummonerSpells = App.summonerSpellList;

            var previousMatches = new List <MatchDetail>();
            var prevMatchList   = await api.GetMatchListAsync(summoner.Region, summoner.Id, null, null, null, null, null, 0, 9);

            foreach (var match in prevMatchList.Matches)
            {
                var tempMatch = await api.GetMatchAsync(region, match.MatchID);

                previousMatches.Add(tempMatch);
            }
            var previousRanked = new List <PreviousMatchesFile>();

            for (int i = 0; i < previousMatches.Count; i++)
            {
                var gameType          = "Ranked";
                var playerId          = previousMatches[i].ParticipantIdentities.FirstOrDefault(s => s.Player.SummonerId == summoner.Id).ParticipantId;
                var player            = previousMatches[i].Participants.FirstOrDefault(j => j.ParticipantId == playerId);
                var champPlayed       = App.championList.First(x => x.Id == player.ChampionId);
                var summonerSpellList = new List <UriImageSource>
                {
                    allSummonerSpells.FirstOrDefault(y => y.Id == player.Spell1Id).Icon,
                    allSummonerSpells.FirstOrDefault(y => y.Id == player.Spell2Id).Icon
                };
                var itemList = new List <ItemStatic>
                {
                    allItems.FirstOrDefault((x) => x.Id == player.Stats.Item0),
                    allItems.FirstOrDefault((x) => x.Id == player.Stats.Item1),
                    allItems.FirstOrDefault((x) => x.Id == player.Stats.Item2),
                    allItems.FirstOrDefault((x) => x.Id == player.Stats.Item3),
                    allItems.FirstOrDefault((x) => x.Id == player.Stats.Item4),
                    allItems.FirstOrDefault((x) => x.Id == player.Stats.Item5),
                    allItems.FirstOrDefault((x) => x.Id == player.Stats.Item6)
                };
                var itemNameList = new List <UriImageSource>();
                for (int j = 0; j < itemList.Count; j++)
                {
                    if (itemList[j] != null)
                    {
                        itemNameList.Add(itemList[j].Icon);
                    }
                    else
                    {
                        itemNameList.Add(App.emptyIcon);
                    }
                }

                var prev = new PreviousMatchesFile(
                    gameType,
                    player.ChampionId,
                    (int)player.Stats.ChampLevel,
                    player.Stats.Winner,
                    App.FormatNumber((int)player.Stats.GoldEarned),
                    player.Stats.MinionsKilled.ToString(),
                    itemNameList,
                    summonerSpellList,
                    champPlayed.Icon,
                    previousMatches[i].MatchCreation.ToString("g"),
                    player.Stats.Kills + "/" + player.Stats.Deaths + "/" + player.Stats.Assists,
                    previousMatches[i]
                    );
                previousRanked.Add(prev);
            }

            var imageTemplate = new DataTemplate(typeof(PreviousGameCell));
            var listView      = new ListView
            {
                ItemTemplate  = imageTemplate,
                HasUnevenRows = true,
                ItemsSource   = previousRanked
            };

            listView.ItemTapped += async(object sender, ItemTappedEventArgs e) =>
            {
                var myListView = (ListView)sender;
                var myItem     = (PreviousMatchesFile)myListView.SelectedItem;
                UserDialogs.Instance.ShowLoading("Loading Game", MaskType.Black);
                try
                {
                    Debug.WriteLine(myItem.ThisGame.MatchId);
                    var previousPage = await PreviousRankedPage.loadPrevious(myItem.ThisGame, Region, Summoner, myItem.champId, myItem.ThisGame.Participants, myItem.ThisGame.ParticipantIdentities);

                    UserDialogs.Instance.HideLoading();
                    await SearchPage.Navigation.PushAsync(previousPage);
                }
                catch (Exception ex)
                {
                    UserDialogs.Instance.HideLoading();
                    Debug.WriteLine(ex);
                    await UserDialogs.Instance.AlertAsync("Are you connected to the internet?\nTry again", "An Error Occured", "Okay");
                }
            };
            if (!DependencyService.Get <ISaveAndLoad>().FileExists("haveyou"))
            {
                var adView = new AdMobView {
                    WidthRequest = 320, HeightRequest = 50
                };
                listView.Header = adView;
            }
            return(listView);
        }
        public static async Task <ListView> loadMatchHistory(Summoner summoner, Region region, Page SearchPage)
        {
            var allItems          = App.itemList;
            var allSummonerSpells = App.summonerSpellList;

            var previousMatches = await summoner.GetRecentGamesAsync();

            var previousAll = new List <Previous>();

            for (int i = 0; i < previousMatches.Count; i++)
            {
                var gameType          = App.gameTypeName(previousMatches[i].GameSubType);
                var champPlayed       = App.championList.First(c => c.Id == previousMatches[i].ChampionId);
                var summonerSpellList = new List <UriImageSource>
                {
                    allSummonerSpells.FirstOrDefault(y => y.Id == previousMatches[i].SummonerSpell1).Icon,
                    allSummonerSpells.FirstOrDefault(y => y.Id == previousMatches[i].SummonerSpell2).Icon
                };
                var itemList = new List <ItemStatic>
                {
                    allItems.FirstOrDefault((x) => x.Id == previousMatches[i].Statistics.Item0),
                    allItems.FirstOrDefault((x) => x.Id == previousMatches[i].Statistics.Item1),
                    allItems.FirstOrDefault((x) => x.Id == previousMatches[i].Statistics.Item2),
                    allItems.FirstOrDefault((x) => x.Id == previousMatches[i].Statistics.Item3),
                    allItems.FirstOrDefault((x) => x.Id == previousMatches[i].Statistics.Item4),
                    allItems.FirstOrDefault((x) => x.Id == previousMatches[i].Statistics.Item5),
                    allItems.FirstOrDefault((x) => x.Id == previousMatches[i].Statistics.Item6)
                };
                var itemNameList = new List <UriImageSource>();
                for (int j = 0; j < itemList.Count; j++)
                {
                    if (itemList[j] != null)
                    {
                        itemNameList.Add(itemList[j].Icon);
                    }
                    else
                    {
                        itemNameList.Add(App.emptyIcon);
                    }
                }

                var prev = new Previous(
                    gameType,
                    previousMatches[i].Level,
                    previousMatches[i].Statistics.Win,
                    App.FormatNumber(previousMatches[i].Statistics.GoldEarned),
                    previousMatches[i].Statistics.MinionsKilled.ToString(),
                    itemNameList,
                    summonerSpellList,
                    champPlayed.Icon,
                    previousMatches[i].CreateDate.ToString("g"),
                    previousMatches[i].Statistics.ChampionsKilled + "/" + previousMatches[i].Statistics.NumDeaths + "/" + previousMatches[i].Statistics.Assists,
                    previousMatches[i]
                    );
                previousAll.Add(prev);
            }

            var imageTemplate = new DataTemplate(typeof(PreviousGameCell));
            var listView      = new ListView
            {
                ItemTemplate  = imageTemplate,
                HasUnevenRows = true,
                ItemsSource   = previousAll
            };

            listView.ItemTapped += async(object sender, ItemTappedEventArgs e) =>
            {
                var myListView = (ListView)sender;
                var myItem     = (Previous)myListView.SelectedItem;
                UserDialogs.Instance.ShowLoading("Loading Game", MaskType.Black);
                try
                {
                    Debug.WriteLine(myItem.ThisGame.GameId);
                    var match = await api.GetMatchAsync(Region, myItem.ThisGame.GameId);

                    var previousPage = await PreviousGamePage.loadPrevious(match, myItem.ThisGame, Region, Summoner, myItem.ThisGame.FellowPlayers);

                    UserDialogs.Instance.HideLoading();
                    await SearchPage.Navigation.PushAsync(previousPage);
                }
                catch (Exception ex)
                {
                    UserDialogs.Instance.HideLoading();
                    Debug.WriteLine(ex);
                    await UserDialogs.Instance.AlertAsync("Are you connected to the internet?\nTry again", "An Error Occured", "Okay");
                }
            };
            if (!DependencyService.Get <ISaveAndLoad>().FileExists("haveyou"))
            {
                var adView = new AdMobView {
                    WidthRequest = 320, HeightRequest = 50
                };
                listView.Header = adView;
            }
            return(listView);
        }
Beispiel #9
0
        public ListView LoadAbilities(ChampionStatic champion)
        {
            var abilityListView = new ListView
            {
                HasUnevenRows = true
            };

            if (!DependencyService.Get <ISaveAndLoad>().FileExists("haveyou"))
            {
                var adView = new AdMobView {
                    WidthRequest = 320, HeightRequest = 50
                };
                abilityListView.Header = adView;
            }

            var abilityTemplate = new DataTemplate(typeof(AbilityCell));

            var abilityList = new List <abilityView>();

            if (champion.Id != 420)
            {
                var stringId = champion.Id.ToString();
                if (champion.Id == 2 || champion.Id == 3 || champion.Id == 4 || champion.Id == 8)
                {
                    abilityList.Add(new abilityView {
                        Name = champion.Passive.Name, Description = champion.Passive.Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/passive/{1}", App.appVersion, champion.Passive.Image.Full), Video = string.Format("https://lolstatic-a.akamaihd.net/champion-abilities/videos/mp4/000{0}_01.mp4", champion.Id)
                    });
                    abilityList.Add(new abilityView {
                        Name = champion.Spells[0].Name, Description = champion.Spells[0].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[0].Image.Full), Video = string.Format("https://lolstatic-a.akamaihd.net/champion-abilities/videos/mp4/000{0}_0{1}.mp4", champion.Id, 1)
                    });
                    abilityList.Add(new abilityView {
                        Name = champion.Spells[1].Name, Description = champion.Spells[1].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[1].Image.Full), Video = string.Format("https://lolstatic-a.akamaihd.net/champion-abilities/videos/mp4/000{0}_0{1}.mp4", champion.Id, 2)
                    });
                    abilityList.Add(new abilityView {
                        Name = champion.Spells[2].Name, Description = champion.Spells[2].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[2].Image.Full), Video = string.Format("https://lolstatic-a.akamaihd.net/champion-abilities/videos/mp4/000{0}_0{1}.mp4", champion.Id, 3)
                    });
                    abilityList.Add(new abilityView {
                        Name = champion.Spells[3].Name, Description = champion.Spells[3].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[3].Image.Full), Video = string.Format("https://lolstatic-a.akamaihd.net/champion-abilities/videos/mp4/000{0}_0{1}.mp4", champion.Id, 4)
                    });
                }
                else if (champion.Id == 240 || champion.Id == 164)
                {
                    abilityList.Add(new abilityView {
                        Name = champion.Passive.Name, Description = champion.Passive.Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/passive/{1}", App.appVersion, champion.Passive.Image.Full), Video = "No Video"
                    });
                    abilityList.Add(new abilityView {
                        Name = champion.Spells[0].Name, Description = champion.Spells[0].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[0].Image.Full), Video = "No Video"
                    });
                    abilityList.Add(new abilityView {
                        Name = champion.Spells[1].Name, Description = champion.Spells[1].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[1].Image.Full), Video = "No Video"
                    });
                    abilityList.Add(new abilityView {
                        Name = champion.Spells[2].Name, Description = champion.Spells[2].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[2].Image.Full), Video = "No Video"
                    });
                    abilityList.Add(new abilityView {
                        Name = champion.Spells[3].Name, Description = champion.Spells[3].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[3].Image.Full), Video = "No Video"
                    });
                }
                else if (champion.Id == 12 || champion.Id == 36 || champion.Id == 9 || champion.Id == 120 || champion.Id == 126 ||
                         champion.Id == 85 || champion.Id == 82 || champion.Id == 25 || champion.Id == 78 || champion.Id == 33 ||
                         champion.Id == 102 || champion.Id == 27 || champion.Id == 134 || champion.Id == 91 || champion.Id == 77 ||
                         champion.Id == 45 || champion.Id == 106 || champion.Id == 62)
                {
                    abilityList.Add(new abilityView {
                        Name = champion.Passive.Name, Description = champion.Passive.Description, Image = champion.Passive.Image.Full, Video = "No Video"
                    });

                    for (int i = 0; i < champion.Spells.Count; i++)
                    {
                        switch (stringId.Length)
                        {
                        case 1:
                            abilityList.Add(new abilityView {
                                Name = champion.Spells[i].Name, Description = champion.Spells[i].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[i].Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/000{0}_0{1}.mp4", champion.Id, i + 2)
                            });
                            break;

                        case 2:
                            abilityList.Add(new abilityView {
                                Name = champion.Spells[i].Name, Description = champion.Spells[i].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[i].Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/00{0}_0{1}.mp4", champion.Id, i + 2)
                            });
                            break;

                        case 3:
                            abilityList.Add(new abilityView {
                                Name = champion.Spells[i].Name, Description = champion.Spells[i].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[i].Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/0{0}_0{1}.mp4", champion.Id, i + 2)
                            });
                            break;

                        case 4:
                            abilityList.Add(new abilityView {
                                Name = champion.Spells[i].Name, Description = champion.Spells[i].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[i].Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/{0}_0{1}.mp4", champion.Id, i + 2)
                            });
                            break;
                        }
                    }
                }
                else
                {
                    switch (stringId.Length)
                    {
                    case 1:
                        abilityList.Add(new abilityView {
                            Name = champion.Passive.Name, Description = champion.Passive.Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/passive/{1}", App.appVersion, champion.Passive.Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/000{0}_01.mp4", champion.Id)
                        });
                        break;

                    case 2:
                        abilityList.Add(new abilityView {
                            Name = champion.Passive.Name, Description = champion.Passive.Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/passive/{1}", App.appVersion, champion.Passive.Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/00{0}_01.mp4", champion.Id)
                        });
                        break;

                    case 3:
                        abilityList.Add(new abilityView {
                            Name = champion.Passive.Name, Description = champion.Passive.Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/passive/{1}", App.appVersion, champion.Passive.Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/0{0}_01.mp4", champion.Id)
                        });
                        break;

                    case 4:
                        abilityList.Add(new abilityView {
                            Name = champion.Passive.Name, Description = champion.Passive.Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/passive/{1}", App.appVersion, champion.Passive.Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/{0}_01.mp4", champion.Id)
                        });
                        break;
                    }

                    for (int i = 0; i < champion.Spells.Count; i++)
                    {
                        switch (stringId.Length)
                        {
                        case 1:
                            abilityList.Add(new abilityView {
                                Name = champion.Spells[i].Name, Description = champion.Spells[i].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[i].Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/000{0}_0{1}.mp4", champion.Id, i + 2)
                            });
                            break;

                        case 2:
                            abilityList.Add(new abilityView {
                                Name = champion.Spells[i].Name, Description = champion.Spells[i].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[i].Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/00{0}_0{1}.mp4", champion.Id, i + 2)
                            });
                            break;

                        case 3:
                            abilityList.Add(new abilityView {
                                Name = champion.Spells[i].Name, Description = champion.Spells[i].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[i].Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/0{0}_0{1}.mp4", champion.Id, i + 2)
                            });
                            break;

                        case 4:
                            abilityList.Add(new abilityView {
                                Name = champion.Spells[i].Name, Description = champion.Spells[i].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[i].Image.Full), Video = string.Format("http://cdn.leagueoflegends.com/champion-abilities/videos/mp4/{0}_0{1}.mp4", champion.Id, i + 2)
                            });
                            break;
                        }
                    }
                }
            }
            else
            {
                abilityList.Add(new abilityView {
                    Name = champion.Passive.Name, Description = champion.Passive.Description, Image = champion.Passive.Image.Full, Video = "http://news.cdn.leagueoflegends.com/public/images/pages/illaoi-reveal/videos/Illaoi_P.mp4"
                });
                abilityList.Add(new abilityView {
                    Name = champion.Spells[0].Name, Description = champion.Spells[0].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[0].Image.Full), Video = "http://news.cdn.leagueoflegends.com/public/images/pages/illaoi-reveal/videos/Illaoi_Q.mp4"
                });
                abilityList.Add(new abilityView {
                    Name = champion.Spells[1].Name, Description = champion.Spells[1].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[1].Image.Full), Video = "http://news.cdn.leagueoflegends.com/public/images/pages/illaoi-reveal/videos/Illaoi_W.mp4"
                });
                abilityList.Add(new abilityView {
                    Name = champion.Spells[2].Name, Description = champion.Spells[2].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[2].Image.Full), Video = "http://news.cdn.leagueoflegends.com/public/images/pages/illaoi-reveal/videos/Illaoi_E.mp4"
                });
                abilityList.Add(new abilityView {
                    Name = champion.Spells[3].Name, Description = champion.Spells[3].Description, Image = string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, champion.Spells[3].Image.Full), Video = "http://news.cdn.leagueoflegends.com/public/images/pages/illaoi-reveal/videos/Illaoi_R.mp4"
                });
            }
            abilityListView.ItemTemplate = abilityTemplate;
            abilityListView.ItemsSource  = abilityList;

            abilityListView.ItemTapped += (sender, e) =>
            {
                abilityListView.IsEnabled = false;
                var myListView = (ListView)sender;
                var myItem     = (abilityView)myListView.SelectedItem;
                if (myItem.Video == "No Video")
                {
                    UserDialogs.Instance.AlertAsync("Sadly, the ability " + myItem.Name + " doesn't have a video associated with it.", "Unable To Load", "Okay");
                    abilityListView.IsEnabled = true;
                    return;
                }

                var webview = new WebView
                {
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Source            = new UrlWebViewSource
                    {
                        Url = myItem.Video
                    }
                };

                var contentPage = new ContentPage
                {
                    Content = webview,
                    Title   = myItem.Name
                };
                abilityListView.IsEnabled = true;
                Navigation.PushAsync(contentPage);
            };
            return(abilityListView);
        }