use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.
the class HttpMethodMapper method post.
/**
* pos 请求
*
* @param http
* @param varargs
* @return
*/
public LuaValue post(U http, Varargs varargs) {
final String url = LuaUtil.getString(varargs, 2);
final LuaTable params = LuaUtil.getTable(varargs, 3, 2);
final LuaFunction callback = LuaUtil.getFunction(varargs, 4, 3, 2);
return http.post(url, params, callback);
}
use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.
the class UIImageViewMethodMapper method startAnimationImages.
/**
* 开始帧动画
*
* @param view
* @param varargs 时间是秒而不是毫秒
* @return
*/
public LuaValue startAnimationImages(U view, Varargs varargs) {
final LuaTable imagesTable = varargs.opttable(2, null);
final double duration = varargs.optdouble(3, 1f);
boolean repeat = false;
if (varargs.isnumber(4)) {
repeat = varargs.optint(4, -1) > 0;
} else {
repeat = varargs.optboolean(4, false);
}
if (imagesTable != null && imagesTable.length() > 0) {
final String[] images = new String[imagesTable.length()];
int i = 0;
for (LuaValue key : imagesTable.keys()) {
images[i++] = imagesTable.get(key).optjstring(null);
}
return view.startAnimationImages(images, (int) duration * 1000, repeat);
}
return view;
}
use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.
the class LuaUtil method toTable.
/**
* convert params to LuaTable
*
* @param params
* @return
*/
public static LuaValue toTable(List<?> params) {
if (params != null) {
final LuaTable result = new LuaTable();
if (params.size() > 0) {
Object value = null;
for (int i = 0; i < params.size(); i++) {
value = params.get(i);
result.set(i + 1, toLuaValue(value));
}
}
return result;
}
return LuaValue.NIL;
}
use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.
the class LuaUtil method toTable.
/**
* convert map to LuaTable
*
* @param params
* @return
*/
public static LuaValue toTable(Map<?, ?> params) {
if (params != null) {
final LuaTable result = new LuaTable();
if (params.size() > 0) {
Object valueObj = null;
LuaValue key = null;
for (final Object keyObj : params.keySet()) {
valueObj = params.get(keyObj);
key = toLuaValue(keyObj);
if (key != LuaValue.NIL) {
result.set(key, toLuaValue(valueObj));
}
}
}
return result;
}
return LuaValue.NIL;
}
use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.
the class DestroyUtil method onDestroyTable.
public static void onDestroyTable(LuaTable table) {
if (table != null) {
LuaValue isDestroy = table.get(KEY_DESTROY);
if (isDestroy == null || !LuaBoolean.TRUE.eq_b(isDestroy)) {
//标志位
table.set(KEY_DESTROY, LuaBoolean.TRUE);
LuaValue value = null;
View view = null;
for (LuaValue key : table.keys()) {
value = table.get(key);
if (value instanceof UDView) {
view = ((UDView) value).getView();
if (view instanceof ViewGroup) {
clearViews((ViewGroup) view);
} else {
((UDView) value).onDestroy();
}
} else if (value instanceof BaseUserdata) {
((BaseUserdata) value).onDestroy();
} else if (value instanceof LuaTable) {
onDestroyTable((LuaTable) value);
}
}
}
}
}
Aggregations