forked from MvvmCross/MvvmCross
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMvxSplashScreenAppCompatActivity.cs
More file actions
94 lines (77 loc) · 2.79 KB
/
MvxSplashScreenAppCompatActivity.cs
File metadata and controls
94 lines (77 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MS-PL license.
// See the LICENSE file in the project root for more information.
using Android.OS;
using Android.Runtime;
using Android.Views;
using MvvmCross.Core;
using MvvmCross.Platforms.Android.Core;
using MvvmCross.ViewModels;
namespace MvvmCross.Droid.Support.V7.AppCompat
{
[Register("mvvmcross.droid.support.v7.appcompat." + nameof(MvxSplashScreenAppCompatActivity))]
public abstract class MvxSplashScreenAppCompatActivity
: MvxAppCompatActivity, IMvxSetupMonitor
{
private const int NoContent = 0;
private readonly int _resourceId;
public new MvxNullViewModel ViewModel
{
get { return base.ViewModel as MvxNullViewModel; }
set { base.ViewModel = value; }
}
protected MvxSplashScreenAppCompatActivity(int resourceId = NoContent)
{
_resourceId = resourceId;
}
protected virtual void RequestWindowFeatures()
{
RequestWindowFeature(WindowFeatures.NoTitle);
}
protected override void OnCreate(Bundle bundle)
{
RequestWindowFeatures();
var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);
setup.InitializeAndMonitor(this);
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);
}
}
private bool _isResumed;
protected override void OnResume()
{
base.OnResume();
_isResumed = true;
var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);
setup.InitializeAndMonitor(this);
}
protected override void OnPause()
{
_isResumed = false;
var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);
setup.CancelMonitor(this);
base.OnPause();
}
public virtual void InitializationComplete()
{
if (!_isResumed)
return;
TriggerFirstNavigate();
}
protected virtual void TriggerFirstNavigate()
{
var startup = Mvx.Resolve<IMvxAppStart>();
if (!startup.IsStarted)
startup.Start();
}
// do nothing on this override, as initial navigation is managed by TriggerFirstNavigate
protected override void RunAppStart(Bundle bundle)
{
}
}
}