Search in sources :

Example 61 with LuaValue

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

the class JsonUtil method toLuaTable.

/**
     * 将JSONObject转成LuaTable
     *
     * @param obj
     * @return
     */
public static LuaValue toLuaTable(JSONArray obj) {
    LuaValue result = LuaValue.NIL;
    if (obj != null) {
        //只要不空,就创建一个table
        result = new LuaTable();
        if (obj.length() > 0) {
            for (int i = 0; i < obj.length(); i++) {
                final int key = i + 1;
                final Object value = obj.opt(i);
                result.set(key, toLuaValue(value));
            }
        }
    }
    return result;
}
Also used : LuaTable(org.luaj.vm2.LuaTable) JSONObject(org.json.JSONObject) LuaValue(org.luaj.vm2.LuaValue)

Example 62 with LuaValue

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

the class JsonUtil method toLuaTable.

/**
     * 将JSONObject转成LuaTable
     *
     * @param obj
     * @return
     */
public static LuaValue toLuaTable(JSONObject obj) {
    LuaValue result = LuaValue.NIL;
    if (obj != null) {
        result = new LuaTable();
        if (obj.length() > 0) {
            //只要不空,就创建一个table
            Iterator<String> iter = obj.keys();
            while (iter.hasNext()) {
                final String key = iter.next();
                final Object value = obj.opt(key);
                result.set(key, toLuaValue(value));
            }
        }
    }
    return result;
}
Also used : LuaTable(org.luaj.vm2.LuaTable) JSONObject(org.json.JSONObject) LuaValue(org.luaj.vm2.LuaValue)

Example 63 with LuaValue

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

the class LuaUtil method toMap.

/**
     * 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;
}
Also used : HashMap(java.util.HashMap) UDSpannableString(com.taobao.luaview.userdata.ui.UDSpannableString) LuaValue(org.luaj.vm2.LuaValue)

Example 64 with LuaValue

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

the class UDSpannableString method init.

/**
     * 初始化数据
     */
public void init(Varargs initParams) {
    LuaValue text = NIL, config = NIL;
    if (initParams != null) {
        text = getInitParam1();
        config = getInitParam2();
    }
    initSpannableStringBuilder(text, config);
}
Also used : LuaValue(org.luaj.vm2.LuaValue)

Example 65 with LuaValue

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

the class UDView method startAnimation.

//-------------------------------------------动画相关--------------------------------------------
/**
     * 开始动画
     * TODO 这里的start/stop需要跟 UDAnimator的保持同步
     *
     * @param animators
     * @return
     */
public UDView startAnimation(LuaValue[] animators) {
    final View view = getView();
    if (view != null && animators.length > 0) {
        if (isAnimating() == false) {
            //不在动画中才可以动画
            if (mAnimators != null) {
                AnimatorUtil.cancel(mAnimators);
                mAnimators.clear();
            } else {
                mAnimators = new ArrayList<Animator>();
            }
            for (LuaValue animator : animators) {
                if (animator instanceof UDAnimator) {
                    final Animator anim = ((UDAnimator) animator).with(this).build();
                    mAnimators.add(anim);
                }
            }
            startAnimation();
        }
    }
    return this;
}
Also used : Animator(android.animation.Animator) LuaValue(org.luaj.vm2.LuaValue) LVImageView(com.taobao.luaview.view.LVImageView) View(android.view.View) LVRecyclerView(com.taobao.luaview.view.LVRecyclerView)

Aggregations

LuaValue (org.luaj.vm2.LuaValue)51 LuaTable (org.luaj.vm2.LuaTable)35 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)5 LuaFunction (org.luaj.vm2.LuaFunction)5 View (android.view.View)4 LuaError (org.luaj.vm2.LuaError)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 UDLuaTable (com.taobao.luaview.userdata.base.UDLuaTable)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Field (java.lang.reflect.Field)2