protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);

            string sharedPreferenceName = "SoundFontProviderStorage";
            string key = "settings";
            var sp = this.GetSharedPreferences (sharedPreferenceName, default (FileCreationMode));

            var model = ApplicationModel.Instance;
            model.Initialize (sp.GetString (key, string.Empty), s => {
                var e = sp.Edit ();
                e.PutString (key, s);
                e.Commit ();
            });

            #if DEBUG
            if (!model.Settings.SearchPaths.Contains (predefined_temp_path))
                model.AddSearchPaths (predefined_temp_path);
            #endif
            foreach (var path in model.Settings.SearchPaths)
                model.LoadFromDirectory (path);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            var vp = FindViewById<ViewPager> (Resource.Id.mainViewPager);
            var vpa = new TheViewPagerAdapter (SupportFragmentManager);
            vpa.Add ("Installed SoundFonts", new InstalledSoundFontFragment ());
            vpa.Add ("SoundFont Folders", new SoundFontFolderListFragment ());
            vpa.Add ("Online Catalogs", new OnlineCatalogFragment ());
            vp.Adapter = vpa;

            FindViewById<TabLayout> (Resource.Id.mainTabLayout).TabMode = TabLayout.ModeScrollable;

            var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar> (Resource.Id.mainToolbar);
            toolbar.InflateMenu (Resource.Menu.toolbar);
            toolbar.MenuItemClick += (sender, e) => {
                if (e.Item.ItemId == Resource.Id.toolbar_addnewfolder) {
                    //var df = new FolderChooserDialogFragment ();
                    //df.Show (SupportFragmentManager, "FolderChooser");
                    Intent i = new Intent (this, typeof (FilePickerActivity));

                    i.PutExtra (FilePickerActivity.ExtraMode, FilePickerActivity.ModeDir);

                    // Configure initial directory by specifying a String.
                    // You could specify a String like "/storage/emulated/0/", but that can
                    // dangerous. Always use Android's API calls to get paths to the SD-card or
                    // internal memory.
                    i.PutExtra (FilePickerActivity.ExtraStartPath, Android.OS.Environment.ExternalStorageDirectory.Path);

                    StartActivityForResult (i, 1234);				}
            };

            var tabl = FindViewById<TabLayout> (Resource.Id.mainTabLayout);
            tabl.SetupWithViewPager (vp);
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            string sharedPreferenceName = "SoundFontProviderStorage";
            string key = "settings";
            var    sp  = this.GetSharedPreferences(sharedPreferenceName, default(FileCreationMode));

            var model = ApplicationModel.Instance;

            model.Initialize(sp.GetString(key, string.Empty), s => {
                var e = sp.Edit();
                e.PutString(key, s);
                e.Commit();
            });

#if DEBUG
            if (!model.Settings.SearchPaths.Contains(predefined_temp_path))
            {
                model.AddSearchPaths(predefined_temp_path);
            }
#endif
            foreach (var path in model.Settings.SearchPaths)
            {
                model.LoadFromDirectory(path);
            }

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var vp  = FindViewById <ViewPager> (Resource.Id.mainViewPager);
            var vpa = new TheViewPagerAdapter(SupportFragmentManager);
            vpa.Add("Installed SoundFonts", new InstalledSoundFontFragment());
            vpa.Add("SoundFont Folders", new SoundFontFolderListFragment());
            vpa.Add("Online Catalogs", new OnlineCatalogFragment());
            vp.Adapter = vpa;

            FindViewById <TabLayout> (Resource.Id.mainTabLayout).TabMode = TabLayout.ModeScrollable;

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar> (Resource.Id.mainToolbar);
            toolbar.InflateMenu(Resource.Menu.toolbar);
            toolbar.MenuItemClick += (sender, e) => {
                if (e.Item.ItemId == Resource.Id.toolbar_addnewfolder)
                {
                    //var df = new FolderChooserDialogFragment ();
                    //df.Show (SupportFragmentManager, "FolderChooser");
                    Intent i = new Intent(this, typeof(FilePickerActivity));

                    i.PutExtra(FilePickerActivity.ExtraMode, FilePickerActivity.ModeDir);

                    // Configure initial directory by specifying a String.
                    // You could specify a String like "/storage/emulated/0/", but that can
                    // dangerous. Always use Android's API calls to get paths to the SD-card or
                    // internal memory.
                    i.PutExtra(FilePickerActivity.ExtraStartPath, Android.OS.Environment.ExternalStorageDirectory.Path);

                    StartActivityForResult(i, 1234);
                }
            };

            var tabl = FindViewById <TabLayout> (Resource.Id.mainTabLayout);
            tabl.SetupWithViewPager(vp);
        }