use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.
the class UDHttp method initVarargs.
/**
* 初始化数据
*/
private void initVarargs() {
final LuaValue param1 = getInitParam1();
final LuaFunction callback = LuaUtil.getFunction(initParams, 2);
final String method = LuaUtil.getString(param1, "method");
final LuaTable params = LuaUtil.getTable(param1, "params");
setMethod(method);
setParams(params);
setCallback(callback);
disableConnectionReuseIfNecessary();
}
use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.
the class UDHttpResponse method toTable.
/**
* convert response to LuaTable
*
* @return
*/
public LuaTable toTable() {
LuaTable result = new LuaTable();
result.set("data", new UDData(getGlobals(), getmetatable(), null).append(mData));
result.set("code", LuaValue.valueOf(mStatusCode));
result.set("header", LuaUtil.toTable(mHeaders));
result.set("message", LuaValue.valueOf(mResponseMsg));
return result;
}
use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.
the class VibratorMethodMapper method vibrate.
/**
* 开始震动
*
* @param vibrator
* @param varargs
* @return
*/
public LuaValue vibrate(U vibrator, Varargs varargs) {
if (varargs.narg() > 2 || (varargs.narg() > 1 && varargs.istable(2))) {
final LuaTable luaTable = LuaUtil.getTable(varargs, 2);
final Integer repeat = LuaUtil.toJavaInt(varargs.arg(3));
return vibrator.vibrate(luaTable, repeat);
} else {
final Double time = LuaUtil.getDouble(varargs, 2);
return vibrator.vibrate((long) (time != null ? time * DateUtil.ONE_SECOND : DateUtil.ONE_SECOND));
}
}
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;
}
Aggregations