/// <summary> /// Called when the activity is destroyed. /// </summary> /// <param name="activity">The activity.</param> public void OnActivityDestroyed(Activity activity) { if (!ReferenceEquals(activity, _activity)) { return; } var eventArgs = new ActivityEventArgs(activity); ActivityDestroyed.SafeInvoke(this, eventArgs); }
/// <summary> /// Called when an activity is destroyed. /// </summary> /// <param name="activity">The activity.</param> public virtual void OnActivityDestroyed(Activity activity) { ActivityDestroyed?.Invoke(this, new ActivityDestroyedEventArgs(activity)); // Remove all views from the destroyed activity from the view cache. var viewCacheRemovals = MessagingServiceCore.ViewManager.ViewCache.Where(v => v.Key.Context == activity).ToArray(); foreach (var removal in viewCacheRemovals) { MessagingServiceCore.ViewManager.ViewCache.Remove(removal.Key); } if (MessagingServiceCore.ViewManager.SnackbarAnchorViews.ContainsKey(activity)) { MessagingServiceCore.ViewManager.SnackbarAnchorViews.Remove(activity); } if (MessagingServiceCore.ViewManager.SnackbarContainers.ContainsKey(activity)) { MessagingServiceCore.ViewManager.SnackbarContainers.Remove(activity); } }