summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.ControlGallery.Android/PreApplicationClassActivity.cs
blob: 13f21640608fbdbd6c61efa267a18daaa96990f6 (plain)
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
#if PRE_APPLICATION_CLASS

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Xamarin.Forms.Controls;
using Xamarin.Forms.Platform.Android;

namespace Xamarin.Forms.ControlGallery.Android
{
	[Activity (Label = "Control Gallery", 
			   Icon = "@drawable/icon",
			   MainLauncher = true, 
			   HardwareAccelerated = true, 
			   ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
	public class Activity1 : AndroidActivity
	{
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			
			Forms.Init (this, bundle);
			FormsMaps.Init (this, bundle);

			SetPage (FormsApp.GetFormsApp ());

			MessagingCenter.Subscribe<RootPagesGallery, Type> (this, Messages.ChangeRoot, (sender, pageType) => {
				var page = ((Page)Activator.CreateInstance (pageType));
				SetPage (page);
			});

			MessagingCenter.Subscribe<RootPagesGallery, Type> (this, Messages.ChangeRoot, (sender, pageType) => {
				var page = ((Page)Activator.CreateInstance (pageType));
				SetPage (page);
			});

			MessagingCenter.Subscribe<HomeButton> (this, Messages.GoHome, (sender) => {
				var screen = FormsApp.GetFormsApp ();
				SetPage (screen);
 			});
		}
	}
}

#endif