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;
}
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();
}
}
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);
}
}
}
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;
}
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;
}
Aggregations