Search in sources :

Example 1 with BaseUserdata

use of com.taobao.luaview.userdata.base.BaseUserdata 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

View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 BaseUserdata (com.taobao.luaview.userdata.base.BaseUserdata)1 UDView (com.taobao.luaview.userdata.ui.UDView)1 ILVView (com.taobao.luaview.view.interfaces.ILVView)1 LuaTable (org.luaj.vm2.LuaTable)1 LuaValue (org.luaj.vm2.LuaValue)1