public async Task LoadItems()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                SavedList.Clear();

                var notationList = await NotationStorageHelper.GetAll();

                NothingToSee = notationList.Count == 0;

                foreach (var item in notationList)
                {
                    SavedList.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 2
0
        public async void ToggleFavoriteNotation()
        {
            if (HasFavoritedNotation)
            { // unfavoriting
                var success = await _serviceFavorites.Delete <bool>(_notationId);

                if (success)
                {
                    _favoriteToolbarItem.IconImageSource = ImageSource.FromFile("star_empty.png");
                    HasFavoritedNotation = false;

                    NotationStorageHelper.Remove(_notationId);
                }
            }
            else
            { // favoriting
                var request = new Model.Requests.FavoritesInsertRequest
                {
                    NotationId = _notationId
                };
                var entity = await _serviceFavorites.Insert <Model.Favorites>(request);

                if (entity != null)
                {
                    _favoriteToolbarItem.IconImageSource = ImageSource.FromFile("star_filled.png");
                    HasFavoritedNotation = true;
                }
            }
        }
Exemplo n.º 3
0
        private void LoadDownloadButton()
        {
            var notation = NotationStorageHelper.Get(_notationId);

            if (notation != null)
            {
                _downloadToolbarItem.IconImageSource = ImageSource.FromFile("icon_downloaded.png");
            }
            else
            {
                _downloadToolbarItem.IconImageSource = ImageSource.FromFile("icon_download.png");
            }
        }
        private async Task LoadSavedItems()
        {
            SavedNotationsList.Clear();
            var notations = await NotationStorageHelper.GetAll();

            foreach (var item in notations)
            {
                if (item.Song.Album.AlbumCover.Length == 0)
                {
                    item.Song.Album.AlbumCover = File.ReadAllBytes("logo.png");
                }
                SavedNotationsList.Add(item);
            }
        }
Exemplo n.º 5
0
        public async void DownloadNotation()
        {
            var notation = NotationStorageHelper.Get(_notationId);

            if (notation != null)
            {
                NotationStorageHelper.Remove(_notationId);
                _downloadToolbarItem.IconImageSource = ImageSource.FromFile("icon_download.png");
                await Application.Current.MainPage.DisplayAlert("Success", "Notation has been deleted from the device.", "OK");
            }
            else
            {
                await NotationStorageHelper.Add(_notation);

                _downloadToolbarItem.IconImageSource = ImageSource.FromFile("icon_downloaded.png");
                await Application.Current.MainPage.DisplayAlert("Success", "Notation successfully saved.", "OK");
            }
        }
 private async void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
 {
     if (e.Item != null)
     {
         Models.MenuItem menuItem = e.Item as Models.MenuItem;
         if (menuItem.Page == null)
         {
             SecureStorage.Remove("username");
             SecureStorage.Remove("password");
             NotationStorageHelper.RemoveAll();
             Application.Current.MainPage = new LoginPage();
         }
         else
         {
             Page instance = (Page)Activator.CreateInstance(menuItem.Page);
             await Navigation.PushAsync(instance);
         }
     }
 }
Exemplo n.º 7
0
        private async Task LoadNotation()
        {
            if (HasConnectivity)
            {
                Notation = await _serviceNotations.GetById <Model.Notations>(_notationId);
            }
            else
            {
                Notation = NotationStorageHelper.Get(_notationId);
                if (Notation == null)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Could not load notation.", "OK");

#pragma warning disable CS0612 // Type or member is obsolete
                    Application.Current.MainPage = new MainPage();
#pragma warning restore CS0612 // Type or member is obsolete
                    return;
                }
            }

            LastEditInfo = "on " + Notation.LastEditted.ToShortDateString();
            Title        = Notation.Type.ToString() + "s";
        }