assets/src/org/ruboto/ScriptLoader.java in ruboto-1.0.0 vs assets/src/org/ruboto/ScriptLoader.java in ruboto-1.0.1

- old
+ new

@@ -104,51 +104,24 @@ Log.e("Missing script and class. Either script or predefined class must be present."); throw new RuntimeException("Either script or predefined class must be present."); } component.getScriptInfo().setRubyInstance(rubyInstance); } + persistObjectProxy(component); } catch(IOException e){ e.printStackTrace(); if (component instanceof android.content.Context) { ProgressDialog.show((android.content.Context) component, "Script failed", "Something bad happened", true, true); } } } - public static final void callOnCreate(final RubotoComponent component, Object... args) { - persistObjectProxy(component); - if (component instanceof android.content.Context) { - Log.d("Call onCreate on: " + component.getScriptInfo().getRubyInstance()); - // FIXME(uwe): Simplify when we stop support for snake case aliasing interface callback methods. - if ((Boolean)JRubyAdapter.runScriptlet(component.getScriptInfo().getRubyClassName() + ".instance_methods(false).any?{|m| m.to_sym == :onCreate}")) { - JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "onCreate", args); - } else if ((Boolean)JRubyAdapter.runScriptlet(component.getScriptInfo().getRubyClassName() + ".instance_methods(true).any?{|m| m.to_sym == :on_create}")) { - JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "on_create", args); - } else { - JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "onCreate", args); - } - // EMXIF - } - } - - public static final void callOnDestroy(final RubotoComponent component) { - String rubyClassName = component.getScriptInfo().getRubyClassName(); - if ((Boolean)JRubyAdapter.runScriptlet(rubyClassName + ".instance_methods(false).any?{|m| m.to_sym == :onDestroy}")) { - JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "onDestroy"); - } else if ((Boolean)JRubyAdapter.runScriptlet(rubyClassName + ".instance_methods(true).any?{|m| m.to_sym == :on_destroy}")) { - JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "on_destroy"); - } else { - JRubyAdapter.runRubyMethod(component.getScriptInfo().getRubyInstance(), "onDestroy"); - } - releaseObjectProxy(component); - } - private static void persistObjectProxy(RubotoComponent component) { JRubyAdapter.runScriptlet("Java::" + component.getClass().getName() + ".__persistent__ = true"); ((Map)JRubyAdapter.get("RUBOTO_JAVA_PROXIES")).put(component.getScriptInfo().getRubyInstance(), component.getScriptInfo().getRubyInstance()); } - private static void releaseObjectProxy(RubotoComponent component) { + public static void unloadScript(RubotoComponent component) { ((Map)JRubyAdapter.get("RUBOTO_JAVA_PROXIES")).remove(component.getScriptInfo().getRubyInstance()); } }