async Task Dismiss() { var tcs = new TaskCompletionSource <bool>(); var anim = new AlphaAnimation(_contentView.Alpha, 0.0f); anim.Duration = 250; anim.FillAfter = true; void handler(object sender, Animation.AnimationEndEventArgs e) { tcs.SetResult(true); }; anim.AnimationEnd += handler; _contentView.StartAnimation(anim); await tcs.Task; anim.AnimationEnd -= handler; var dialog = FragmentManager.FindFragmentByTag <ExtraPlatformDialog>(_guid.ToString()); dialog.Dismiss(); _contentView.RemoveFromParent(); _platformDialog.Dispose(); _platformDialog = null; await Task.Delay(250); // wait for a bit time until the dialog is completely released. }
public KeyboardListener(View rootView, ExtraPlatformDialog dialog) { _rootView = rootView; _dialog = dialog; _estimatedKeyboardDP = _defaultKeyboardHeightDP + (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop ? 48 : 0); _rect = new Rect(); }
public async Task <bool> ShowAsync() { var dialog = FragmentManager.FindFragmentByTag <ExtraPlatformDialog>(_guid.ToString()); if (dialog != null) { return(false); } _dlgView.SetUp(); OnceInitializeAction?.Invoke(); var tcs = new TaskCompletionSource <bool>(); async void cancel(object sender, EventArgs e) { _dlgView.RunDismissalAnimation(); await Dismiss(); tcs.SetResult(false); } async void complete(object sender, EventArgs e) { _dlgView.RunDismissalAnimation(); await Dismiss(); tcs.SetResult(true); } _dlgView.DialogNotifierInternal.Canceled += cancel; _dlgView.DialogNotifierInternal.Completed += complete; var payload = new ExtraDialogPayload(_dlgView, _contentView); var bundle = new Bundle(); bundle.PutSerializable("extraDialogPayload", payload); _platformDialog = new ExtraPlatformDialog(); _platformDialog.Arguments = bundle; _platformDialog.Show(FragmentManager, _guid.ToString()); try { return(await tcs.Task); } finally { _dlgView.DialogNotifierInternal.Canceled -= cancel; _dlgView.DialogNotifierInternal.Completed -= complete; _dlgView.TearDown(); payload.Dispose(); bundle.Dispose(); } }
protected override void Dispose(bool disposing) { if (disposing) { _rect?.Dispose(); _rect = null; _rootView = null; _dialog = null; } base.Dispose(disposing); }
public DialogImplementation() { ExtraDialog = new ExtraPlatformDialog(); }