Esempio n. 1
0
  static void dispatchEvent(
      final LuaValueProxy listener, final String event, final String message) {
    if (listener == null || runtime == null || runtime.wasDisposed()) {
      return;
    }

    LuaState luaState = runtime.getLuaState();
    if (!luaState.isOpen()) {
      return;
    }

    final CoronaRuntimeTaskDispatcher dispatcher = new CoronaRuntimeTaskDispatcher(luaState);
    CoronaEnvironment.getCoronaActivity()
        .runOnUiThread(
            new Runnable() {
              @Override
              public void run() {
                CoronaRuntimeTask task =
                    new CoronaRuntimeTask() {
                      @Override
                      public void executeUsing(CoronaRuntime runtime) {
                        try {
                          LuaState luaState = runtime.getLuaState();
                          if (!luaState.isOpen() || listener == null) {
                            return;
                          }

                          listener.pushValue();

                          try {
                            luaState.checkType(-1, com.naef.jnlua.LuaType.FUNCTION);
                          } catch (Exception ex) {
                            ex.printStackTrace();
                            return;
                          }

                          int luaFunctionReferenceKey =
                              luaState.ref(com.naef.jnlua.LuaState.REGISTRYINDEX);
                          luaState.rawGet(
                              com.naef.jnlua.LuaState.REGISTRYINDEX, luaFunctionReferenceKey);
                          luaState.unref(
                              com.naef.jnlua.LuaState.REGISTRYINDEX, luaFunctionReferenceKey);
                          luaState.newTable();
                          luaState.pushString("plugin.tapfortap.event");
                          luaState.setField(-2, "name");
                          luaState.pushString(event);
                          luaState.setField(-2, "event");
                          luaState.pushString(message);
                          luaState.setField(-2, "message");

                          luaState.call(1, 0);
                        } catch (Exception ex) {
                          ex.printStackTrace();
                        }
                      }
                    };
                dispatcher.send(task);
              }
            });
  }
Esempio n. 2
0
 public final int invoke(LuaState luaState) {
   CoronaActivity coronaActivity = CoronaEnvironment.getCoronaActivity();
   int checkInteger = luaState.checkInteger(1);
   String checkString = luaState.checkString(2);
   if (checkInteger != 0) {
     coronaActivity.runOnUiThread(new p(this, coronaActivity, checkString, checkInteger));
   }
   return 0;
 }
Esempio n. 3
0
 public int invoke(LuaState luaState) {
   new LtvManager(new AdManager(CoronaEnvironment.getCoronaActivity())).setLtvCookie();
   return 0;
 }
Esempio n. 4
0
 public int invoke(LuaState luaState) {
   CoronaActivity coronaActivity = CoronaEnvironment.getCoronaActivity();
   coronaActivity.runOnUiThread(new q(this, coronaActivity, luaState.checkString(1)));
   return 0;
 }