Search in sources :

Example 1 with LuaViewApi

use of com.taobao.luaview.fun.mapper.LuaViewApi 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 2 with LuaViewApi

use of com.taobao.luaview.fun.mapper.LuaViewApi in project LuaViewSDK by alibaba.

the class UIViewMethodMapper method matrix.

@LuaViewApi(since = SdkVersion.V_051)
public LuaValue matrix(U view, Varargs varargs) {
    if (varargs.narg() > 1) {
        if (varargs.istable(2)) {
            LuaTable table = LuaUtil.getTable(varargs, 2);
            int n = table.length();
            if (n > 9) {
                float[] values = new float[9];
                for (int i = 0; i < 9; i++) {
                    values[i] = LuaUtil.getFloat(table, 0F, i + 2);
                }
                return view.setMatrix(values);
            } else if (n > 6) {
                float[] values = new float[9];
                for (int i = 0; i < 6; i++) {
                    values[i] = LuaUtil.getFloat(table, 0F, i + 2);
                }
                values[6] = 0;
                values[7] = 0;
                values[8] = 1;
                return view.setMatrix(values);
            }
        } else {
            int n = varargs.narg();
            if (n > 9) {
                float[] values = new float[9];
                for (int i = 0; i < 9; i++) {
                    values[i] = LuaUtil.getFloat(varargs, 0F, i + 2);
                }
                return view.setMatrix(values);
            } else if (n > 6) {
                float[] values = new float[9];
                for (int i = 0; i < 6; i++) {
                    values[i] = LuaUtil.getFloat(varargs, 0F, i + 2);
                }
                values[6] = 0;
                values[7] = 0;
                values[8] = 1;
                return view.setMatrix(values);
            }
        }
    } else {
        float[] values = view.getMatrix();
        if (values != null) {
            LuaTable table = new LuaTable();
            for (int i = 0; i < 6; i++) {
                table.set(i + 1, valueOf(values[i]));
            }
            return table;
        }
    }
    return view;
}
Also used : LuaTable(org.luaj.vm2.LuaTable) LuaViewApi(com.taobao.luaview.fun.mapper.LuaViewApi)

Aggregations

LuaViewApi (com.taobao.luaview.fun.mapper.LuaViewApi)2 LuaTable (org.luaj.vm2.LuaTable)1 LuaValue (org.luaj.vm2.LuaValue)1