Esempio n. 1
0
        public override void OnListItemClick(ListView l, View v, int position, long id)
        {
            FileInfoEx fileSystemInfo = _adapter.GetItem(position);

            if (fileSystemInfo.RootDir != null)
            {
                _instanceData.DefaultInitialDirectory = fileSystemInfo.RootDir;
                RefreshFilesList(fileSystemInfo.RootDir);
            }
            else
            {
                if (fileSystemInfo.FileSysInfo.IsFile())
                {
                    // Do something with the file.  In this case we just pop some toast.
                    //Log.Verbose("FileListFragment", "The file {0} was clicked.", fileSystemInfo.FullName);
                    Intent intent = new Intent();
                    intent.PutExtra(FilePickerActivity.ExtraFileName, fileSystemInfo.FileSysInfo.FullName);

                    Activity.SetResult(Android.App.Result.Ok, intent);
                    Activity.Finish();
                }
                else
                {
                    // Dig into this directory, and display it's contents
                    _instanceData.DefaultInitialDirectory = fileSystemInfo.FileSysInfo.FullName;
                    RefreshFilesList(fileSystemInfo.FileSysInfo.FullName);
                }
            }

            base.OnListItemClick(l, v, position, id);
        }
Esempio n. 2
0
        public override void OnActivityCreated(Bundle savedInstanceState)
        {
            base.OnActivityCreated(savedInstanceState);

            ListView.LongClickable  = _dirSelect;
            ListView.ItemLongClick += (sender, args) =>
            {
                if (_dirSelect)
                {
                    string     fileName       = null;
                    FileInfoEx fileSystemInfo = _adapter.GetItem(args.Position);
                    if (fileSystemInfo != null)
                    {
                        switch (fileSystemInfo.FileType)
                        {
                        case FileInfoType.File:
                            if (fileSystemInfo.FileSysInfo != null && fileSystemInfo.FileSysInfo.IsDirectory())
                            {
                                fileName = fileSystemInfo.FileSysInfo.FullName;
                            }
                            break;

                        case FileInfoType.CurrentDir:
                            fileName = fileSystemInfo.RootDir;
                            break;
                        }

                        if (!string.IsNullOrEmpty(fileName))
                        {
                            Intent intent = new Intent();
                            intent.PutExtra(FilePickerActivity.ExtraFileName, fileName);

                            Activity.SetResult(Android.App.Result.Ok, intent);
                            Activity.Finish();
                            args.Handled = true;
                        }
                    }
                }
            };
        }