Search in sources :

Example 21 with LuaValue

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;
}
Also used : LuaValue(org.luaj.vm2.LuaValue) LuaViewApi(com.taobao.luaview.fun.mapper.LuaViewApi)

Example 22 with LuaValue

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

Example 23 with LuaValue

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;
}
Also used : LuaTable(org.luaj.vm2.LuaTable) UDView(com.taobao.luaview.userdata.ui.UDView) ArrayList(java.util.ArrayList) LuaValue(org.luaj.vm2.LuaValue)

Example 24 with LuaValue

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;
}
Also used : UDView(com.taobao.luaview.userdata.ui.UDView) LuaValue(org.luaj.vm2.LuaValue)

Example 25 with LuaValue

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

Aggregations

LuaValue (org.luaj.vm2.LuaValue)55 LuaTable (org.luaj.vm2.LuaTable)37 Varargs (org.luaj.vm2.Varargs)12 LuaString (org.luaj.vm2.LuaString)9 VarArgFunction (org.luaj.vm2.lib.VarArgFunction)7 UDView (com.taobao.luaview.userdata.ui.UDView)6 LuaError (org.luaj.vm2.LuaError)6 LuaFunction (org.luaj.vm2.LuaFunction)6 View (android.view.View)4 Point (android.graphics.Point)3 ILVView (com.taobao.luaview.view.interfaces.ILVView)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 JSONObject (org.json.JSONObject)3 HorizontalScrollView (android.widget.HorizontalScrollView)2 AerospikeException (com.aerospike.client.AerospikeException)2 LuaViewApi (com.taobao.luaview.fun.mapper.LuaViewApi)2 UDLuaTable (com.taobao.luaview.userdata.base.UDLuaTable)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2