Search in sources :

Example 6 with LuaTable

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

the class UDHttp method initVarargs.

/**
     * 初始化数据
     */
private void initVarargs() {
    final LuaValue param1 = getInitParam1();
    final LuaFunction callback = LuaUtil.getFunction(initParams, 2);
    final String method = LuaUtil.getString(param1, "method");
    final LuaTable params = LuaUtil.getTable(param1, "params");
    setMethod(method);
    setParams(params);
    setCallback(callback);
    disableConnectionReuseIfNecessary();
}
Also used : LuaTable(org.luaj.vm2.LuaTable) LuaValue(org.luaj.vm2.LuaValue) LuaFunction(org.luaj.vm2.LuaFunction)

Example 7 with LuaTable

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

the class UDHttpResponse method toTable.

/**
     * convert response to LuaTable
     *
     * @return
     */
public LuaTable toTable() {
    LuaTable result = new LuaTable();
    result.set("data", new UDData(getGlobals(), getmetatable(), null).append(mData));
    result.set("code", LuaValue.valueOf(mStatusCode));
    result.set("header", LuaUtil.toTable(mHeaders));
    result.set("message", LuaValue.valueOf(mResponseMsg));
    return result;
}
Also used : BaseLuaTable(com.taobao.luaview.userdata.base.BaseLuaTable) LuaTable(org.luaj.vm2.LuaTable) UDData(com.taobao.luaview.userdata.kit.UDData)

Example 8 with LuaTable

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

the class VibratorMethodMapper method vibrate.

/**
     * 开始震动
     *
     * @param vibrator
     * @param varargs
     * @return
     */
public LuaValue vibrate(U vibrator, Varargs varargs) {
    if (varargs.narg() > 2 || (varargs.narg() > 1 && varargs.istable(2))) {
        final LuaTable luaTable = LuaUtil.getTable(varargs, 2);
        final Integer repeat = LuaUtil.toJavaInt(varargs.arg(3));
        return vibrator.vibrate(luaTable, repeat);
    } else {
        final Double time = LuaUtil.getDouble(varargs, 2);
        return vibrator.vibrate((long) (time != null ? time * DateUtil.ONE_SECOND : DateUtil.ONE_SECOND));
    }
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 9 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 10 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)

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