private async void LoadData(string id) { await Mvvm.Dispatcher.DispatcherHelper.RunAsync(async() => { SetMessage(Core.StringMessage.LoadingPleaseWait); if (!App.Locator.Network.IsActive) { SetMessage(Core.StringMessage.NoInternetConnection); return; } ClearSpotifyArtistViewModelData(); TopTracks = new ObservableCollection <Base>(); TopAlbums = new ObservableCollection <Base>(); try { Artist = await _scrobbler.GetDetailArtistByMbid(id); if (Artist == null) { Artist = await _scrobbler.GetDetailArtist(id); } Name = Artist.Name; var track = await _scrobbler.GetArtistTopTracks(Name); var albums = await _scrobbler.GetArtistTopAlbums(Name); if (track != null) { int indexToAdd = -1; foreach (var oSong in track) { indexToAdd++; if (indexToAdd == 9 && Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile") { break; } else if (indexToAdd >= 20) { break; } else { TopTracks.Add(Data.Model.WebSongConverter.CreateSong(oSong)); if (indexToAdd == 2 || indexToAdd == 10 || indexToAdd == 22 || indexToAdd == 34 || indexToAdd == 49 || indexToAdd == 63 || indexToAdd == 78 || indexToAdd == 88 || indexToAdd == 99) { TopTracks.Insert(indexToAdd, new ListAdvert()); } } } } if (albums != null) { int indexToAdd = -1; foreach (var oAlbum in albums?.Content) { if (indexToAdd == 9 && Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile") { break; } else if (indexToAdd >= 20) { break; } if (!string.IsNullOrEmpty(oAlbum.Mbid) || !string.IsNullOrEmpty(oAlbum.Id)) { indexToAdd++; TopAlbums.Add(Data.Model.WebSongConverter.CreateAlbum(oAlbum)); } } } if (track != null) { track = null; } if (albums != null) { albums = null; } } catch (Exception) { IsLoading = false; SetMessage(Core.StringMessage.SomethinWentWrong); return; } if (Artist != null && ((TopAlbums != null && TopAlbums.Count > 0) || (TopTracks != null && TopTracks.Count > 0))) { OverViewMessage = Core.StringMessage.NoMessge; } else { OverViewMessage = Core.StringMessage.EmptyMessage; } if (Artist != null && TopAlbums != null && TopAlbums.Count > 0) { AlbumMessage = Core.StringMessage.NoMessge; } else { AlbumMessage = Core.StringMessage.EmptyMessage; } if (Artist != null && TopTracks != null && TopTracks.Count > 0) { TrackMessage = Core.StringMessage.NoMessge; } else { TrackMessage = Core.StringMessage.EmptyMessage; } IsLoading = false; }); }