use of org.luaj.vm2.Varargs in project LuaViewSDK by alibaba.
the class UIImageViewMethodMapper method startAnimationImages.
/**
* 开始帧动画
*
* @param view
* @param varargs 时间是秒而不是毫秒
* @return
*/
@Deprecated
public LuaValue startAnimationImages(U view, Varargs varargs) {
// TODO 支持UDImageView和UDBitmap
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.Varargs in project LuaViewSDK by alibaba.
the class UIViewGroupMethodMapper method flexChildren.
/**
* Flexbox 设置childViews
*
* @param view
* @param varargs
* @return
*/
public LuaValue flexChildren(U view, Varargs varargs) {
ArrayList<UDView> flexChildren = new ArrayList<UDView>();
LuaValue children = varargs.arg(2);
if (children != null && children instanceof LuaTable) {
// 子节点以一个表的形式作为参数传入
for (int i = 0; i <= children.length(); i++) {
LuaValue luaValue = children.get(i + 1);
if (luaValue != null && luaValue instanceof UDView) {
flexChildren.add((UDView) luaValue);
}
}
} else {
for (int i = 2; i <= varargs.narg(); i++) {
LuaValue luaValue = varargs.optvalue(i, null);
if (luaValue != null && luaValue instanceof UDView) {
flexChildren.add((UDView) luaValue);
}
}
}
view.setChildNodeViews(flexChildren);
return view;
}
use of org.luaj.vm2.Varargs in project LuaViewSDK by alibaba.
the class UIViewGroupMethodMapper method addView.
/**
* 添加子类
*
* @param view
* @param varargs
* @return
*/
public LuaValue addView(U view, Varargs varargs) {
final LuaValue luaValue = varargs.optvalue(2, null);
final Integer pos = LuaUtil.getInt(varargs, 3);
if (luaValue instanceof UDView) {
return view.addView((UDView) luaValue, pos);
}
return view;
}
use of org.luaj.vm2.Varargs in project LuaViewSDK by alibaba.
the class BitmapMethodMapper method sprite.
// --------------------------------------- API --------------------------------------------------
/**
* 切割bitmap
*
* @param bitmap
* @param varargs
* @return
*/
public LuaValue sprite(U bitmap, Varargs varargs) {
final int x = DimenUtil.dpiToPx(varargs.arg(2));
final int y = DimenUtil.dpiToPx(varargs.arg(3));
final int width = DimenUtil.dpiToPx(varargs.arg(4));
final int height = DimenUtil.dpiToPx(varargs.arg(5));
final LuaFunction callback = LuaUtil.getFunction(varargs, 6);
return bitmap.sprite(x, y, width, height, callback);
}
use of org.luaj.vm2.Varargs in project LuaViewSDK by alibaba.
the class LuaUtil method getValue.
/**
* get value of given type, from varargs in position [poslist]
*
* @param type
* @param varargs
* @param poslist
* @return
*/
private static Object getValue(final int type, final Varargs varargs, Object defaultValue, int... poslist) {
Object result = null;
if (varargs != null) {
if (poslist != null && poslist.length > 0) {
LuaValue value = null;
for (int i = 0; i < poslist.length; i++) {
if (varargs.narg() >= poslist[i]) {
value = varargs.arg(poslist[i]);
result = parseValue(type, value);
}
if (result != null) {
break;
}
}
}
}
return result != null ? result : defaultValue;
}
Aggregations