public static Android.Support.V4.App.FragmentActivity GetActivity([NotNull] this IView view) { if (view == null) { throw new ArgumentNullException(nameof(view)); } return(view.As( activity => activity, fragment => fragment.NotNull().Activity)); }
public static UINavigationController GetNavigationController([NotNull] this IView view) { if (view == null) { throw new ArgumentNullException(nameof(view)); } return(view.As( navigationController => navigationController, viewController => viewController.NotNull().NavigationController)); }
internal static ILifecycleViewModelStore?Get(IView <ILifecycleViewModel> view) { LifecycleViewModelStoreFragment?store = null; var fragmentManager = view.As( activity => activity.SupportFragmentManager, fragment => fragment.Activity.SupportFragmentManager); if (!fragmentManager.IsDestroyed) { store = (LifecycleViewModelStoreFragment)fragmentManager.FindFragmentByTag(LifecycleViewModelStoreTag); if (store == null) { store = LifecycleViewModelStoreFragment.NewInstance(); fragmentManager .BeginTransaction() .Add(store, LifecycleViewModelStoreTag) .Commit(); } } return(store); }