Search in sources :

Example 21 with LuaTable

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);
}
Also used : LuaTable(org.luaj.vm2.LuaTable) LuaFunction(org.luaj.vm2.LuaFunction)

Example 22 with LuaTable

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;
}
Also used : LuaTable(org.luaj.vm2.LuaTable) LuaValue(org.luaj.vm2.LuaValue)

Example 23 with LuaTable

use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.

the class LuaUtil method toTable.

/**
     * convert params to LuaTable
     *
     * @param params
     * @return
     */
public static LuaValue toTable(List<?> params) {
    if (params != null) {
        final LuaTable result = new LuaTable();
        if (params.size() > 0) {
            Object value = null;
            for (int i = 0; i < params.size(); i++) {
                value = params.get(i);
                result.set(i + 1, toLuaValue(value));
            }
        }
        return result;
    }
    return LuaValue.NIL;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 24 with LuaTable

use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.

the class LuaUtil method toTable.

/**
     * convert map to LuaTable
     *
     * @param params
     * @return
     */
public static LuaValue toTable(Map<?, ?> params) {
    if (params != null) {
        final LuaTable result = new LuaTable();
        if (params.size() > 0) {
            Object valueObj = null;
            LuaValue key = null;
            for (final Object keyObj : params.keySet()) {
                valueObj = params.get(keyObj);
                key = toLuaValue(keyObj);
                if (key != LuaValue.NIL) {
                    result.set(key, toLuaValue(valueObj));
                }
            }
        }
        return result;
    }
    return LuaValue.NIL;
}
Also used : LuaTable(org.luaj.vm2.LuaTable) LuaValue(org.luaj.vm2.LuaValue)

Example 25 with LuaTable

use of org.luaj.vm2.LuaTable in project LuaViewSDK by alibaba.

the class DestroyUtil method onDestroyTable.

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);
                }
            }
        }
    }
}
Also used : LuaTable(org.luaj.vm2.LuaTable) UDView(com.taobao.luaview.userdata.ui.UDView) ViewGroup(android.view.ViewGroup) BaseUserdata(com.taobao.luaview.userdata.base.BaseUserdata) LuaValue(org.luaj.vm2.LuaValue) UDView(com.taobao.luaview.userdata.ui.UDView) View(android.view.View) ILVView(com.taobao.luaview.view.interfaces.ILVView)

Aggregations

LuaTable (org.luaj.vm2.LuaTable)54 LuaValue (org.luaj.vm2.LuaValue)19 Varargs (org.luaj.vm2.Varargs)16 VarArgFunction (org.luaj.vm2.lib.VarArgFunction)15 LuaError (org.luaj.vm2.LuaError)5 LuaFunction (org.luaj.vm2.LuaFunction)4 View (android.view.View)3 JSONObject (org.json.JSONObject)3 LibFunction (org.luaj.vm2.lib.LibFunction)3 BaseLuaTable (com.taobao.luaview.userdata.base.BaseLuaTable)2 UDView (com.taobao.luaview.userdata.ui.UDView)2 ILVView (com.taobao.luaview.view.interfaces.ILVView)2 List (java.util.List)2 LuanObjImage (net.schattenkind.androidLove.luan.obj.LuanObjImage)2 LuaString (org.luaj.vm2.LuaString)2 Paint (android.graphics.Paint)1 Sensor (android.hardware.Sensor)1 SoundPool (android.media.SoundPool)1 MotionEvent (android.view.MotionEvent)1 ViewGroup (android.view.ViewGroup)1