public App(LessonCollection lessonList) { InitializeComponent(); ListOfLessons = lessonList; videoSound = new Sound(); MainPage = new NavigationPage(new Views.MainPage()); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); //var assembly = Assembly.GetExecutingAssembly(); //Stream stream = assembly.GetManifestResourceStream("DanceApp.Droid.lessonsR.json"); //using (StreamReader r = new StreamReader(stream)) AssetManager assets = this.Assets; var backingFile = Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, "lessons.json"); if (!File.Exists(backingFile)) { using (StreamReader r = new StreamReader(assets.Open("lessons.json"))) { var json = r.ReadToEnd(); ListOfLessons = JsonConvert.DeserializeObject <LessonCollection>(json); } using (StreamWriter w = File.CreateText(backingFile)) { JsonConvert.SerializeObject(ListOfLessons); } } else { using (StreamReader r = new StreamReader(backingFile)) { var json = r.ReadToEnd(); ListOfLessons = JsonConvert.DeserializeObject <LessonCollection>(json); } } LoadApplication(new App(ListOfLessons)); }