Exemplo n.º 1
0
        public static MvxAndroidSetup GetOrCreateSetup(Context applicationContext)
        {
            if (_instance != null)
            {
                return(_instance);
            }

            lock (LockObject)
            {
                if (_instance != null)
                {
                    return(_instance);
                }

                var setupType = FindSetupType();
                if (setupType == null)
                {
                    throw new MvxException("Could not find a Setup class for application");
                }

                try
                {
                    _instance = (MvxAndroidSetup)Activator.CreateInstance(setupType, applicationContext);
                }
                catch (Exception exception)
                {
                    throw exception.MvxWrap("Failed to create instance of {0}", setupType.FullName);
                }

                return(_instance);
            }
        }
        public static MvxAndroidSetup GetOrCreateSetup(Context applicationContext)
        {
            if (_instance != null)
            {
                return _instance;
            }

            lock (LockObject)
            {
                if (_instance != null)
                {
                    return _instance;
                }

                var setupType = FindSetupType();
                if (setupType == null)
                {
                    throw new MvxException("Could not find a Setup class for application");
                }

                try
                {
                    _instance = (MvxAndroidSetup) Activator.CreateInstance(setupType, applicationContext);
                }
                catch (Exception exception)
                {
                    throw exception.MvxWrap("Failed to create instance of {0}", setupType.FullName);
                }

                return _instance;
            }
        }
Exemplo n.º 3
0
        protected virtual void CreateSetup(Context applicationContext)
        {
            var setupType = FindSetupType();

            if (setupType == null)
            {
                throw new MvxException("Could not find a Setup class for application");
            }

            try
            {
                _setup = (MvxAndroidSetup)Activator.CreateInstance(setupType, applicationContext);
            }
            catch (Exception exception)
            {
                throw exception.MvxWrap("Failed to create instance of {0}", setupType.FullName);
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);

            _setup = MvxAndroidSetupSingleton.GetOrCreateSetup(ApplicationContext);

            // initialize app if necessary
            if (_setup.State == MvxSetup.MvxSetupState.Uninitialized)
            {
                _setup.InitializePrimary();
            }

            base.OnCreate(bundle);

            if (_resourceId != NoContent)
            {
                // Set our view from the "splash" layout resource
                // Be careful to use non-binding inflation
                var content = LayoutInflater.Inflate(_resourceId, null);
                SetContentView(content);
            }
        }