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