public void SyncDatabases() { while (true) { Thread.Sleep(5000); NoteDatabase.SyncDatabases(); } }
public async override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); //Refresh the note on the screen CurrNote = await NoteDatabase.GetNoteByIdFromLocal(CurrNote.Id); UpdateView(); _isrunning = true; }
/// <summary> /// Called when a row is touched /// </summary> public async override void RowSelected(UITableView tableView, NSIndexPath indexPath) { //UIAlertController okAlertController = UIAlertController.Create(tableItems[indexPath.Row].Title, tableItems[indexPath.Row].Content, UIAlertControllerStyle.Alert); //okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); var detailController = new NoteDetailViewController(await NoteDatabase.GetNoteByIdFromLocal(_tableItems[indexPath.Row].Id)); _owner.NavigationController.PushViewController(detailController, true); tableView.DeselectRow(indexPath, true); }
public async Task UpdateNote() { try { CurrNote.Content = _textview.Text; await NoteDatabase.UpdateNoteLocal(CurrNote); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public async void StayUpdated() { while (_isrunning) { Thread.Sleep(5000); CurrNote = await NoteDatabase.GetNoteByIdFromLocal(CurrNote.Id); InvokeOnMainThread(() => { //CurrNote = NoteDatabase.GetNoteById(CurrNote.Id); UpdateView(); }); } }
public async void SaveTimer() { while (_isRunning) { Thread.Sleep(5000); InvokeOnMainThread(() => { CurrNote.Content = _textview.Text; }); //Don't update on the UI thread, in case it takes longer await NoteDatabase.UpdateNoteLocal(CurrNote); } }
protected async Task CreateTableItems() { //var notes = new List<Note>(); try { var source = new TableSource(await NoteDatabase.GetNotesFromLocal(), this); InvokeOnMainThread(() => { _table.Source = source; _table.ReloadData(); }); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public async Task SaveNote() { await Task.Run(() => { InvokeOnMainThread(async() => { if (CurrNote == null && _textview.Text != null) { if (!_textview.Text.Equals("")) { string sTitle = _title.Text; string sContent = _textview.Text; CurrNote = await NoteDatabase.InsertNoteToLocal(sTitle, sContent, 1); } } else if (CurrNote != null) { CurrNote.Title = _title.Text; CurrNote.Content = _textview.Text; await NoteDatabase.UpdateNoteLocal(CurrNote); } }); }); }