protected override async void OnAppearing() { base.OnAppearing(); IsBusy = true; var response = await httpClient.GetAsync(URL); if (response.IsSuccessStatusCode) { var jsonResponse = await response.Content.ReadAsStringAsync(); try { var albumsResponse = JsonConvert.DeserializeObject <List <Album> >(jsonResponse); if (albumsResponse.Count > 0) { Albums.Clear(); foreach (var album in albumsResponse) { Albums.Add(album); } } } catch (Exception) { await DisplayAlert("Error", "No se pudo descargar la lista de albums", "Ok"); } } else { await DisplayAlert("Error", "No se pudo descargar la lista de albums", "Ok"); } IsBusy = false; }
void ExecuteLoadCommand() { if (IsBusy) { return; } IsBusy = true; if (CurrentGroup == null) { IsBusy = false; return; } try { Albums.Clear(); CurrentGroup.Albums.ForEach(p => Albums.Add(p)); OnPropertyChanged("HasAlbums"); OnPropertyChanged("NoAlbums"); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public void Clear() { Artists.Clear(); Albums.Clear(); Geneires.Clear(); Years.Clear(); }
private void ClearViewModel() { Albums.Clear(); Artists.Clear(); Playlists.Clear(); Tracks.Clear(); }
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { Tracks = Tracks ?? new SimpleStateSupportCollection <JumpListGroup <VKSaverTrack> >(LoadTracks); Artists = Artists ?? new SimpleStateSupportCollection <JumpListGroup <VKSaverArtist> >(LoadArtists); Albums = Albums ?? new SimpleStateSupportCollection <JumpListGroup <VKSaverAlbum> >(LoadAlbums); Genres = Genres ?? new SimpleStateSupportCollection <JumpListGroup <VKSaverGenre> >(LoadGenres); Folders = Folders ?? new SimpleStateSupportCollection <VKSaverFolder>(LoadFolders); Cached = Cached ?? new SimpleStateSupportCollection <JumpListGroup <VKSaverTrack> >(LoadCachedTracks); if (_libraryDatabaseService.NeedReloadLibraryView) { Tracks.Clear(); Artists.Clear(); Albums.Clear(); Genres.Clear(); Folders.Clear(); Cached.Clear(); _libraryDatabaseService.NeedReloadLibraryView = false; } if (viewModelState.Count > 0) { CurrentPivotIndex = (int)viewModelState[nameof(CurrentPivotIndex)]; } else { string viewName = (string)e.Parameter; SetPivotIndex(viewName); } base.OnNavigatedTo(e, viewModelState); }
private void OnLibraryUpdated(string s) { DispatcherHelper.CheckBeginInvokeOnUI(() => { Albums.Clear(); LoadAlbums(); }); }
void ClearDatabase() { musicDatabase.DeleteAll(); musicDatabase.DeleteAll(); musicDatabase.DeleteAll(); trackCollectionRepository.DeleteAll(); tracklistItemRepository.DeleteAll(); musicDatabase.Initialize(); musicDatabase.Initialize(); musicDatabase.Initialize(); trackCollectionRepository.Initialize(); tracklistItemRepository.Initialize(); Artists.Clear(); Albums.Clear(); Tracks.Clear(); TrackCollections.Clear(); videoDatabase.DeleteAll(); Videos.Clear(); CameraRoll.Clear(); Shows.Clear(); }
public async Task Initialize() { Artists.Clear(); Albums.Clear(); Tracks.Clear(); TrackCollections.Clear(); Videos.Clear(); CameraRoll.Clear(); Shows.Clear(); if (_alreadyIndexedOnce) { return; } _alreadyIndexedOnce = true; // Doing full indexing from scratch if 0 tracks are found if (IsMusicDatabaseEmpty() && IsVideoDatabaseEmpty()) { ClearDatabase(); } else // Restore the database { LoadVideosFromDatabase(); await LoadShowsFromDatabase(); LoadCameraRollFromDatabase(); } await PerformMediaLibraryIndexing(); }
public void ResetMusicContent() { Tracks.Clear(); Albums.Clear(); Artists.Clear(); Playlists.Clear(); }
async Task ExecuteSearchAlbumsCommand(string searchTerm) { if (IsBusy) { return; } IsBusy = true; try { Albums.Clear(); var albums = await DataStore.GetItemsAsync(searchTerm).ConfigureAwait(false); foreach (var album in albums) { Albums.Add(album); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async Task ExectueLoadAlbumsCommand() { Albums.Clear(); var albums = await AlbumsDataStore.GetItemsAsync().ConfigureAwait(false); Albums = new ObservableCollection <Album>(albums); }
async Task Load() { if (IsBusy) { return; } IsBusy = true; Albums.Clear(); page = 1; var albums = await AlbumService.Instance.GetAlbums(page); if (albums.Count() > 0) { foreach (var a in albums) { Albums.Add(a); } page++; if (page <= 100) { CanLoadMore = true; } else { CanLoadMore = false; } } IsBusy = false; }
public void LoadAlbumsFromDatabase() { Albums.Clear(); LogHelper.Log("Loading albums from MusicDB ..."); var albums = musicDatabase.LoadAlbums().ToObservable(); var orderedAlbums = albums.OrderBy(x => x.Artist).ThenBy(x => x.Name); Albums.AddRange(orderedAlbums); }
public void OnLoad() { Albums.Clear(); var albums = albumRepository.GetAll(); foreach (var album in albums) { Albums.Add(album); } }
public async Task LoadAsync() { var lookup = await _albumLookupDataService.GetAlbumLookupAsync(); Albums.Clear(); foreach (var item in lookup) { Albums.Add(new NavigationItemViewModel(item.ID, item.DisplayMember)); } }
public async void DisplayAllAlbums() { ObservableCollection <Images> tempalbums = new ObservableCollection <Images>(await FileHelper.GetAllAlbumsAsync()); Albums.Clear(); for (int i = 0; i < tempalbums.Count; i++) { Albums.Add(tempalbums[i]); } }
private void UpdateAlbumList() { Albums.Clear(); List <Album> temp = QueryManager.GetAlbumsByArtistId(_selectedArtist.ArtistId); for (int i = 0; i < temp.Count; i++) { Albums.Add(temp[i]); } }
public AlbumListViewModel(Group group) { if (group == null) { throw new ApplicationException("No group set for album list"); } Title = group.Name; LoadCommand = new Command(() => { if (IsBusy) { return; } IsBusy = true; if (group == null) { IsBusy = false; return; } try { Albums.Clear(); group.Albums.ForEach(p => Albums.Add(p)); OnPropertyChanged("IsListEmpty"); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }); MessagingCenter.Subscribe <Album>(this, "upsert", async album => { album.GroupId = group.Id; album = await dataService.UpsertAsync(album); if (group.Albums == null) { group.Albums = new List <Album>(); } group.Albums.Upsert(album); Albums.Upsert(album); OnPropertyChanged("IsListEmpty"); }); MessagingCenter.Subscribe <Album>(this, "delete", async album => { await dataService.Delete(album); group.Albums.Remove(album); Albums.Delete(album); OnPropertyChanged("IsListEmpty"); }); LoadCommand.Execute(null); }
private void SearchAlbums(string searchQuery) { Albums.Clear(); foreach (var item in AllAlbums) { if (item.AlbumName.ToLower().Contains(searchQuery.ToLower())) { Albums.Add(item); } } }
public override void Cleanup() { _artistsLoaded = _albumsLoaded = _songsLoaded = _genresLoaded = false; _parentId = null; Genres.Clear(); Songs.Clear(); Artists.Clear(); Albums.Clear(); SelectedTracks.Clear(); base.Cleanup(); }
private async void Refresh() { await ServiceLocator.LocalMusicService.Clear(); if (Tracks != null) { Tracks.Clear(); } if (Artists != null) { Artists.Clear(); } if (Albums != null) { Albums.Clear(); } if (AlbumGroups != null) { AlbumGroups.Clear(); } if (SelectedArtistAlbums != null) { SelectedArtistAlbums.Clear(); } var flyout = new FlyoutControl(); flyout.FlyoutContent = new MusicScanView(); await flyout.ShowAsync(); switch (SelectedTabIndex) { case 0: LoadTracks(); break; case 1: LoadAlbums(); break; case 2: LoadArtists(); break; } }
private void ReloadTables() { Albums?.Clear(); var _tables = SqlWorker.GetTables(); if (_tables == null) { return; } foreach (DataTable i in _tables) { Albums.Add(i); } }
public void Rebuild(IEnumerable <Song> songs) { Albums.Clear(); Artists.Clear(); Years.Clear(); Geneires.Clear(); foreach (var s in songs) { Albums.Add(s.Album); Artists.Add(s.Artist); Years.Add(s.Year.ToString()); Geneires.Add(s.Genre); } }
protected override void GetAlbumInfoWithTimer() { log.Debug("Discogs: Looking up Album on Discogs"); Albums.Clear(); try { var task = GetAlbumQuery(); var result = task.Result; // Ignoring the result here, since we have added the album already in the task. log.Debug($"Discogs: Found {Albums.Count} albums"); } catch (Exception ex) { log.Debug($"Discogs: Exception receiving Album Information. {ex.Message} {ex.StackTrace}"); } }
private async Task SearchAlbums(string searchQuery) { if (AddAlbums == true) { if (string.IsNullOrWhiteSpace(searchQuery)) { await Application.Current.MainPage.DisplayAlert("Error", "Please type in the search bar", "OK"); return; } var searchResult = await _albumService.Get <List <Album> >(new AlbumSearchRequest() { AlbumName = searchQuery }); Albums.Clear(); foreach (var item in searchResult) { var thisArtist = await _artistService.GetById <Artist>(item.ArtistId); AlbumHelperVM local = new AlbumHelperVM() { AlbumId = item.AlbumId, AlbumName = item.AlbumName, ArtistId = thisArtist.ArtistId, ArtistName = thisArtist.ArtistName, AlbumGeneratedRating = "Rating: " + item.AlbumGeneratedRating.ToString() + "/5", AlbumPhoto = item.AlbumPhoto, DateReleased = item.DateReleased }; Albums.Add(local); } } else { Albums.Clear(); foreach (var item in AllAlbums) { if (item.AlbumName.ToLower().Contains(searchQuery.ToLower())) { Albums.Add(item); } } } }
void CreateFolder_Completed(object sender, LiveOperationCompletedEventArgs e) { if (e.Error == null) { // succesful. Dispatcher.BeginInvoke(() => { Albums.Clear(); GetAlubmData(); } ); } else { string newAlbumFaild = SkyPhoto.Resources.Resources.newAlbumFaild; MessageBox.Show(newAlbumFaild); } }
void CreateFolder_Completed(LiveOperationResult result) { if (result != null) { // succesful. Dispatcher.BeginInvoke(() => { Albums.Clear(); GetAlubmData(); } ); } else { string newAlbumFaild = SkyPhoto.Resources.Resources.newAlbumFaild; MessageBox.Show(newAlbumFaild); } }
protected override void GetAlbumInfoWithTimer() { log.Debug("MusicBrainz: Looking up Album on MusicBrainz"); Albums.Clear(); try { var album = GetAlbumQuery(ArtistName, AlbumName); if (album.Result != null) { Albums.Add(album.Result); } log.Debug($"MusicBrainz: Found {Albums.Count} albums"); } catch (Exception ex) { log.Debug($"MusicBrainz: Exception receiving Album Information. {ex.Message} {ex.StackTrace}"); } }
private async void SearchAlbums(string query) { Albums.Clear(); List <int> foundAlbums = await SearchManagerModel.SearchAlbums(query); foreach (int albumId in foundAlbums) { AlbumViewModel foundAlbum = LibraryViewModel.Current.LookupAlbumById(albumId); if (foundAlbum != null) { Albums.Add(foundAlbum); } } albumSearchInProgress = false; NotifyPropertyChanged(Properties.SearchInProgress); NotifyPropertyChanged(Properties.ContentInfoAlbums); }
async Task GetAlbumsAsync() { if (IsBusy) { return; } try { IsBusy = true; var config = SpotifyClientConfig.CreateDefault(); var request = new ClientCredentialsRequest(clientId, clientSecret); var response = await new OAuthClient(config).RequestToken(request); var spotify = new SpotifyClient(config.WithToken(response.AccessToken)); var albumsRaw = await spotify.Artists.GetAlbums(Authors[AuthorSelected]); var albums = albumsRaw.Items; Albums.Clear(); foreach (var album in albums) { var songsRaw = await spotify.Albums.GetTracks(album.Id); var songs = songsRaw.Items; Albums.Add(Album.FromSimpleAlbum(album, songs)); } } catch (Exception ex) { Debug.WriteLine($"Error to get albums: {ex.Message}"); await Application.Current.MainPage.DisplayAlert("Error with albums! ", ex.Message, "Dobrá"); } finally { IsBusy = false; } }