use of group.pals.android.lib.ui.filechooser.io.localfile.LocalFile in project FBReaderJ by geometer.
the class FileChooserUtil method runFileChooser.
public static void runFileChooser(Activity activity, int requestCode, String title, String initialDir, String regexp) {
final Intent intent = new Intent(activity, FileChooserActivity.class);
intent.putExtra(FileChooserActivity._TextResources, textResources(title));
intent.putExtra(FileChooserActivity._Rootpath, (Parcelable) new LocalFile(initialDir));
intent.putExtra(FileChooserActivity._ActionBar, true);
intent.putExtra(FileChooserActivity._SaveLastLocation, false);
intent.putExtra(FileChooserActivity._DisplayHiddenFiles, false);
intent.putExtra(FileChooserActivity._ShowNewFolderButton, false);
intent.putExtra(FileChooserActivity._FilenameRegExp, regexp);
intent.putExtra(FileChooserActivity._FilterMode, IFileProvider.FilterMode.FilesOnly);
activity.startActivityForResult(intent, requestCode);
}
use of group.pals.android.lib.ui.filechooser.io.localfile.LocalFile in project FBReaderJ by geometer.
the class LocalFileProvider method listAllFiles.
// listFiles()
@Override
public List<IFile> listAllFiles(IFile dir, final boolean[] hasMoreFiles) throws Exception {
if (!(dir instanceof File) || !dir.canRead())
return null;
if (hasMoreFiles != null && hasMoreFiles.length > 0)
hasMoreFiles[0] = false;
final List<IFile> _files = new ArrayList<IFile>();
try {
IFile root = dir.parentFile();
if (root.parentFile() == null && LocalFileProvider.this.accept(root))
_files.add(root);
File[] files = ((File) dir).listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
LocalFile file = new LocalFile(pathname);
if (!LocalFileProvider.this.accept(file))
return false;
if (_files.size() >= getMaxFileCount()) {
if (hasMoreFiles != null && hasMoreFiles.length > 0)
hasMoreFiles[0] = true;
return false;
}
_files.add(file);
return false;
}
});
if (files != null) {
Collections.sort(_files, new FileComparator(getSortType(), getSortOrder()));
return _files;
}
return null;
} catch (Throwable t) {
return null;
}
}
use of group.pals.android.lib.ui.filechooser.io.localfile.LocalFile in project FBReaderJ by geometer.
the class FileChooserUtil method runDirectoryChooser.
public static void runDirectoryChooser(Activity activity, int requestCode, String title, String initialValue, boolean chooseWritableDirsOnly) {
final Intent intent = new Intent(activity, FileChooserActivity.class);
intent.putExtra(FileChooserActivity._TextResources, textResources(title));
intent.putExtra(FileChooserActivity._Rootpath, (Parcelable) new LocalFile(initialValue));
intent.putExtra(FileChooserActivity._ActionBar, true);
intent.putExtra(FileChooserActivity._SaveLastLocation, false);
intent.putExtra(FileChooserActivity._DisplayHiddenFiles, true);
intent.putExtra(FileChooserActivity._FilterMode, chooseWritableDirsOnly ? IFileProvider.FilterMode.DirectoriesOnly : IFileProvider.FilterMode.AnyDirectories);
activity.startActivityForResult(intent, requestCode);
}
use of group.pals.android.lib.ui.filechooser.io.localfile.LocalFile in project FBReaderJ by geometer.
the class LocalFileProvider method listAllFiles.
// listAllFiles()
@Override
public List<IFile> listAllFiles(IFile dir, final IFileFilter filter) {
if (!(dir instanceof File))
return null;
final List<IFile> _res = new ArrayList<IFile>();
try {
IFile root = dir.parentFile();
if (root == null || filter == null || filter.accept(root))
_res.add(root);
File[] files = ((File) dir).listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
LocalFile file = new LocalFile(pathname);
if (filter == null || filter.accept(file))
_res.add(file);
return false;
}
});
if (files != null)
return _res;
return null;
} catch (Throwable t) {
return null;
}
}
use of group.pals.android.lib.ui.filechooser.io.localfile.LocalFile in project FBReaderJ by geometer.
the class LocalFileProvider method listAllFiles.
// listAllFiles()
@Override
public List<IFile> listAllFiles(IFile dir) throws Exception {
if (!(dir instanceof File) || !dir.canRead())
return null;
try {
final List<IFile> _files = new ArrayList<IFile>();
IFile root = dir.parentFile();
if (root.parentFile() == null)
_files.add(root);
File[] files = ((File) dir).listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
_files.add(new LocalFile(pathname));
return false;
}
});
if (files != null)
return _files;
return null;
} catch (Throwable t) {
return null;
}
}
Aggregations