use of org.luaj.vm2.LuaValue in project love-android by hagish.
the class LuaUtils method getFromTableByPath.
public static LuaValue getFromTableByPath(LuaTable t, String path) {
String[] pathParts = path.split("\\.");
LuaValue cur = t;
for (String part : pathParts) {
LuaValue next = cur.get(part);
if (next.equals(LuaValue.NIL)) {
cur = next;
break;
} else {
cur = next;
}
}
return cur;
}
use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.
the class UDBaseListOrRecyclerView method callCellSize.
/**
* return width, height
*
* @param cell
* @param position
* @return
*/
public int[] callCellSize(LuaValue cell, int position, int... defaultSize) {
final Varargs size = invokeCellSize(cell, position);
int defaultWidth = (defaultSize != null && defaultSize.length > 1) ? defaultSize[0] : AndroidUtil.getScreenWidth(getContext());
int width = 0, height = 0;
if (size != null) {
if (size.narg() > 1) {
//width & height
width = DimenUtil.dpiToPx(size.arg(1), defaultWidth);
height = DimenUtil.dpiToPx(size.arg(2));
} else {
width = defaultWidth;
height = DimenUtil.dpiToPx(size.arg(1));
}
}
return new int[] { width, height };
}
use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.
the class UDBaseListOrRecyclerView method onCellLongClicked.
/**
* 调用 Callback 方法
*
* @param cell
* @param position
* @return
*/
public boolean onCellLongClicked(LuaValue cell, int position) {
final int section = getSectionByPosition(position);
final int row = getRowInSectionByPosition(position);
final String id = getId(position, section, row);
final LuaValue cellData = getCell(id);
if (cellData != null) {
final LuaValue callback = cellData.get("Callback");
if (callback != null && callback.istable()) {
return LuaUtil.callFunction(LuaUtil.getFunction(callback, "LongClick", "longClick"), cell, LuaUtil.toLuaInt(section), LuaUtil.toLuaInt(row)).optboolean(false);
}
}
return false;
}
use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.
the class UDBaseListOrRecyclerView method onCellClicked.
/**
* 调用 Callback 方法
*
* @param cell
* @param position
* @return
*/
public LuaValue onCellClicked(LuaValue cell, int position) {
final int section = getSectionByPosition(position);
final int row = getRowInSectionByPosition(position);
final String id = getId(position, section, row);
final LuaValue cellData = getCell(id);
if (cellData != null) {
final LuaValue callback = cellData.get("Callback");
if (callback.isfunction()) {
return LuaUtil.callFunction(callback, cell, LuaUtil.toLuaInt(section), LuaUtil.toLuaInt(row));
} else if (callback.istable()) {
return LuaUtil.callFunction(LuaUtil.getFunction(callback, "Click", "click"), cell, LuaUtil.toLuaInt(section), LuaUtil.toLuaInt(row));
}
}
return NIL;
}
use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.
the class HttpMethodMapper method get.
/**
* get请求
*
* @param http
* @param varargs
* @return
*/
public LuaValue get(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.get(url, params, callback);
}
Aggregations