Skip to content

Instantly share code, notes, and snippets.

@julianshen
Created May 1, 2011 15:11
Show Gist options
  • Save julianshen/950560 to your computer and use it in GitHub Desktop.
Save julianshen/950560 to your computer and use it in GitHub Desktop.
private void initScriptEnv() {
jsContext = org.mozilla.javascript.Context.enter();
jsContext.setOptimizationLevel(-1);
jsScope = jsContext.initStandardObjects();
Object RObj = org.mozilla.javascript.Context.javaToJS(new Rwrapper(), jsScope);
ScriptableObject.putProperty(jsScope, "R", RObj);
ScriptableObject.putProperty(jsScope, "log", new Log());
ScriptableObject.putProperty(jsScope, "findview", new FindViewById(this));
InputStream in;
try {
in = this.getResources().getAssets().open("init.js");
jsContext.evaluateReader(jsScope, new InputStreamReader(in), "init.js", 0, null);
} catch (IOException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment