public override void ViewWillAppear(bool animated) { base.ViewWillAppear (animated); // This is not double loading becuase it is a new _loader each time and the _newSL is a get set _loader = new List<SongToSave> (); _dbWorker = new DBWorker (); _dbWorker.StartDBWorker (); dbPath = _dbWorker.GetPathToDb (); var conn = new SQLiteConnection (dbPath); // this seems redundant. foreach (var item in conn.Table<SongToSave>()) { var tempSong = new SongToSave () { BookTitle = item.BookTitle, BookAuthor = item.BookAuthor, PlayPosition = item.PlayPosition }; _loader.Add (tempSong); } conn.Close (); // why am I using two list? _newSL = _loader; TableView.ReloadData (); }
public TestCell(SongToSave song, string reuseIdentifier) : base(UITableViewCellStyle.Default, reuseIdentifier) { this.Song = song; _nameLabel = new UILabel (); _imageView = new UIImageView (); _titleFont = UIFont.FromName ("Papyrus", 20.0f); this.ContentView.AddSubview (_imageView); this.ContentView.AddSubview (_nameLabel); this.ContentView.BackgroundColor = UIColor.Clear; }
public BookSpineCell(SongToSave song, string reuseID) : base(UITableViewCellStyle.Default, reuseID) { _song = song; _bookTitle = new UILabel (); _spineImage = new UIImageView (); _titleFont = UIFont.FromName ("Papyrus", 20.0f); this.ContentView.AddSubview (_spineImage); // this.BackgroundColor = UIColor.Clear; this.ContentView.AddSubview (_bookTitle); // this.ShouldIndentWhileEditing = true; }
public void Stopper() { Console.WriteLine ("Test point one"); dbWorker = new DBWorker (); dbWorker.StartDBWorker (); dbPath = dbWorker.GetPathToDb (); var conn = new SQLiteConnection (dbPath); // this playingstate shit is not working right? var playerState = _musicPlayer.PlaybackState; if (playerState == MPMusicPlaybackState.Playing || playerState == MPMusicPlaybackState.Paused){ // need to disable the play buttons and change the title/artist text to null Console.WriteLine ("Test point two"); playPauseBtn.Enabled = false; stopBtn.Enabled = false; positionSkipBtn.Enabled = false; timerBtn.Enabled = false; titleLbl.Text = "Song Not Selected"; artistLbl.Text = "Artist Not Available"; currentTimeLbl.Text = "0:00:00"; lengthLbl.Text = "0:00:00"; positionSld.SetValue(0f, false); Console.WriteLine("music was playing or paused"); // debugging refreshTimer.Invalidate(); PlayPauseSwitch = "play"; string stopTitle = _musicPlayer.NowPlayingItem.Title; string authorChecker = _musicPlayer.NowPlayingItem.Artist; string stopAuthor = " "; if (authorChecker == null || authorChecker.Length < 1) { stopAuthor = "No Artist"; } else{ stopAuthor = authorChecker; } Console.WriteLine("Author Saving: " + stopAuthor); // debugging double startingPoint = _musicPlayer.CurrentPlaybackTime; Console.WriteLine ("Stopping point: {0}", startingPoint); var query = conn.Table<SongToSave>().Where(q => q.BookTitle == stopTitle); SongToSave sts; if (query.Count() > 1){ Console.WriteLine("We have a problem, more than one book stored"); // debugging } else if (query.Count() > 0){ // replace the entry foreach (var item in query){ sts = new SongToSave() {BookTitle = stopTitle, BookAuthor = stopAuthor, PlayPosition = startingPoint, ID = item.ID}; conn.Update(sts); } } else{ sts = new SongToSave() {BookTitle = stopTitle, PlayPosition = startingPoint}; conn.Insert(sts); } _musicPlayer.Stop(); UIAlertView alert = new UIAlertView("Position Saved", stopTitle, null, "OK", null); alert.Show(); } else{ Console.WriteLine("Stopped Nothing"); //debugging return; } }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear (animated); // causes the table data to be reloaded each time the view will appear _songList = new List<SongToSave> (); var conn = new SQLiteConnection (dbPath); foreach (var item in conn.Table<SongToSave>()) { var tempSong = new SongToSave () { BookTitle = item.BookTitle, BookAuthor = item.BookAuthor, PlayPosition = item.PlayPosition }; _songList.Add (tempSong); } conn.Close (); this.TableView.ReloadData (); }