use of com.stardust.scriptdroid.model.script.PathChecker in project Auto.js by hyb1996.
the class ShortcutActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final String path = getIntent().getStringExtra(ScriptIntents.EXTRA_KEY_PATH);
if (new PathChecker(this).checkAndToastError(path)) {
runScriptFile(path);
}
finish();
}
use of com.stardust.scriptdroid.model.script.PathChecker in project Auto.js by hyb1996.
the class ScriptIntents method handleIntent.
public static boolean handleIntent(Context context, Intent intent) {
String path = getPath(intent);
String script = intent.getStringExtra(ScriptIntents.EXTRA_KEY_PRE_EXECUTE_SCRIPT);
int loopTimes = intent.getIntExtra(EXTRA_KEY_LOOP_TIMES, 1);
long delay = intent.getLongExtra(EXTRA_KEY_DELAY, 0);
long interval = intent.getLongExtra(EXTRA_KEY_LOOP_INTERVAL, 0);
ScriptSource source = null;
ExecutionConfig config = new ExecutionConfig().loop(delay, loopTimes, interval);
if (path == null && script != null) {
source = new StringScriptSource(script);
} else if (path != null && new PathChecker(context).checkAndToastError(path)) {
JavaScriptFileSource fileScriptSource = new JavaScriptFileSource(path);
if (script != null) {
source = new SequenceScriptSource(fileScriptSource.getName(), new StringScriptSource(script), fileScriptSource);
} else {
source = fileScriptSource;
}
config.executePath(new File(path).getParent());
} else {
config.executePath(StorageFileProvider.DEFAULT_DIRECTORY_PATH);
}
if (source == null) {
return false;
}
AutoJs.getInstance().getScriptEngineService().execute(source, config);
return true;
}
Aggregations