public async Task InitListView() { Realm RealmContext = null; try { if (User.AllLoggedIn.Count() > 1) { foreach (var _u in User.AllLoggedIn) { await _u.LogOutAsync(); } } if (User.Current == null) { if (await MyRealm.Login(API_USERNAME, API_PASSWORD) == null) { return; } } RealmContext = MyRealm.RealmContext; using (var transaction = RealmContext.BeginWrite()) { RealmContext.RemoveAll <TrackMessage>(); RealmContext.Add(new TrackMessage { Id = 0, Text = "Please wait, service starting" }); transaction.Commit(); } listView.ItemsSource = TrackMessage = RealmContext.All <TrackMessage>(); } catch (Exception e) { Console.WriteLine($"{Constants.TAG} Erreur {e.GetType().FullName} {e.Message}"); } }
private async void Clicked(object sender, EventArgs e) { if (sender == StartButton || sender == StopButton) { MessagingCenter.Send(new ToTrackerMessage(sender == StartButton), nameof(ToTrackerMessage)); } else if (sender == CreateButton) { if (await MyRealm.Login(API_USERNAME, API_PASSWORD, true) != null) { await InitListView(); } } }