public void onServiceConnected(ComponentName name, IBinder iservice) { Log.d("lua", "setting activity"); service = ((Lua.LocalBinder) iservice).getService(); modTable = service.require(modName); if (modTable == null) { finish(); return; } service.setGlobal("current_activity", this); Object res; Object arg = null; if (argRef != 0) { arg = LuaObject.fromReference(Lua.L, argRef); } try { if (modTable.isFunction()) { LuaObject android = service.require("android"); LuaObject aNew = android.getField("new"); res = aNew.call(new Object[] {modTable}); modTable = (LuaObject) res; } res = service.invokeMethod(modTable, "onCreate", this, arg, state); } catch (LuaException e) { log("onCreate " + e.getMessage()); res = null; } if (res == null) { finish(); return; } if (res instanceof View) { setContentView((View) res); } else if (!(res instanceof Boolean)) { log("onCreate must return a View"); finish(); return; } service.invokeMethod(modTable, "onStart"); if (state != null) { super.onRestoreInstanceState(state); } service.invokeMethod(modTable, "onResume"); }
@Override public boolean onOptionsItemSelected(MenuItem item) { Object res = service.invokeMethod(modTable, "onOptionsItemSelected", item); if (res == null) { return super.onOptionsItemSelected(item); } else { return true; } }
@Override public boolean onCreateOptionsMenu(Menu menu) { Object res = service.invokeMethod(modTable, "onCreateOptionsMenu", menu); return res != null ? (Boolean) res : false; }
@Override public void onDestroy() { super.onDestroy(); service.invokeMethod(modTable, "onDestroy"); Lua.unbind(this, this); }
@Override public void onStop() { super.onStop(); service.invokeMethod(modTable, "onStop"); }
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (service != null) service.invokeMethod(modTable, "onSaveInstanceState", outState); }
@Override public void onStart() { super.onStart(); if (service != null) service.invokeMethod(modTable, "onStart"); }
@Override public void onPause() { super.onPause(); service.invokeMethod(modTable, "onPause"); }
@Override protected void onActivityResult(int request, int result, Intent data) { service.invokeMethod(modTable, "onActivityResult", request, result, data); }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); service.invokeMethod(modTable, "onCreateContextMenu", menu, v, menuInfo); }