Search in sources :

Example 1 with UDViewGroup

use of com.taobao.luaview.userdata.ui.UDViewGroup in project LuaViewSDK by alibaba.

the class LVPageFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //View封装
    //TODO 为什么用mLuaUserData.getmetatable()不行
    final UDView page = new UDViewGroup(createPageLayout(), mGlobals, null);
    //对外数据封装,必须使用LuaTable
    final UDLuaTable pageData = new UDLuaTable(page);
    final View pageView = pageData.getView();
    //初始化View
    initView(pageData, mPosInViewPager);
    //绘制数据
    renderView(pageData, mPosInViewPager);
    return pageView;
}
Also used : UDLuaTable(com.taobao.luaview.userdata.base.UDLuaTable) UDViewGroup(com.taobao.luaview.userdata.ui.UDViewGroup) UDView(com.taobao.luaview.userdata.ui.UDView) UDView(com.taobao.luaview.userdata.ui.UDView) View(android.view.View)

Example 2 with UDViewGroup

use of com.taobao.luaview.userdata.ui.UDViewGroup in project LuaViewSDK by alibaba.

the class LVRecyclerViewAdapter method createItemView.

/**
     * create item view for view holder
     *
     * @param viewType
     * @return
     */
private View createItemView(final int viewType) {
    final UDViewGroup layout = new UDViewGroup(createLayout(), mGlobals, null);
    //对外数据封装,必须使用LuaTable
    final UDLuaTable cellData = new UDLuaTable(layout);
    View itemView = null;
    //View封装
    if (this.mLuaUserData.hasCellSize(viewType)) {
        //有Size的定义
        final LVViewGroup cellView = createLayout();
        View tmpView = layout.getView();
        if (tmpView != null) {
            cellView.addView(tmpView);
        }
        itemView = cellView;
    } else {
        itemView = layout.getView();
    }
    itemView.setTag(Constants.RES_LV_TAG, cellData);
    return itemView;
}
Also used : UDLuaTable(com.taobao.luaview.userdata.base.UDLuaTable) UDViewGroup(com.taobao.luaview.userdata.ui.UDViewGroup) RecyclerView(android.support.v7.widget.RecyclerView) UDBaseRecyclerView(com.taobao.luaview.userdata.list.UDBaseRecyclerView) View(android.view.View) AbsListView(android.widget.AbsListView) LVViewGroup(com.taobao.luaview.view.LVViewGroup)

Example 3 with UDViewGroup

use of com.taobao.luaview.userdata.ui.UDViewGroup in project LuaViewSDK by alibaba.

the class LVCustomViewPagerIndicator method createView.

/**
     * create view
     *
     * @param pos
     * @return
     */
private LuaValue createView(int pos, int currentItem) {
    Globals globals = this.mLuaUserdata.getGlobals();
    //View封装
    final LVViewGroup container = createCellLayout();
    final UDViewGroup cell = new UDViewGroup(container, globals, null);
    //对外数据封装,必须使用LuaTable
    final UDLuaTable cellData = new UDLuaTable(cell);
    //call init
    globals.saveContainer(container);
    //初始化
    this.mLuaUserdata.callCellInit(cellData, pos, currentItem);
    globals.restoreContainer();
    //set tag
    View view = cellData.getView();
    if (view != null) {
        view.setTag(Constants.RES_LV_TAG, cellData);
    }
    return cellData;
}
Also used : Globals(org.luaj.vm2.Globals) UDLuaTable(com.taobao.luaview.userdata.base.UDLuaTable) UDViewGroup(com.taobao.luaview.userdata.ui.UDViewGroup) LVViewGroup(com.taobao.luaview.view.LVViewGroup) ILVView(com.taobao.luaview.view.interfaces.ILVView) HorizontalScrollView(android.widget.HorizontalScrollView) UDView(com.taobao.luaview.userdata.ui.UDView) View(android.view.View)

Example 4 with UDViewGroup

use of com.taobao.luaview.userdata.ui.UDViewGroup in project LuaViewSDK by alibaba.

