use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.
the class UIRefreshLayoutViewMethodMapper method setRefreshingOffset.
@LuaViewApi(revisions = { "名称去掉set" })
public LuaValue setRefreshingOffset(U view, Varargs varargs) {
final LuaValue offset = varargs.optvalue(2, NIL);
view.setRefreshingOffset(offset.tofloat());
return this;
}
use of org.luaj.vm2.LuaValue 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.LuaValue 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.LuaValue 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.LuaValue 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);
}
Aggregations