/// <summary> /// Shows the notification. /// </summary> /// <param name="notification">The notification.</param> public void ShowNotification(Rest.Notification notification) { Notification = notification; // // If no notification, then clear the notification view immediately. // if (notification == null) { ContainerView.ClearAnimation(); ContainerView.Visibility = ViewStates.Invisible; ContainerView.TranslationY = Utility.DipToPixel(-120); DismissButton.Focusable = false; DismissButton.ClearFocus(); return; } MessageView.Text = notification.Message; if (notification.Image != null) { Task.Run(async() => { Bitmap image; try { image = await Utility.LoadImageFromUrlAsync(Crex.Application.Current.GetAbsoluteUrl(notification.Image.BestMatch)); } catch { image = null; } Post(() => { ImageView.SetImageBitmap(image); ShowCurrentNotification(); }); }); } else { ImageView.SetImageBitmap(null); ShowCurrentNotification(); } }
/// <summary> /// Hides the current notification. /// </summary> private void HideCurrentNotification() { var animation = ObjectAnimator.OfFloat(ContainerView, "translationY", Utility.DipToPixel(-120)); animation.SetDuration(Crex.Application.Current.Config.AnimationTime.Value); animation.AnimationEnd += (sender, args) => { ContainerView.Visibility = ViewStates.Invisible; NotificationWasDismissed?.Invoke(this, new EventArgs()); }; ContainerView.ClearAnimation(); DismissButton.ClearFocus(); DismissButton.Focusable = false; animation.Start(); }