/// <inheritdoc />
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetupActionBar();
            SetContentView(Resource.Layout.filepicker_mainactivity);

            var newDirName     = Intent.GetStringExtra(ExtraNewDirName);
            var initialDir     = Intent.GetStringExtra(ExtraInitialDirectory);
            var filePickerMode = (FilePickerMode)Intent.GetIntExtra(ExtraMode, 1);

            if (bundle == null)
            {
                fragment         = new FilePickerFragment(newDirName, initialDir, filePickerMode);
                fragment.Cancel += sender =>
                {
                    SetResult(Result.Canceled);
                    Finish();
                };

                fragment.FileSelected += (sender, path) =>
                {
                    var intent = new Intent();
                    intent.PutExtra(ResultSelectedDir, path);
                    SetResult(Result.Ok, intent);     // should be firstuser?
                    Finish();
                };
                FragmentManager.BeginTransaction().Add(Resource.Id.filepicker_main, fragment).Commit();
            }
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            // Get our button from the layout resource,
            // and attach an event to it
            var buttonDirectoryActivity = FindViewById<Button>(Resource.Id.btnDirectoryActivity);
            var buttonFileActivity = FindViewById<Button>(Resource.Id.btnFileActivity);
            var buttonDirectoryDialog = FindViewById<Button>(Resource.Id.btnDirectoryDialog);
            var buttonFileDialog = FindViewById<Button>(Resource.Id.btnFileDialog);

            buttonDirectoryActivity.Click += delegate
            {
                var intent = new Intent(this, typeof(FilePickerActivity));
                intent.PutExtra(FilePickerActivity.ExtraNewDirName, "NewFolder");
                intent.PutExtra(FilePickerActivity.ExtraInitialDirectory, SelectedDirectory);
                intent.PutExtra(FilePickerActivity.ExtraMode, (int)FilePickerMode.Directory);
                StartActivityForResult(intent, FilePickerActivity.ResultCodeDirSelected);
            };

            buttonFileActivity.Click += delegate
            {
                var intent = new Intent(this, typeof(FilePickerActivity));
                StartActivityForResult(intent, FilePickerActivity.ResultCodeDirSelected);
            };

            buttonDirectoryDialog.Click += delegate
            {
                filePickerFragment = new FilePickerFragment(null, null, FilePickerMode.Directory);
                filePickerFragment.FileSelected += (sender, path) =>
                    {
                        filePickerFragment.Dismiss();
                        UpdateSelectedText(path);
                    };
                filePickerFragment.Cancel += sender => filePickerFragment.Dismiss();
                filePickerFragment.Show(FragmentManager, "FilePicker");
            };

            buttonFileDialog.Click += delegate
            {
                filePickerFragment = new FilePickerFragment();
                filePickerFragment.FileSelected += (sender, path) =>
                {
                    filePickerFragment.Dismiss();
                    UpdateSelectedText(path);
                };
                filePickerFragment.Cancel += sender => filePickerFragment.Dismiss();
                filePickerFragment.Show(FragmentManager, "FilePicker");
            };
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetupActionBar();
            SetContentView(Resource.Layout.filepicker_mainactivity);

            var newDirName = Intent.GetStringExtra(ExtraNewDirName);
            var initialDir = Intent.GetStringExtra(ExtraInitialDirectory);
            var filePickerMode = (FilePickerMode)Intent.GetIntExtra(ExtraMode, 1);

            if (bundle == null)
            {
                fragment = new FilePickerFragment(newDirName, initialDir, filePickerMode);
                fragment.Cancel += sender =>
                    {
                        SetResult(Result.Canceled);
                        Finish();
                    };

                fragment.FileSelected += (sender, path) =>
                    {
                        var intent = new Intent();
                        intent.PutExtra(ResultSelectedDir, path);
                        SetResult(Result.Ok, intent); // should be firstuser?
                      //  MessagingCenter.Send<Page,string>(new Page(),"FilePicked",path);
                        Dict.DictonaryManager.Instance.parseFile(path);
                        Finish();
                    };
                FragmentManager.BeginTransaction().Add(Resource.Id.filepicker_main, fragment).Commit();
            }
        }