public async Task getSummAsync() { grouped = new ObservableCollection <GroupedSearchesAndFavorites>(); var searchesGroup = new GroupedSearchesAndFavorites { LongName = "Favorite", ShortName = "F" }; for (int i = 0; i < App.FavoriteDatabase.GetItems().Count; i++) { if (App.FavoriteDatabase.GetItems()[i].Name != "") { var reg = regFromString(App.FavoriteDatabase.GetItems()[i].Region.ToLower()); var sum = await api.GetSummonerAsync(reg, App.FavoriteDatabase.GetItems()[i].summonerID); if (sum.Name == App.FavoriteDatabase.GetItems()[i].Name) { searchesGroup.Add(App.FavoriteDatabase.GetItems()[i]); } else { App.FavoriteDatabase.DeleteItem(i + 1); icon = string.Format(icon, sum.Region, sum.Id); var newItem = new SearchesAndFavorites { Name = sum.Name, Region = sum.Region.ToString().ToUpper(), Icon = icon, summonerID = (int)sum.Id }; App.FavoriteDatabase.SaveItem(newItem); searchesGroup.Add(newItem); icon = iconReset; } } } }
public async Task Refresh() { grouped = new ObservableCollection <GroupedSearchesAndFavorites>(); var searchesGroup = new GroupedSearchesAndFavorites { LongName = "Favourite", ShortName = "F" }; for (int i = 0; i < App.FavoriteDatabase.GetItems().Count; i++) { if (App.FavoriteDatabase.GetItems()[i].Name != "") { searchesGroup.Add(App.FavoriteDatabase.GetItems()[i]); } } grouped.Add(searchesGroup); listview.ItemsSource = grouped; listview.IsGroupingEnabled = true; //listview.GroupDisplayBinding = new Binding("LongName"); await getSummAsync(); }