Search in sources :

Example 1 with UDLuaTable

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

use of com.taobao.luaview.userdata.base.UDLuaTable in project LuaViewSDK by alibaba.

the class LVRecyclerViewHolder method onLayout.

/**
     * onLayout view
     *
     * @param position
     */
public void onLayout(final int position) {
    Object obj = itemView.getTag(Constants.RES_LV_TAG);
    if (obj instanceof UDLuaTable) {
        final UDLuaTable cellData = (UDLuaTable) obj;
        mGlobals.saveContainer(cellData.getLVViewGroup());
        mLuaUserData.callCellLayout(cellData, position);
        mGlobals.restoreContainer();
    }
}
Also used : UDLuaTable(com.taobao.luaview.userdata.base.UDLuaTable)

Example 3 with UDLuaTable

use of com.taobao.luaview.userdata.base.UDLuaTable in project LuaViewSDK by alibaba.

the class LVRecyclerViewAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(LVRecyclerViewHolder holder, int position) {
    if (position >= 0 && position < getItemCount()) {
        if (holder != null) {
            if (holder.itemView != null) {
                //设置位置
                holder.itemView.setTag(Constants.RES_LV_TAG_POSITION, position);
                holder.itemView.setTag(Constants.RES_LV_TAG_PINNED, this.mLuaUserData.mIsPinnedSparseArray.get(position));
            }
            if (this.mLuaUserData.hasCellSize(getItemViewType(position))) {
                if (holder.itemView != null && holder.itemView.getTag(Constants.RES_LV_TAG) instanceof UDLuaTable) {
                    UDLuaTable cellData = (UDLuaTable) holder.itemView.getTag(Constants.RES_LV_TAG);
                    //初始化View的size,这里因为每个cell的宽度高度可能不一样,需要再调用一遍
                    initCellSize(cellData, position);
                }
            }
            if (holder.itemView != null && holder.itemView.getTag(Constants.RES_LV_TAG_INIT) == null) {
                //是否已经调用过onInit,如果调用过则不重复调用
                holder.onInit(position);
                holder.itemView.setTag(Constants.RES_LV_TAG_INIT, true);
            }
            holder.onLayout(position);
        }
    }
}
Also used : UDLuaTable(com.taobao.luaview.userdata.base.UDLuaTable)

Example 4 with UDLuaTable

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

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

Aggregations

UDLuaTable (com.taobao.luaview.userdata.base.UDLuaTable)10 View (android.view.View)6 UDView (com.taobao.luaview.userdata.ui.UDView)5 UDViewGroup (com.taobao.luaview.userdata.ui.UDViewGroup)5 LVViewGroup (com.taobao.luaview.view.LVViewGroup)3 AbsListView (android.widget.AbsListView)2 UDBaseListView (com.taobao.luaview.userdata.list.UDBaseListView)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 AdapterView (android.widget.AdapterView)1 HorizontalScrollView (android.widget.HorizontalScrollView)1 ListView (android.widget.ListView)1 UDBaseRecyclerView (com.taobao.luaview.userdata.list.UDBaseRecyclerView)1 UDListView (com.taobao.luaview.userdata.list.UDListView)1 LVListViewAdapter (com.taobao.luaview.view.adapter.LVListViewAdapter)1 ILVListView (com.taobao.luaview.view.interfaces.ILVListView)1 ILVView (com.taobao.luaview.view.interfaces.ILVView)1 Globals (org.luaj.vm2.Globals)1 LuaValue (org.luaj.vm2.LuaValue)1