Search in sources :

Example 6 with UDLuaTable

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

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

Example 8 with UDLuaTable

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

the class LVCustomViewPagerIndicator method createAndRenderView.

/**
     * 创建一个item
     *
     * @param pos
     * @return
     */
private View createAndRenderView(int pos) {
    final int currentItem = mViewPager.getCurrentItem();
    final LuaValue cellData = createView(pos, currentItem);
    if (cellData instanceof UDLuaTable) {
        //绘制
        mLuaUserdata.callCellLayout(cellData, pos, currentItem);
        return ((UDLuaTable) cellData).getView();
    }
    return null;
}
Also used : UDLuaTable(com.taobao.luaview.userdata.base.UDLuaTable) LuaValue(org.luaj.vm2.LuaValue)

Example 9 with UDLuaTable

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

the class LVRecyclerViewHolder method onInit.

public void onInit(int position) {
    Object obj = itemView != null ? itemView.getTag(Constants.RES_LV_TAG) : null;
    if (obj instanceof UDLuaTable) {
        UDLuaTable cellData = (UDLuaTable) obj;
        //初始化View
        initView(cellData, position);
        //点击回调
        initCallbacks(cellData, position);
    }
}
Also used : UDLuaTable(com.taobao.luaview.userdata.base.UDLuaTable)

Example 10 with UDLuaTable

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

the class LVListView method initData.

/**
     * 初始化子元素
     */
private void initData(Globals globals) {
    //        initHeaderContainer();
    //        initFooterContainer();
    mAdapter = new LVListViewAdapter(globals, mLuaUserdata);
    this.setAdapter(mAdapter);
    this.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final UDLuaTable cellData = (UDLuaTable) view.getTag();
            final int row = position - LVListView.this.getHeaderViewsCount();
            mAdapter.onCellClicked(cellData, row);
        }
    });
    this.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            final UDLuaTable cellData = (UDLuaTable) view.getTag();
            final int row = position - LVListView.this.getHeaderViewsCount();
            return mAdapter.onCellLongClicked(cellData, row);
        }
    });
    this.setSelector(android.R.color.transparent);
    //设置divider颜色透明
    this.setDivider(new ColorDrawable(Color.TRANSPARENT));
    mLuaUserdata.initOnScrollCallback(this);
}
Also used : UDLuaTable(com.taobao.luaview.userdata.base.UDLuaTable) ColorDrawable(android.graphics.drawable.ColorDrawable) LVListViewAdapter(com.taobao.luaview.view.adapter.LVListViewAdapter) AdapterView(android.widget.AdapterView) UDBaseListView(com.taobao.luaview.userdata.list.UDBaseListView) UDView(com.taobao.luaview.userdata.ui.UDView) UDListView(com.taobao.luaview.userdata.list.UDListView) View(android.view.View) ILVListView(com.taobao.luaview.view.interfaces.ILVListView) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

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