Skip to content

Commit

Permalink
Moved Forms init for Android and UWP as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mellson committed Aug 17, 2017
1 parent 41206e1 commit f49e455
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public MvxFormsApplication FormsApplication
{
get
{
if (!Xamarin.Forms.Forms.IsInitialized)
Xamarin.Forms.Forms.Init(Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity, null);
if (_formsApplication == null)
_formsApplication = CreateFormsApplication();
return _formsApplication;
Expand All @@ -52,7 +54,6 @@ public MvxFormsApplication FormsApplication

protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
Xamarin.Forms.Forms.Init(Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity, null);
return new MvxFormsDroidPagePresenter(FormsApplication);
}

Expand Down
13 changes: 9 additions & 4 deletions MvvmCross-Forms/MvvmCross.Forms.Uwp/MvxFormsWindowsSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,20 @@ protected override void InitializeApp(IMvxPluginManager pluginManager, IMvxAppli
}

private MvxFormsApplication _formsApplication;
public MvxFormsApplication FormsApplication =>
_formsApplication = _formsApplication ?? CreateFormsApplication();
public MvxFormsApplication FormsApplication
{
get
{
if (!Xamarin.Forms.Forms.IsInitialized)
Xamarin.Forms.Forms.Init(_launchActivatedEventArgs);
_formsApplication = _formsApplication ?? CreateFormsApplication();
}
}

protected virtual MvxFormsApplication CreateFormsApplication() => new MvxFormsApplication();

protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
{
Xamarin.Forms.Forms.Init(_launchActivatedEventArgs);

var presenter = new MvxFormsUwpPagePresenter(rootFrame, FormsApplication);
Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);

Expand Down

0 comments on commit f49e455

Please sign in to comment.