Beispiel #1
0
        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));
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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);
        }