Exemplo n.º 1
0
        public virtual void InitializeFromSplashScreen(IMvxAndroidSplashScreenActivity splashScreen)
        {
            lock (LockObject)
            {
                _currentSplashScreen = splashScreen;

                if (_initializationStarted)
                {
                    if (_initialized)
                    {
                        _currentSplashScreen.InitializationComplete();
                        return;
                    }

                    return;
                }

                _initializationStarted = true;
            }

            _setup.InitializePrimary();
            ThreadPool.QueueUserWorkItem(ignored =>
            {
                _setup.InitializeSecondary();
                lock (LockObject)
                {
                    _initialized = true;
                    if (_currentSplashScreen != null)
                    {
                        _currentSplashScreen.InitializationComplete();
                    }
                }
            });
        }
Exemplo n.º 2
0
        public virtual void EnsureInitialized()
        {
            lock (LockObject)
            {
                if (_initialized)
                {
                    return;
                }

                if (IsInitialisedTaskCompletionSource != null)
                {
                    Mvx.Trace("EnsureInitialized has already been called so now waiting for completion");
                    IsInitialisedTaskCompletionSource.Task.Wait();
                }
                else
                {
                    IsInitialisedTaskCompletionSource = new TaskCompletionSource <bool>();
                    _setup.Initialize();
                    _initialized = true;

                    if (_currentSplashScreen != null)
                    {
                        Mvx.Warning("Current splash screen not null during direct initialization - not sure this should ever happen!");
                        var dispatcher = Mvx.GetSingleton <IMvxMainThreadDispatcher>();
                        dispatcher.RequestMainThreadAction(() =>
                        {
                            _currentSplashScreen?.InitializationComplete();
                        });
                    }

                    IsInitialisedTaskCompletionSource.SetResult(true);
                }
            }
        }
Exemplo n.º 3
0
        public virtual void EnsureInitialized()
        {
            lock (LockObject)
            {
                if (_initialized)
                {
                    return;
                }

                if (_initializationStarted)
                {
                    Mvx.Warning("Multiple Initialize calls made for MvxAndroidSetupSingleton singleton");
                    throw new MvxException("Multiple initialize calls made");
                }

                _initializationStarted = true;
            }

            _setup.Initialize();

            lock (LockObject)
            {
                _initialized = true;
                if (_currentSplashScreen != null)
                {
                    Mvx.Warning("Current splash screen not null during direct initialization - not sure this should ever happen!");
                    _currentSplashScreen.InitializationComplete();
                }
            }
        }
Exemplo n.º 4
0
        public virtual void InitializeFromSplashScreen(IMvxAndroidSplashScreenActivity splashScreen)
        {
            lock (LockObject)
            {
                _currentSplashScreen = splashScreen;
                if (_initialized)
                {
                    _currentSplashScreen?.InitializationComplete();
                    return;
                }

                if (IsInitialisedTaskCompletionSource != null)
                {
                    return;
                }
                else
                {
                    IsInitialisedTaskCompletionSource = new TaskCompletionSource <bool>();
                    _setup.InitializePrimary();
                    ThreadPool.QueueUserWorkItem(ignored =>
                    {
                        _setup.InitializeSecondary();
                        lock (LockObject)
                        {
                            IsInitialisedTaskCompletionSource.SetResult(true);
                            _initialized   = true;
                            var dispatcher = Mvx.GetSingleton <IMvxMainThreadDispatcher>();
                            dispatcher.RequestMainThreadAction(() =>
                            {
                                _currentSplashScreen?.InitializationComplete();
                            });
                        }
                    });
                }
            }
        }