/// <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> /// Shows the notification. /// </summary> /// <param name="notification">The notification to be shown.</param> public void ShowNotification(Rest.Notification notification) { View.Frame = new CGRect(0, -View.Frame.Size.Height, View.Frame.Size.Width, View.Frame.Size.Height); Notification = notification; if (notification == null) { return; } MessageLabel.Text = notification.Message; if (notification.Image != null) { Task.Run(async() => { UIImage image; try { image = await Utility.LoadImageFromUrlAsync(Crex.Application.Current.GetAbsoluteUrl(notification.Image.BestMatch)); } catch { image = null; } InvokeOnMainThread(() => { ImageView.Image = image; ShowCurrentNotification(); }); }); } else { ImageView.Image = null; ShowCurrentNotification(); } }