use of com.tmall.wireless.tangram.dataparser.concrete.BaseCellBinderResolver in project Tangram-Android by alibaba.
the class BannerEntityCard method createCell.
private BaseCell createCell(@NonNull MVHelper resolver, @NonNull JSONObject cellData, boolean appended) {
if (cellData != null) {
BaseCell cell = null;
String cellType = cellData.optString(Card.KEY_TYPE);
if ((resolver != null && resolver.resolver().getViewClass(cellType) != null) || Utils.isCard(cellData)) {
if (resolver.resolver().isCompatibleType(cellType)) {
cell = Utils.newInstance(resolver.resolver().getCellClass(cellType));
// do not display when newInstance failed
if (cell == null) {
return null;
}
cell.serviceManager = serviceManager;
} else {
// do not support
if (Utils.isCard(cellData)) {
switch(cellType) {
case TangramBuilder.TYPE_CONTAINER_BANNER:
cell = new BannerEntityCard();
break;
}
if (cell != null) {
cell.serviceManager = serviceManager;
cell.nestedParent = this;
cell.parentId = id;
}
} else {
cell = new BaseCell(cellType);
cell.serviceManager = serviceManager;
cell.nestedParent = this;
cell.parentId = id;
}
}
if (cell != null) {
parseCell(resolver, cellData, cell, appended);
cell.setStringType(cellType);
}
return cell;
} else {
// support virtual view at layout
BaseCellBinderResolver componentBinderResolver = serviceManager.getService(BaseCellBinderResolver.class);
if (componentBinderResolver.has(cellType)) {
cell = new BaseCell(cellType);
cell.serviceManager = serviceManager;
cell.nestedParent = this;
cell.parentId = id;
parseCell(resolver, cellData, cell, appended);
cell.setStringType(cellType);
return cell;
} else {
return null;
}
}
}
return null;
}
use of com.tmall.wireless.tangram.dataparser.concrete.BaseCellBinderResolver in project Tangram-Android by alibaba.
the class LinearScrollEntityCard method createCell.
private BaseCell createCell(@NonNull MVHelper resolver, @NonNull JSONObject cellData, boolean appended) {
if (cellData != null) {
BaseCell cell = null;
String cellType = cellData.optString(Card.KEY_TYPE);
if ((resolver != null && resolver.resolver().getViewClass(cellType) != null) || Utils.isCard(cellData)) {
if (resolver.resolver().isCompatibleType(cellType)) {
cell = Utils.newInstance(resolver.resolver().getCellClass(cellType));
// do not display when newInstance failed
if (cell == null) {
return null;
}
cell.serviceManager = serviceManager;
} else {
cell = new BaseCell(cellType);
cell.serviceManager = serviceManager;
cell.nestedParent = this;
cell.parentId = id;
}
if (cell != null) {
parseCell(resolver, cellData, cell, appended);
cell.setStringType(cellType);
}
return cell;
} else {
// support virtual view at layout
BaseCellBinderResolver componentBinderResolver = serviceManager.getService(BaseCellBinderResolver.class);
if (componentBinderResolver.has(cellType)) {
cell = new BaseCell(cellType);
cell.serviceManager = serviceManager;
cell.nestedParent = this;
cell.parentId = id;
parseCell(resolver, cellData, cell, appended);
cell.setStringType(cellType);
return cell;
} else {
return null;
}
}
}
return null;
}
use of com.tmall.wireless.tangram.dataparser.concrete.BaseCellBinderResolver in project Tangram-Android by alibaba.
the class BaseTangramEngine method registerCell.
/**
* register cell after engine has been created
* @param type
* @param viewClz
* @param <V>
*/
public <V extends View> void registerCell(String type, @NonNull Class<V> viewClz) {
BaseCellBinderResolver baseCellBinderResolver = getService(BaseCellBinderResolver.class);
MVHelper mMVHelper = getService(MVHelper.class);
if (baseCellBinderResolver != null && mMVHelper != null && mMVHelper.resolver() != null) {
baseCellBinderResolver.register(type, new BaseCellBinder<>(viewClz, mMVHelper));
mMVHelper.resolver().register(type, viewClz);
}
}
use of com.tmall.wireless.tangram.dataparser.concrete.BaseCellBinderResolver in project Tangram-Android by alibaba.
the class BaseTangramEngine method registerVirtualViewTemplate.
/**
* set compiled binary data after engine has been setup, used when load template data dynamically
* @param type
* @param data
*/
public void registerVirtualViewTemplate(String type, byte[] data) {
BaseCellBinderResolver baseCellBinderResolver = getService(BaseCellBinderResolver.class);
BaseCardBinderResolver baseCardBinderResolver = getService(BaseCardBinderResolver.class);
if (baseCellBinderResolver != null && baseCardBinderResolver != null) {
CardResolver cardResolver = baseCardBinderResolver.getDelegate();
MVHelper mMVHelper = getService(MVHelper.class);
if (cardResolver != null && mMVHelper != null) {
baseCellBinderResolver.register(type, new BaseCellBinder(type, mMVHelper));
cardResolver.register(type, VVCard.class);
setVirtualViewTemplate(data);
}
}
}
Aggregations