public ExperienceSelectionViewController(IntPtr handle) : base(handle) { NSUrl exampleDefinitionsFileURL = NSBundle.MainBundle.GetUrlForResource("samples", "json", "ARchitectExamples"); if (exampleDefinitionsFileURL != null) { NSData exampleExperienceData = NSData.FromUrl(exampleDefinitionsFileURL); NSString exampleExperienceDefinitions = NSString.FromData(exampleExperienceData, NSStringEncoding.UTF8); experienceGroups = ArExperienceManager.ParseExampleDefintion(exampleExperienceDefinitions); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Activity_Main); /* * Loads the experience definiton file from the assets and parses the content to * ArExperienceGroups. */ var stream = Assets.Open("samples/samples.json"); StreamReader sr = new StreamReader(stream); experienceGroups = ArExperienceManager.ParseExampleDefintion(sr.ReadToEnd()); sr.Close(); /* * Removes all ArExperiences that are not supported on the current device because * of missing hardware requirements like sensors. */ int removedExperiences = FilterUnsupportedArExperiences(this, experienceGroups); if (removedExperiences > 0) { string message = GetString(Resource.String.error_loading_ar_experience_unsupported, removedExperiences); Toast.MakeText(this, message, ToastLength.Long).Show(); } /* * Fills the ExpandableListView with all remaining ArExperiences. */ var adapter = new Util.adapters.ArExpandableListAdapter(this, experienceGroups); listView = FindViewById(Resource.Id.listView) as ExpandableListView; MoveExpandableIndicatorToRight(); listView.ChildClick += ExperienceListChildClick; listView.SetAdapter(adapter); /* * Sets the title and the menu of the Toolbar. The menu contains two items * one for laoding a custom ArExperience from a URL and one for showing informations about * the Version of the Wikitude SDK. */ var toolbar = FindViewById(Resource.Id.toolbar) as Android.Support.V7.Widget.Toolbar; toolbar.InflateMenu(Resource.Menu.main_menu); toolbar.MenuItemClick += (sender, args) => { switch (args.Item.ItemId) { case Resource.Id.menu_main_load_url: var intent = new Intent(this, typeof(UrlLauncherStorageActivity)); StartActivity(intent); args.Handled = true; break; case Resource.Id.menu_main_info: var sdkBuildInformation = ArchitectView.SDKBuildInformation; new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle(Resource.String.build_information_title) .SetMessage( GetString(Resource.String.build_information_config) + sdkBuildInformation.BuildConfiguration + "\n" + GetString(Resource.String.build_information_date) + sdkBuildInformation.BuildDate + "\n" + GetString(Resource.String.build_information_number) + sdkBuildInformation.BuildNumber + "\n" + GetString(Resource.String.build_information_version) + ArchitectView.SDKVersion) .Show(); args.Handled = true; break; default: args.Handled = false; break; } }; toolbar.SetTitle(Resource.String.app_name); }