Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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);
        }