public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey) { AddPreferencesFromResource(Resource.Xml.mic_preferences); //Preference var prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context); ISharedPreferencesEditor editor = prefs.Edit(); editor.PutBoolean("settings_changed", true); editor.PutString("edit_mic_id", micId); editor.Apply(); //clearPreferencesButton = FindPreference("preference_mic_button_sounds") as Android.Support.V7.Preferences.PreferenceScreen; //clearPreferencesButton.PreferenceClick += micSounds; //changeSensitivityButton = FindPreference("preference_mic_button_sensitivity") as Android.Support.V7.Preferences.PreferenceScreen; //changeSensitivityButton.PreferenceClick += setSensitivity; restoreNotificationsButton = FindPreference("preference_mic_button_restore") as Android.Support.V7.Preferences.PreferenceScreen; restoreNotificationsButton.PreferenceClick += restoreNotifications; deleteMicButton = FindPreference("preference_mic_button_delete") as Android.Support.V7.Preferences.PreferenceScreen; deleteMicButton.PreferenceClick += deleteMic; //preference_mic_button_sensitivity mRegistrationBroadcastReceiver = new Shared.BroadcastReceiver(); mRegistrationBroadcastReceiver.Receive += (sender, e) => { var reply_error = e.Intent.GetStringExtra("reply_error"); var reply_data = e.Intent.GetStringExtra("reply_data"); if (reply_data == Shared.QueuedDeviceRequestType.CHANGE_SENSITIVITY) { if (reply_error == Shared.ServerResponsecode.OK.ToString()) { if (loadingDialog != null) { loadingDialog.Hide(); } Acr.UserDialogs.UserDialogs.Instance.SuccessToast("Success!"); } else { if (loadingDialog != null) { loadingDialog.Hide(); } Acr.UserDialogs.UserDialogs.Instance.ShowError("Error Changing Sensitivity"); } } }; LocalBroadcastManager.GetInstance(base.Activity).RegisterReceiver(mRegistrationBroadcastReceiver, new IntentFilter("reply_error")); }
public static async Task <bool> CheckPermissions(Permission permission, IProgressDialog dlg) { var permissionStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(permission); bool request = false; if (permissionStatus == PermissionStatus.Denied) { if (Device.RuntimePlatform == Device.iOS) { dlg.Hide(); var title = $"{permission} Permission"; var question = $"To use this plugin the {permission} permission is required. Please go into Settings and turn on {permission} for the app."; var positive = "Settings"; var negative = "Maybe Later"; var task = Application.Current?.MainPage?.DisplayAlert(title, question, positive, negative); if (task == null) { return(false); } var result = await task; if (result) { CrossPermissions.Current.OpenAppSettings(); } return(false); } request = true; } if (request || permissionStatus != PermissionStatus.Granted) { var newStatus = await CrossPermissions.Current.RequestPermissionsAsync(permission); if (newStatus.ContainsKey(permission) && newStatus[permission] != PermissionStatus.Granted) { dlg.Hide(); var title = $"{permission} Permission"; var question = $"To use the plugin the {permission} permission is required."; var positive = "Settings"; var negative = "Maybe Later"; var result = await Acr.UserDialogs.UserDialogs.Instance.ConfirmAsync(question, title, positive, negative); if (result) { CrossPermissions.Current.OpenAppSettings(); } return(false); } } return(true); }
public async Task HideLoadingAsync() { if (_Progress == null) { return; } _Progress.Hide(); _Progress.Dispose(); _Progress = null; }
protected override async void OnAppearing() { try { _busy = UserDialogs.Instance.Loading(MessageHelper.Loading); var service = DependencyService.Get <IDueService>(); var result = await Task.Run(() => service.GetDuereceipts(_houseId)); var reciptViewModel = result.Receipts.Select(i => new ReceiptsViewModel { Id = i.Id, Date = i.Date, Description = i.Description, Advance = i.Advance ? "ok.png" : "wrong.png", Source = i.Source, Amount = i.Amount, }); AccountStatementView.ItemsSource = reciptViewModel; StackVisibility.IsVisible = true; } catch (Exception ex) { if (!CrossConnectivity.Current.IsConnected) { UserDialogs.Instance.ErrorToast(MessageHelper.NoInternet); } } finally { _busy.Hide(); } base.OnAppearing(); }
async Task ExecuteTapQueueMessageCommandAsync(CloudQueueMessage queueMessage) { if (queueMessage == null) { return; } MessagingService.Current.Subscribe <MessageArgsDeleteQueueMessage>(MessageKeys.DeleteQueueMessage, async(m, argsDeleteQueueMessage) => { Navigation.PopAsync(); IProgressDialog deletingDialog = UserDialogs.Loading("Deleting Queue Message"); deletingDialog.Show(); try { var message = QueueMessages.Where(qm => qm.Id == argsDeleteQueueMessage.QueueId).FirstOrDefault(); if (message == null) { return; } await Queue.BaseQueue.DeleteMessageAsync(message); App.Logger.Track(AppEvent.DeleteQueueMessage.ToString()); QueueMessages.Remove(message); QueueMessageCount--; SortQueueMessages(); } catch (Exception ex) { Logger.Report(ex, "Method", "HandleMessageArgsDeleteQueueMessage"); MessagingService.Current.SendMessage(MessageKeys.Error, ex); } finally { if (deletingDialog != null) { if (deletingDialog.IsShowing) { deletingDialog.Hide(); } deletingDialog.Dispose(); } } }); try { var queueMessageDetailsPage = new QueueMessageDetailsPage(queueMessage, queue); App.Logger.TrackPage(AppPage.QueueMessageDetails.ToString()); await NavigationService.PushAsync(Navigation, queueMessageDetailsPage); } catch (Exception ex) { Console.WriteLine("Ex: " + ex.Message); } }
protected async override void OnAppearing() { if (IsBusy) { return; } IsBusy = true; ViewModel.ErrorMessage = ""; base.OnAppearing(); IProgressDialog progress = null; try { progress = UserDialogs.Instance.Loading("Loading...", maskType: MaskType.Clear); progress.Show(); InitContributionType(); await BindContributionAreas(); BindingSelectors(); } catch { } finally { progress?.Hide(); IsBusy = false; } }
/// <summary> /// Shows the progress. /// </summary> /// <param name="visible">If set to <c>true</c> visible.</param> /// <param name="title">Title.</param> /// <param name="subtitle">Subtitle.</param> public void UpdateProgress(bool visible, string title = "", string subtitle = "") { if (_progressDialog == null && visible == false) { return; } if (_progressDialog == null) { _progressDialog = UserDialogs.Instance.Progress(); _progressDialog.IsDeterministic = false; } _progressDialog.Title = title ?? string.Empty; if (visible) { if (!_progressDialog.IsShowing) { _progressDialog.Show(); } } else { if (_progressDialog.IsShowing) { _progressDialog.Hide(); } _progressDialog = null; } }
protected async override void OnAppearing() { if (IsBusy) { return; } IsBusy = true; ViewModel.ErrorMessage = ""; base.OnAppearing(); IProgressDialog progress = null; try { progress = UserDialogs.Instance.Loading(TranslateServices.GetResourceString(CommonConstants.DialogLoading), maskType: MaskType.Clear); progress.Show(); InitContributionType(); await BindContributionAreas(); BindingSelectors(); } catch (Exception ex) { await UserDialogs.Instance.AlertAsync(string.Format(CommonConstants.DialogDescriptionForCheckNetworkFormat, ex.Message), TranslateServices.GetResourceString(CommonConstants.DialogOK)); } finally { progress?.Hide(); IsBusy = false; } }
protected void HideBusy() { if (_busy != null) { _busy.Hide(); } }
async Task ExecuteTapFileShareCommandAsync(ASECloudFileShare fileShare) { if (fileShare == null) { return; } MessagingService.Current.Subscribe <MessageArgsDeleteFileShare>(MessageKeys.DeleteFileShare, async(m, argsDeleteFileShare) => { Navigation.PopAsync(); IProgressDialog deletingDialog = UserDialogs.Loading("Deleting FileShare"); deletingDialog.Show(); try { var aseFileShare = FileShares.Where(fs => fs.FileShareName == argsDeleteFileShare.FileShareName && fs.StorageAccountName == argsDeleteFileShare.StorageAccountName).FirstOrDefault(); if (aseFileShare == null) { return; } await aseFileShare.BaseFileShare.DeleteAsync(); App.Logger.Track(AppEvent.DeleteFileShare.ToString()); FileShares.Remove(aseFileShare); SortFileShares(); var realm = App.GetRealm(); await realm.WriteAsync(temprealm => { temprealm.Remove(temprealm.All <RealmCloudFileShare>() .Where(fs => fs.FileShareName == argsDeleteFileShare.FileShareName && fs.StorageAccountName == argsDeleteFileShare.StorageAccountName).First()); }); } catch (Exception ex) { Logger.Report(ex, "Method", "HandleMessageArgsDeleteFileShare"); MessagingService.Current.SendMessage(MessageKeys.Error, ex); } finally { if (deletingDialog != null) { if (deletingDialog.IsShowing) { deletingDialog.Hide(); } deletingDialog.Dispose(); } } }); var filesPage = new FilesPage(fileShare); App.Logger.TrackPage(AppPage.Files.ToString()); await NavigationService.PushAsync(Navigation, filesPage); }
public async Task HideLoadingAsync() { try { if (_Progress == null) { return; } _Progress.Hide(); _Progress.Dispose(); _Progress = null; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(string.Format("*** DialogService.HideLoadingAsync - Exception: {0}", ex)); } }
async Task ExecuteTapContainerCommandAsync(ASECloudBlobContainer container) { if (container == null) { return; } MessagingService.Current.Subscribe <MessageArgsDeleteContainer>(MessageKeys.DeleteContainer, async(m, argsDeleteContainer) => { Console.WriteLine("Delete containerX: " + argsDeleteContainer.ContainerName); Navigation.PopAsync(); IProgressDialog deletingDialog = UserDialogs.Loading("Deleting Container"); deletingDialog.Show(); try { var aseContainer = Containers.Where(c => c.ContainerName == argsDeleteContainer.ContainerName && c.StorageAccountName == argsDeleteContainer.StorageAccountName).FirstOrDefault(); if (aseContainer == null) { return; } await aseContainer.BaseContainer.DeleteAsync(); App.Logger.Track(AppEvent.DeleteContainer.ToString()); Containers.Remove(aseContainer); SortContainers(); var realm = App.GetRealm(); await realm.WriteAsync(temprealm => { temprealm.Remove(temprealm.All <RealmCloudBlobContainer>() .Where(c => c.ContainerName == argsDeleteContainer.ContainerName && c.StorageAccountName == argsDeleteContainer.StorageAccountName).First()); }); } catch (Exception ex) { Logger.Report(ex, "Method", "HandleMessageArgsDeleteContainer"); MessagingService.Current.SendMessage(MessageKeys.Error, ex); } finally { if (deletingDialog != null) { if (deletingDialog.IsShowing) { deletingDialog.Hide(); } deletingDialog.Dispose(); } } }); var blobsPage = new BlobsPage(container); App.Logger.TrackPage(AppPage.Blobs.ToString()); await NavigationService.PushAsync(Navigation, blobsPage); }
private void Navigated(object sender, string e) { if (_progressDialog == null) { return; } _adalPage.HybridWebView.Navigated -= Navigated; _progressDialog.Hide(); _progressDialog = null; }
async Task ExecuteTapContainerCommandAsync(ASECloudTable table) { if (table == null) { return; } MessagingService.Current.Subscribe <MessageArgsDeleteTable>(MessageKeys.DeleteTable, async(m, argsDeleteTable) => { Navigation.PopAsync(); IProgressDialog deletingDialog = UserDialogs.Loading("Deleting Table"); deletingDialog.Show(); try { var aseTable = Tables.Where(t => t.TableName == argsDeleteTable.TableName && t.StorageAccountName == argsDeleteTable.StorageAccountName).FirstOrDefault(); if (aseTable == null) { return; } await aseTable.BaseTable.DeleteIfExistsAsync(); App.Logger.Track(AppEvent.DeleteTable.ToString()); Tables.Remove(aseTable); SortTables(); var realm = App.GetRealm(); await realm.WriteAsync(temprealm => { temprealm.Remove(temprealm.All <RealmCloudTable>() .Where(t => t.TableName == argsDeleteTable.TableName && t.StorageAccountName == argsDeleteTable.StorageAccountName).First()); }); } catch (Exception ex) { Logger.Report(ex, "Method", "HandleMessageArgsDeleteTable"); MessagingService.Current.SendMessage(MessageKeys.Error, ex); } finally { if (deletingDialog != null) { if (deletingDialog.IsShowing) { deletingDialog.Hide(); } deletingDialog.Dispose(); } } }); var tableRowsPage = new TableRowsPage(table); App.Logger.TrackPage(AppPage.TableRows.ToString()); await testPage.Navigation.PushAsync(tableRowsPage); }
protected override void OnAppearing() { if (CrossConnectivity.Current.IsConnected) { busy = UserDialogs.Instance.Loading(MessageHelper.Loading); webViewStack.IsVisible = true; noInternetStack.IsVisible = false; var service = DependencyService.Get <IDueService>(); var result = service.PaymentURL(paymentModel); webView.Source = result.Result; } else { busy.Hide(); BackgroundColor = Color.FromHex("#f2f2f2"); webViewStack.IsVisible = false; noInternetStack.IsVisible = true; } base.OnAppearing(); }
public void Hide() { try { progress.Hide(); } catch (Exception ex) { throw ex; } }
/// <summary> /// milliseconds 秒経っても task が完了しない場合、Loading ダイアログを完了まで表示 /// </summary> public static Task <T> LoadingDelayedAsync <T>(this IUserDialogs instance, Task <T> task, CancellationTokenSource source, string title = "", string cancelText = null, Action onCancel = null, int milliseconds = 500) { var canCancel = source != null; if (!canCancel) { source = new CancellationTokenSource(); // dummy } IProgressDialog dialog = null; return(Task.Run(async() => { // delay var t = 0.0; while (t < milliseconds) { await Task.Delay(TimeSpan.FromMilliseconds(100)); if (task.IsCompleted || task.IsFaulted || (source?.Token.IsCancellationRequested ?? false)) { return await task; } t += 100; } // show dialog = canCancel ? instance.Loading(title, () => { source?.Cancel(true); onCancel?.Invoke(); }, cancelText) : instance.Loading(title); // wait return await task; }, source.Token).ContinueWith(t => { dialog?.Hide(); dialog?.Dispose(); return t.Result; }, source.Token).ContinueWith(t => { if (t.IsCanceled) { return default(T); } if (t.IsFaulted) { // show error UserDialogs.Instance.Alert(t.Exception); return default(T); } return t.Result; }, source.Token)); }
public GongLueContentPage(string url, string title) { InitializeComponent(); Title = title; if (CrossConnectivity.Current.IsConnected) { loading = UserDialogs.Instance.Loading("获取并解析内容"); Task.Run(() => this.LoadContent(url)).Wait(); loading.Hide(); } }
protected void HideDialog(IProgressDialog dialog) { try { dialog.Hide(); } catch (Exception) { //todo: needs to be refactored to catch correct exception. //not handled on purpose, can crash during app rotation } }
private async void Send(object sender, EventArgs e) { IProgressDialog waiter = null; try { UserModel[] additionalVolunteers = viewModel.AdditionalVolunteers.Select(m => m.Model).ToArray(); double hours = viewModel.Hours; DateTime now = DateTime.UtcNow; UserModel user = UserModel.CurrentUser; IDataStore <Event> dataStore = DependencyService.Get <IDataStore <Event> >() ?? new MockDataStore(); EventCheckInModel checkIn = new EventCheckInModel(); checkIn.EventId = program.Id; checkIn.CheckinDate = now; checkIn.HourCount = hours; checkIn.ParentUserEmail = null; checkIn.UserEmail = user.Email; waiter = UserDialogs.Instance.Loading("Sending...", maskType: MaskType.Clear); waiter.Show(); bool result = await dataStore.CheckInUserOnEventAsync(checkIn); if (!result) { throw new Exception(); } waiter?.Hide(); await Navigation.PopAsync(); } catch { waiter?.Hide(); await DisplayAlert("Error", "Cannot save hours", "OK"); } }
protected async override void OnAppearing() { base.OnAppearing(); this.viewModel = this.BindingContext as PetServicesViewModel; IProgressDialog l = App.GetLoadingDialog(AppSettings.Constants.LoaderText); l.Show(); try { await viewModel.LoadContents(); l.Hide(); } catch (Exception) { l.Hide(); await DisplayAlert(AppSettings.Constants.DisplayGeneralErrorDlgTitle, AppSettings.Constants.DisplayGeneralErrorDlgMessage, "OK"); } company = CompanyInformation.GetDefault(); this.PetServicesList.ItemsSource = viewModel.PetServices; }
async Task ExecuteTapFileCommandAsync(IListFileItem fileItem) { if (fileItem == null) { return; } MessagingService.Current.Subscribe <MessageArgsDeleteFile>(MessageKeys.DeleteFile, async(m, argsDeleteFile) => { Navigation.PopAsync(); IProgressDialog deletingDialog = UserDialogs.Loading("Deleting File"); deletingDialog.Show(); try { var file = Files.Where(f => f.Share.Name == argsDeleteFile.FileName).FirstOrDefault(); if (file == null) { return; } await FileShare.BaseFileShare.GetRootDirectoryReference().GetFileReference(file.Share.Name).DeleteAsync(); App.Logger.Track(AppEvent.DeleteFile.ToString()); Files.Remove(file); FileAndDirectoryCount--; SortFiles(); } catch (Exception ex) { Logger.Report(ex, "Method", "HandleMessageArgsDeleteFile"); MessagingService.Current.SendMessage(MessageKeys.Error, ex); } finally { if (deletingDialog != null) { if (deletingDialog.IsShowing) { deletingDialog.Hide(); } deletingDialog.Dispose(); } } }); }
public GongLueListPage(string url, string title) { InitializeComponent(); BindingContext = this; Title = title; this.url = url; if (CrossConnectivity.Current.IsConnected) { loading = UserDialogs.Instance.Loading("加载数据列表"); //using (this.Dialogs.Loading("Loading (No Cancel)")) // await Task.Delay(TimeSpan.FromSeconds(3)); Task.Run(() => this.LoadData(url)).Wait(); loading.Hide(); //var task = Task.Factory.StartNew(() => this.LoadData(url)); //task.ContinueWith((t) => { loading.Hide(); }); //task.Start(); } }
private async Task SetLocation(Location location, bool isPreparing = false) { try { if (!isPreparing) { _progressDialogs.Show(); } Location = location; NearbyMarker = await _locationsRepository.GetNearbyEntries(location, _appSettings.NearbyMarkerCount, false); } finally { if (!isPreparing && _progressDialogs.IsShowing) { _progressDialogs.Hide(); } } }
protected override async void OnAppearing() { base.OnAppearing(); if (IsBusy) { return; } if (Settings.GetSetting(CommonConstants.TokenKey) != string.Empty) { IProgressDialog progress = null; try { IsBusy = true; progress = UserDialogs.Instance.Loading(TranslateServices.GetResourceString(CommonConstants.RefreshTokenKey)); await LiveIdLogOnViewModel.GetNewAccessToken(); } catch (Exception ex) { Debug.WriteLine(string.Format(TranslateServices.GetResourceString(CommonConstants.RefreshTokenExceptionTip), ex.Message)); } finally { progress?.Hide(); IsBusy = false; } } if (LogOnViewModel.Instance.IsLoggedIn) { App.GoHome(); } else { await logo.FadeTo(1, 500, Easing.CubicOut); await title.FadeTo(1, 1000, Easing.CubicOut); } }
protected override async void OnAppearing() { base.OnAppearing(); if (IsBusy) { return; } if (Settings.GetSetting(CommonConstants.TokenKey) != string.Empty) { IProgressDialog progress = null; try { IsBusy = true; progress = UserDialogs.Instance.Loading("Refreshing tokens..."); await LiveIdLogOnViewModel.GetNewAccessToken(); } catch (Exception ex) { Debug.WriteLine($"Unable to refresh token: {ex}"); } finally { progress?.Hide(); IsBusy = false; } } if (LogOnViewModel.Instance.IsLoggedIn) { App.GoHome(); } else { await logo.FadeTo(1, 500, Easing.CubicOut); await title.FadeTo(1, 1000, Easing.CubicOut); } }
protected override async void OnAppearing() { try { _busy = UserDialogs.Instance.Loading(MessageHelper.Loading); var bindingResult = await Task.Run(() => userDetailsService.GetUserDetails(HouseID)); BindingContext = bindingResult; } catch (Exception ex) { if (!CrossConnectivity.Current.IsConnected) { UserDialogs.Instance.ErrorToast(MessageHelper.NoInternet); } } finally { _busy.Hide(); } base.OnAppearing(); }
private async void Navigating(object sender, string returnUrl) { if (!returnUrl.StartsWith(_settingsProvider.RedirectUrl)) { return; } _adalPage.HybridWebView.IsVisible = false; var uri = new Uri(returnUrl); var code = uri.Query.Remove(0, 6); _progressDialog = _userDialogService.Progress(_progressConfig); var authToken = await RequestToken(code); await _rootPageProvider.Page.Navigation.PopModalAsync(); _progressDialog.Hide(); _tcs.SetResult(authToken); }
protected override async void OnAppearing() { try { _busy = UserDialogs.Instance.Loading(MessageHelper.Loading); owner.Text = houseDetails.OwnerName; tenent.Text = houseDetails.TenantName; var service = DependencyService.Get <IDueService>(); var result = await Task.Run(() => service.GetSettleDues(houseDetails.HouseId, _payOnlineModel)); this.setlDuesMdel = result; setleDuesViewModel = setlDuesMdel.Charges.Select(i => new SettleDuesViewModel { Id = i.Id, Date = i.Date, Description = i.Description, DueDate = i.DueDate, Balance = i.Balance, SettingAmount = i.Balance }).ToList(); SettleDuesView.ItemsSource = setleDuesViewModel; SettleDuesView.HeightRequest = setleDuesViewModel.Count * 30; toalAmount = setleDuesViewModel.Sum(i => (Convert.ToDecimal(i.SettingAmount))); grandTotal.Text = Convert.ToString(toalAmount); } catch (Exception) { if (!CrossConnectivity.Current.IsConnected) { UserDialogs.Instance.ErrorToast(MessageHelper.NoInternet); } } finally { _busy.Hide(); } }
/// <summary> /// Hide the loading screen /// </summary> public static void HideLoading() { _loadingDialog?.Hide(); }
public void DisableSpin(IProgressDialog progressDialog) { progressDialog?.Hide(); }