本文整理汇总了Java中org.luaj.vm2.LuaTable.keys方法的典型用法代码示例。如果您正苦于以下问题:Java LuaTable.keys方法的具体用法?Java LuaTable.keys怎么用?Java LuaTable.keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.luaj.vm2.LuaTable
的用法示例。
在下文中一共展示了LuaTable.keys方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawLines
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawLines(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
final float pts[] = new float[keys.length * 4];
LuaValue value = null;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 4) {
for (int j = 0; j < 4; j++) {
pts[i * 4 + j] = DimenUtil.dpiToPx(value.get(j + 1));
}
}
}
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
canvas.drawLines(pts, getDefaultPaint(config));
}
}
}
}
示例2: require
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/**
* Lua业务代码层可以使用该API请求跳转到一个新的Activity。
* @param params
*/
@LuaViewApi
public void require(LuaTable params) {
HashMap<String, String> hashMap = new HashMap<>();
LuaValue[] k = params.keys();
for (int i=0; i < k.length; i++) {
hashMap.put(k[i].optjstring(null), params.get(k[i]).optjstring(null));
}
/**
* 启动另一个Activity之前,把当前Activity的packagePath和uri参数透传给下一个Activity。
*/
if (mActivity.mUri != null) {
hashMap.put("uri", mActivity.mUri);
hashMap.put("packagePath", LuaScriptManager.buildScriptBundleFolderPath(mActivity.mUri));
}
Intent intent = new Intent(mActivity, LVBasicActivity.class);
intent.putExtra(Constants.PAGE_PARAMS, hashMap);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mActivity.startActivity(intent);
}
示例3: clipRects
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void clipRects(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
float x1, y1, dx, dy;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 4) {
x1 = DimenUtil.dpiToPx(value.get(1));
y1 = DimenUtil.dpiToPx(value.get(2));
dx = DimenUtil.dpiToPx(value.get(3));
dy = DimenUtil.dpiToPx(value.get(4));
canvas.clipRect(x1, y1, x1 + dx, y1 + dy);
}
}
}
}
}
}
示例4: drawRects
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawRects(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
float x1, y1, dx, dy;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 4) {
x1 = DimenUtil.dpiToPx(value.get(1));
y1 = DimenUtil.dpiToPx(value.get(2));
dx = DimenUtil.dpiToPx(value.get(3));
dy = DimenUtil.dpiToPx(value.get(4));
canvas.drawRect(x1, y1, x1 + dx, y1 + dy, getDefaultPaint(LuaUtil.isTable(value.get(5)) ? value.get(5) : config));
}
}
}
}
}
}
示例5: drawPoints
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawPoints(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
final float pts[] = new float[keys.length * 2];
LuaValue value = null;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 2) {
for (int j = 0; j < 2; j++) {
pts[i * 2 + j] = DimenUtil.dpiToPx(value.get(j + 1));
}
}
}
canvas.drawPoints(pts, getDefaultPaint(config));
}
}
}
}
示例6: drawCircles
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawCircles(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 3) {
canvas.drawCircle(DimenUtil.dpiToPx(value.get(1)),
DimenUtil.dpiToPx(value.get(2)),
DimenUtil.dpiToPx(value.get(3)),
getDefaultPaint(LuaUtil.isTable(value.get(4)) ? value.get(4) : config));
}
}
}
}
}
}
示例7: drawTexts
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawTexts(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
CharSequence text = null;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 3) {
text = LuaUtil.toText(value.get(1));
if (!TextUtils.isEmpty(text)) {
canvas.drawText(text, 0, text.length(),
DimenUtil.dpiToPx(value.get(2)),
DimenUtil.dpiToPx(value.get(3)),
getDefaultPaint(LuaUtil.isTable(value.get(4)) ? value.get(4) : config));
}
}
}
}
}
}
}
示例8: startAnimationImages
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/**
* 开始帧动画
*
* @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;
}
示例9: onDestroyTable
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
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);
}
}
}
}
}
示例10: toJSONObject
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
public static JSONObject toJSONObject(LuaTable table) {
JSONObject obj = new JSONObject();
if (table != null) {
LuaValue[] keys = table.keys();
if (keys != null && keys.length > 0) {
try {
for (int i = 0; i < keys.length; i++) {
String key = keys[i].optjstring("");
LuaValue value = table.get(keys[i]);
if (value instanceof LuaTable) {
obj.put(key, toJSONObject((LuaTable) value));
} else {
obj.put(key, value);
}
}
} catch (JSONException e) {
LogUtil.e("[LuaView Error-toJSONObject]-Json Parse Failed, Reason: Invalid Format!", e);
}
}
}
return obj;
}
示例11: luaTableToMap
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
static Map<String, String> luaTableToMap(LuaTable value) {
Map<String, String> params = new HashMap<>();
LuaValue[] keys = value.keys();
for (LuaValue k : keys) {
if (k.isstring()) {
LuaValue v = value.get(k);
if (v.isstring()) {
params.put(k.tojstring(), v.tojstring());
}
}
}
return params;
}
示例12: drawRoundRects
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawRoundRects(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
float x1, y1, dx, dy, x3, y3;
Paint paint = null;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 6) {
x1 = DimenUtil.dpiToPx(value.get(1));
y1 = DimenUtil.dpiToPx(value.get(2));
dx = DimenUtil.dpiToPx(value.get(3));
dy = DimenUtil.dpiToPx(value.get(4));
x3 = DimenUtil.dpiToPx(value.get(5));
y3 = DimenUtil.dpiToPx(value.get(6));
paint = getDefaultPaint(LuaUtil.isTable(value.get(7)) ? value.get(7) : config);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
canvas.drawRoundRect(x1, y1, x1 + dx, y1 + dy, x3, y3, paint);
} else {
drawRoundRectPlain(x1, y1, x1 + dx, y1 + dy, x3, y3, paint, canvas);
}
}
}
}
}
}
}
示例13: drawArcs
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawArcs(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
float x1, y1, dx, dy, x3, y3;
boolean use = false;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 7) {
x1 = DimenUtil.dpiToPx(value.get(1));
y1 = DimenUtil.dpiToPx(value.get(2));
dx = DimenUtil.dpiToPx(value.get(3));
dy = DimenUtil.dpiToPx(value.get(4));
x3 = (float) value.get(5).optdouble(0);
y3 = (float) value.get(6).optdouble(0);
use = value.get(7).optboolean(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
canvas.drawArc(x1, y1, x1 + dx, y1 + dy, x3, y3, use,
getDefaultPaint(LuaUtil.isTable(value.get(8)) ? value.get(8) : config));
} else {
final RectF rectF = mRectF;
rectF.left = x1;
rectF.top = y1;
rectF.right = x1 + dx;
rectF.bottom = y1 + dy;
canvas.drawArc(rectF, x3, y3, use, getDefaultPaint(config));
}
}
}
}
}
}
}
示例14: drawOvals
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
private void drawOvals(Varargs varargs) {
final Canvas canvas = getCanvas();
if (canvas != null) {
final LuaTable table = LuaUtil.getTable(varargs, 2);
final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
if (table != null) {
final LuaValue[] keys = table.keys();
if (keys.length > 0) {
LuaValue value = null;
float x1, y1, dx, dy;
for (int i = 0; i < keys.length; i++) {
value = table.get(keys[i]);
if (value instanceof LuaTable && value.length() >= 4) {
x1 = DimenUtil.dpiToPx(value.get(1));
y1 = DimenUtil.dpiToPx(value.get(2));
dx = DimenUtil.dpiToPx(value.get(3));
dy = DimenUtil.dpiToPx(value.get(4));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
canvas.drawOval(x1, y1, x1 + dx, y1 + dy, getDefaultPaint(LuaUtil.isTable(value.get(5)) ? value.get(5) : config));
} else {
final RectF rectF = mRectF;
rectF.left = x1;
rectF.top = y1;
rectF.right = x1 + dx;
rectF.bottom = y1 + dy;
canvas.drawOval(rectF, getDefaultPaint(config));
}
}
}
}
}
}
}
示例15: toMap
import org.luaj.vm2.LuaTable; //导入方法依赖的package包/类
/**
* convert a table to map
*
* @param table
* @return
*/
public static Map<String, String> toMap(LuaTable table) {
if (table != null) {
final Map<String, String> result = new HashMap<String, String>();
final LuaValue[] keys = table.keys();
LuaValue value = null;
for (LuaValue key : keys) {
value = table.get(key);
result.put(key.optjstring(null), value.optjstring(null));
}
}
return null;
}