Search in sources :

Example 1 with ThreadCompat

use of com.stardust.lang.ThreadCompat in project Auto.js by hyb1996.

the class ScriptEngineService method execute.

public ScriptExecution execute(ScriptExecutionTask task) {
    if (task.getListener() != null) {
        task.setExecutionListener(new ScriptExecutionObserver.Wrapper(mScriptExecutionObserver, task.getListener()));
    } else {
        task.setExecutionListener(mScriptExecutionObserver);
    }
    ScriptSource source = task.getSource();
    if (source instanceof JavaScriptSource) {
        int mode = ((JavaScriptSource) source).getExecutionMode();
        if ((mode & JavaScriptSource.EXECUTION_MODE_UI) != 0) {
            return ScriptExecuteActivity.execute(mContext, mScriptEngineManager, task);
        }
    }
    RunnableScriptExecution r;
    if (source instanceof JavaScriptSource) {
        r = new LoopedBasedJavaScriptExecution(mScriptEngineManager, task);
    } else {
        r = new RunnableScriptExecution(mScriptEngineManager, task);
    }
    if (task.getConfig().runInNewThread) {
        new ThreadCompat(r).start();
    } else {
        r.run();
    }
    return r;
}
Also used : ThreadCompat(com.stardust.lang.ThreadCompat) JavaScriptSource(com.stardust.autojs.script.JavaScriptSource) RunnableScriptExecution(com.stardust.autojs.execution.RunnableScriptExecution) LoopedBasedJavaScriptExecution(com.stardust.autojs.execution.LoopedBasedJavaScriptExecution) JavaScriptSource(com.stardust.autojs.script.JavaScriptSource) ScriptSource(com.stardust.autojs.script.ScriptSource) ScriptExecutionObserver(com.stardust.autojs.execution.ScriptExecutionObserver)

Aggregations

LoopedBasedJavaScriptExecution (com.stardust.autojs.execution.LoopedBasedJavaScriptExecution)1 RunnableScriptExecution (com.stardust.autojs.execution.RunnableScriptExecution)1 ScriptExecutionObserver (com.stardust.autojs.execution.ScriptExecutionObserver)1 JavaScriptSource (com.stardust.autojs.script.JavaScriptSource)1 ScriptSource (com.stardust.autojs.script.ScriptSource)1 ThreadCompat (com.stardust.lang.ThreadCompat)1