Open fly2012 opened 5 years ago
It seems to be a bug for android 7.0-7.1 only. I'll fix it later and pubish a new version 1.3.1
fly2012 notifications@github.com 于 2018年12月29日周六 10:18写道:
[image: image] https://user-images.githubusercontent.com/2106761/50532327-d331f080-0b52-11e9-9cb1-27eef982c13f.png
With the code.
findViewById(R.id.test).setOnClickListener(new View.OnClickListener() { @override https://github.com/override public void onClick(View v) { executeLua("using "java.lang"\n" + "--for method call test\n" + "local abs=Math.abs\n" + "local t=os.clock()\n" + "for i=1,2.5e6 do\n" + " abs(0)\n" + "end\n" + "print(os.clock()-t)\n" + "\n" + "--for member access test\n" + "t=os.clock()\n" + "for i=1,1.8e6 do\n" + " Math.abs(0)\n" + "end\n" + "print(os.clock()-t)"); } }); } private void executeLua(String str){ ScriptContext context = new ScriptContext(); context.addToLua("context", this); context.run(str); }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/qtiuto/lua-for-android/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/AJHwUjwUq5mQbDD9wXRdv8tbTdY29E3gks5u9tDjgaJpZM4ZkXZ1 .
Version 1.3.1 has been publish to fix the using bugs for older android versions. @fly2012
With the code.
findViewById(R.id.test).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { executeLua("using \"java.lang\"\n" + "--for method call test\n" + "local abs=Math.abs\n" + "local t=os.clock()\n" + "for i=1,2.5e6 do\n" + " abs(0)\n" + "end\n" + "print(os.clock()-t)\n" + "\n" + "--for member access test\n" + "t=os.clock()\n" + "for i=1,1.8e6 do\n" + " Math.abs(0)\n" + "end\n" + "print(os.clock()-t)"); } }); } private void executeLua(String str){ ScriptContext context = new ScriptContext(); context.addToLua("context", this); context.run(str); }