Permalink
Browse files

Tweaks to setup

  • Loading branch information...
1 parent 249873a commit fdb36666ffd89dd750005c15637163e737b4ff35 @slodge slodge committed May 16, 2012
@@ -28,6 +28,7 @@ public static class MvxAndroidActivityExtensionMethods
public static void OnViewCreate<TViewModel>(this IMvxAndroidView<TViewModel> androidView)
where TViewModel : class, IMvxViewModel
{
+ androidView.EnsureSetupInitialized();
androidView.OnLifetimeEvent((listener, activity) => listener.OnCreate(activity));
var view = androidView as IMvxView<TViewModel>;
view.OnViewCreate(() => { return androidView.LoadViewModel(); });
@@ -93,7 +94,6 @@ private static TViewModel LoadViewModel<TViewModel>(this IMvxAndroidView<TViewMo
if (typeof(TViewModel) == typeof(MvxNullViewModel))
return new MvxNullViewModel() as TViewModel;
- androidView.EnsureSetupInitialized();
var translatorService = androidView.GetService<IMvxAndroidViewModelLoader>();
var viewModel = translatorService.Load(activity.Intent);
@@ -102,6 +102,12 @@ private static TViewModel LoadViewModel<TViewModel>(this IMvxAndroidView<TViewMo
private static void EnsureSetupInitialized(this IMvxAndroidView androidView)
{
+ if (androidView is IMvxAndroidSplashScreenActivity)
+ {
+ // splash screen views manage their own setup initialization
+ return;
+ }
+
var activity = androidView.ToActivity();
var setup = MvxAndroidSetupSingleton.GetOrCreateSetup(activity.ApplicationContext);
setup.EnsureInitialized(androidView.GetType());
@@ -0,0 +1,17 @@
+#region Copyright
+// <copyright file="IMvxAndroidSplashScreenActivity.cs" company="Cirrious">
+// (c) Copyright Cirrious. http://www.cirrious.com
+// This source is subject to the Microsoft Public License (Ms-PL)
+// Please see license.txt on http://opensource.org/licenses/ms-pl.html
+// All other rights reserved.
+// </copyright>
+//
+// Project Lead - Stuart Lodge, Cirrious. http://www.cirrious.com
+#endregion
+
+namespace Cirrious.MvvmCross.Android.Interfaces
+{
+ public interface IMvxAndroidSplashScreenActivity
+ {
+ }
+}
@@ -12,6 +12,7 @@
using System.Threading;
using Android.OS;
using Android.Views;
+using Cirrious.MvvmCross.Android.Interfaces;
using Cirrious.MvvmCross.Android.Platform;
using Cirrious.MvvmCross.ExtensionMethods;
using Cirrious.MvvmCross.Interfaces.ServiceProvider;
@@ -23,12 +24,12 @@ namespace Cirrious.MvvmCross.Android.Views
{
public abstract class MvxBaseSplashScreenActivity
: MvxActivityView<MvxNullViewModel>
+ , IMvxAndroidSplashScreenActivity
, IMvxServiceConsumer<IMvxStartNavigation>
{
private const int NoContent = 0;
private static bool _primaryInitialized = false;
- private static bool _secondaryInitialized = false;
private static MvxBaseAndroidSetup _setup;
private readonly int _resourceId;
@@ -42,12 +43,13 @@ protected override void OnCreate(Bundle bundle)
{
RequestWindowFeature(WindowFeatures.NoTitle);
+ _setup = MvxAndroidSetupSingleton.GetOrCreateSetup(ApplicationContext);
+
if (!_primaryInitialized)
{
_primaryInitialized = true;
// initialize app if necessary
- _setup = MvxAndroidSetupSingleton.GetOrCreateSetup(ApplicationContext);
if (_setup.State == MvxBaseSetup.MvxSetupState.Uninitialized)
{
_setup.InitializePrimary();
@@ -51,6 +51,7 @@
<Compile Include="Android\Interfaces\IMvxAndroidViewModelRequestTranslator.cs" />
<Compile Include="Android\Interfaces\IMvxAndroidActivityLifeTimeListener.cs" />
<Compile Include="Android\Interfaces\IMvxAndroidGlobals.cs" />
+ <Compile Include="Android\Interfaces\IMvxAndroidSplashScreenActivity.cs" />
<Compile Include="Android\Interfaces\MvxIntentRequestCode.cs" />
<Compile Include="Android\Interfaces\MvxIntentResultEventArgs.cs" />
<Compile Include="Android\Interfaces\MvxTranslatedIntent.cs" />

0 comments on commit fdb3666

Please sign in to comment.