use of com.stardust.scriptdroid.model.script.ScriptFile in project Auto.js by hyb1996.
the class ScriptOperations method importFile.
public Observable<String> importFile(String prefix, final InputStream inputStream, final String ext) {
return showFileNameInputDialog(PFiles.getNameWithoutExtension(prefix), ext).observeOn(Schedulers.io()).map(input -> {
final String pathTo = getCurrentDirectoryPath() + input + "." + ext;
if (PFiles.copyStream(inputStream, pathTo)) {
showMessage(R.string.text_import_succeed);
} else {
showMessage(R.string.text_import_fail);
}
mStorageFileProvider.notifyFileCreated(mCurrentDirectory, new ScriptFile(pathTo));
return pathTo;
});
}
use of com.stardust.scriptdroid.model.script.ScriptFile 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.scriptdroid.model.script.ScriptFile in project Auto.js by hyb1996.
the class ScriptListView method loadScriptList.
private void loadScriptList() {
setRefreshing(true);
mStorageFileProvider.getDirectoryFiles(mCurrentDirectory).subscribeOn(Schedulers.io()).filter(f -> mFilter == null ? true : mFilter.apply(f)).collectInto(mScriptList.cloneConfig(), (list, file) -> {
if (file instanceof ScriptFile) {
list.add((ScriptFile) file);
} else {
list.add(new ScriptFile(file));
}
}).observeOn(Schedulers.computation()).doOnSuccess(ScriptList::sort).observeOn(AndroidSchedulers.mainThread()).subscribe(list -> {
mScriptList = list;
mScriptListAdapter.notifyDataSetChanged();
setRefreshing(false);
});
}
use of com.stardust.scriptdroid.model.script.ScriptFile in project Auto.js by hyb1996.
the class TimedTaskSettingActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int taskId = getIntent().getIntExtra(TaskReceiver.EXTRA_TASK_ID, -1);
if (taskId != -1) {
mTimedTask = TimedTaskManager.getInstance().getTimedTask(taskId);
if (mTimedTask != null) {
mScriptFile = new ScriptFile(mTimedTask.getScriptPath());
}
} else {
String path = getIntent().getStringExtra(ScriptIntents.EXTRA_KEY_PATH);
if (TextUtils.isEmpty(path)) {
finish();
}
mScriptFile = new ScriptFile(path);
}
}
use of com.stardust.scriptdroid.model.script.ScriptFile in project Auto.js by hyb1996.
the class ScriptOperations method newDirectory.
public void newDirectory() {
showNameInputDialog("", new InputCallback()).subscribe(path -> {
ScriptFile newDir = new ScriptFile(getCurrentDirectory(), path);
if (newDir.mkdirs()) {
showMessage(R.string.text_already_create);
mStorageFileProvider.notifyFileCreated(mCurrentDirectory, new ScriptFile(newDir));
} else {
showMessage(R.string.text_create_fail);
}
});
}
Aggregations