partial void ReloadButton_TouchUpInside(UIButton sender) { //open a progress alert KeyVault.Tokens.Reset(); ProgressAlert = UIAlertController.Create("Reload Application Data", "Reloading please wait...", UIAlertControllerStyle.Alert); PresentViewController(ProgressAlert, true, null); Task reloadTask = Task.Run(async() => { await ApplicationData.Current.LoadApplicationData(); BeginInvokeOnMainThread(() => { ProgressAlert.DismissViewController(true, null); if (ApplicationData.Current.Errors.Count == 0) { var alert = UIAlertController.Create("Success", $"Application Data Reloaded Successfully", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } else { var alert = UIAlertController.Create("Error", $"Could not reload data. {ApplicationData.Current.Errors.Count} errors encountered.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } }); }); }
public async Task Reload(Context context = null) { if (context == null) { context = Context; } ProgressAlert alert = new ProgressAlert("Refreshing scrobbles", "Please wait...", context); alert.Show(); if (SourceUser != null) { ReythScrobbles.Clear(); var res = await client.User.GetRecentScrobbles(SourceUser, null, 1, 100); if (res.Success) { ReythScrobbles.AddRange(res); } } if (client.Auth.UserSession != null) { var userRes = await client.User.GetRecentScrobbles(client.Auth.UserSession.Username, null, 1, 100); GinaScrobbles.Clear(); if (userRes.Success) { GinaScrobbles.AddRange(userRes); } } if (ReythAdapter == null) { ReythAdapter = new ScrobbleListAdapter(ReythScrobbles.ToArray(), (e, a) => { var vh = a.View.Tag as ScrobbleListAdapterViewHolder; vh.ChangeChecked(); }); } else { ReythAdapter.SetItems(ReythScrobbles); } if (GinaAdapter == null) { GinaAdapter = new ScrobbleListAdapter(GinaScrobbles.ToArray()); } else { GinaAdapter.SetItems(GinaScrobbles); } alert.Hide(); if (string.IsNullOrEmpty(SourceUser)) { var msg = new MessageAlert("Source User Not Set!", "Use the 'Set Source' option from the menu to pick the user whose scrobbles you want to sync.", context); msg.Show(); } }
private void ShowSuccess(DataServiceResponse <ConfirmationResponse> Response) { InvokeOnMainThread(() => { ProgressAlert.DismissViewController(true, null); var alert = UIAlertController.Create("Appointment Confirmed", $"Your appointment is confirmed. Your confirmation number is: {Response?.Data?.ConfirmationNumber}", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, OnConfirmComplete)); PresentViewController(alert, true, null); }); }
private void ShowError(DataServiceResponse <ConfirmationResponse> Response) { InvokeOnMainThread(() => { ProgressAlert.DismissViewController(true, null); var alert = UIAlertController.Create("Schedule Error", $"Unable to confirm appointment: {Response.ErrorMessage}", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); CancelButton.Enabled = true; ConfirmButton.Enabled = true; }); }
public async Task <bool> Sync(LastTrack[] scrobbles) { var progress = new ProgressAlert("Syncing scrobbles", "Please wait...", Context); progress.Show(); if (!client.Auth.Authenticated) { progress.Hide(); return(false); } var newScrobbles = scrobbles.Where(o => o.TimePlayed != null && !GinaScrobbles.Any(p => p.TimePlayed == o.TimePlayed)); var list = newScrobbles.Select(o => new Scrobble(o.ArtistName, o.AlbumName, o.Name, o.TimePlayed.Value) { ChosenByUser = true, Duration = o.Duration }).ToList(); var scrobbler = new MemoryScrobbler(client.Auth); var res = await scrobbler.ScrobbleAsync(list); progress.Hide(); await Reload(); Toast.MakeText(Context, $"Synced {list.Count} scrobbles!", ToastLength.Long).Show(); return(true); }