use of com.stardust.pio.PFile in project Auto.js by hyb1996.
the class ScriptOperations method rename.
public Observable<Boolean> rename(final ScriptFile file) {
final ScriptFile oldFile = new ScriptFile(file.getPath());
String originalName = file.getSimplifiedName();
return showNameInputDialog(originalName, new InputCallback(file.isDirectory() ? null : PFiles.getExtension(file.getName()), originalName)).map(newName -> {
PFile newFile = file.renameAndReturnNewFile(newName);
if (newFile != null) {
mStorageFileProvider.notifyFileChanged(mCurrentDirectory, oldFile, newFile);
}
return newFile != null;
});
}
use of com.stardust.pio.PFile in project Auto.js by hyb1996.
the class SampleFileProvider method listFiles.
@Override
protected Observable<PFile> listFiles(PFile directory) {
return Observable.just(directory).flatMap(dir -> Observable.fromArray(mAssetManager.list(directory.getPath()))).map(path -> {
String absPath = new File(directory, path).getPath();
if (!absPath.endsWith(".js")) {
return new AssetDirectory(absPath);
}
PFile file = new PFile(mContext.getFilesDir(), absPath);
if (!file.exists()) {
copySample(mContext, absPath, file.getPath());
}
return file;
});
}
Aggregations