the class LVListViewAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    //        LogUtil.d("yesong", position, convertView, getItemViewType(position), getViewTypeCount());
    //数据封装
    UDLuaTable cellData = null;
    final int viewType = getItemViewType(position);
    final boolean hasCellSize = this.mLuaUserData.hasCellSize(position);
    if (convertView == null || ((UDLuaTable) convertView.getTag()).get(KEY_VIEW_TYPE) != LuaValue.valueOf(viewType)) {
        //在内部创建好Cell
        //TODO 为什么用mLuaUserData.getmetatable()不行
        UDView layout = new UDViewGroup(createLayout(), mGlobals, null);
        //对外数据封装,必须使用LuaTable
        cellData = new UDLuaTable(layout);
        //View封装
        if (hasCellSize) {
            //有Size的定义
            final LVViewGroup cellView = createLayout();
            View tmp = layout.getView();
            if (tmp != null) {
                cellView.addView(tmp);
            }
            convertView = cellView;
        } else {
            convertView = layout.getView();
        }
        initView(cellData, position);
        convertView.setTag(cellData);
    } else {
        cellData = (UDLuaTable) convertView.getTag();
    }
    //更新position
    cellData.set(KEY_VIEW_TYPE, viewType);
    if (hasCellSize) {
        //有Size的定义,每次更新size
        //TODO 需要动态更新View的Size,需要在这里调用,否则移动到初始化的时候。这个暂时先去掉,会有问题,复用有问题
        initCellSize(cellData, position);
    }
    //绘制数据
    renderView(cellData, position);
    return convertView;
}
Also used : UDLuaTable(com.taobao.luaview.userdata.base.UDLuaTable) UDViewGroup(com.taobao.luaview.userdata.ui.UDViewGroup) UDView(com.taobao.luaview.userdata.ui.UDView) LVViewGroup(com.taobao.luaview.view.LVViewGroup) AbsListView(android.widget.AbsListView) UDBaseListView(com.taobao.luaview.userdata.list.UDBaseListView) UDView(com.taobao.luaview.userdata.ui.UDView) View(android.view.View)

Example 5 with UDViewGroup

use of com.taobao.luaview.userdata.ui.UDViewGroup in project LuaViewSDK by alibaba.

the class LVPagerAdapter method newItem.

public Object newItem(ViewGroup container, int position) {
    //View封装
    //TODO 为什么用mLuaUserData.getmetatable()不行
    final UDView page = new UDViewGroup(createPageLayout(), mGlobals, null);
    //对外数据封装,必须使用LuaTable
    final UDLuaTable pageData = new UDLuaTable(page);
    final View pageView = pageData.getView();
    //添加view
    if (container != null && pageView != null) {
        container.addView(pageView);
    }
    //初始化View
    initView(pageData, position);
    //绘制数据
    renderView(pageData, position);
    //add to list
    mViews.put(position, new WeakReference<View>(pageView));
    return pageView;
}
Also used : UDLuaTable(com.taobao.luaview.userdata.base.UDLuaTable) UDViewGroup(com.taobao.luaview.userdata.ui.UDViewGroup) UDView(com.taobao.luaview.userdata.ui.UDView) UDView(com.taobao.luaview.userdata.ui.UDView) View(android.view.View)

Aggregations

View (android.view.View)5 UDLuaTable (com.taobao.luaview.userdata.base.UDLuaTable)5 UDViewGroup (com.taobao.luaview.userdata.ui.UDViewGroup)5 UDView (com.taobao.luaview.userdata.ui.UDView)4 LVViewGroup (com.taobao.luaview.view.LVViewGroup)3 AbsListView (android.widget.AbsListView)2 RecyclerView (android.support.v7.widget.RecyclerView)1 HorizontalScrollView (android.widget.HorizontalScrollView)1 UDBaseListView (com.taobao.luaview.userdata.list.UDBaseListView)1 UDBaseRecyclerView (com.taobao.luaview.userdata.list.UDBaseRecyclerView)1 ILVView (com.taobao.luaview.view.interfaces.ILVView)1 Globals (org.luaj.vm2.Globals)1