use of com.tmall.wireless.tangram.structure.entitycard.LinearScrollEntityCard in project Tangram-Android by alibaba.
the class Card method createCell.
protected BaseCell createCell(@NonNull MVHelper resolver, @Nullable JSONObject cellData, boolean appended) {
if (cellData != null) {
BaseCell cell = null;
String cellType = cellData.optString(Card.KEY_TYPE);
if ((getMVHelper() != null && getMVHelper().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;
// ensure service manager
cell.serviceManager = serviceManager;
} else {
if (Utils.isCard(cellData)) {
switch(cellType) {
case TangramBuilder.TYPE_CONTAINER_FLOW:
case TangramBuilder.TYPE_CONTAINER_1C_FLOW:
case TangramBuilder.TYPE_CONTAINER_2C_FLOW:
case TangramBuilder.TYPE_CONTAINER_3C_FLOW:
case TangramBuilder.TYPE_CONTAINER_4C_FLOW:
case TangramBuilder.TYPE_CONTAINER_5C_FLOW:
CardResolver cardResolver = serviceManager.getService(CardResolver.class);
Card gridCard = cardResolver.create(cellType);
gridCard.serviceManager = serviceManager;
gridCard.parseWith(cellData, resolver);
addChildCard(gridCard);
break;
case TangramBuilder.TYPE_CONTAINER_BANNER:
cell = new BannerEntityCard();
break;
case TangramBuilder.TYPE_CONTAINER_SCROLL:
cell = new LinearScrollEntityCard();
break;
}
if (cell != null) {
cell.serviceManager = serviceManager;
cell.parent = this;
cell.parentId = id;
} else {
return null;
}
} else {
cell = new BaseCell(cellType);
cell.serviceManager = serviceManager;
cell.parent = this;
cell.parentId = id;
}
}
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.parent = 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.structure.entitycard.LinearScrollEntityCard in project Tangram-Android by alibaba.
the class PojoDataParser method createCell.
protected BaseCell createCell(@NonNull MVHelper resolver, @Nullable JSONObject cellData, ServiceManager serviceManager) {
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 {
if (Utils.isCard(cellData)) {
switch(cellType) {
// TODO support parse inline flow card
case TangramBuilder.TYPE_CONTAINER_BANNER:
cell = new BannerEntityCard();
break;
case TangramBuilder.TYPE_CONTAINER_SCROLL:
cell = new LinearScrollEntityCard();
break;
}
if (cell != null) {
cell.serviceManager = serviceManager;
}
} else {
cell = new BaseCell(cellType);
cell.serviceManager = serviceManager;
}
}
if (cell != null) {
resolver.parseCell(resolver, cell, cellData);
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;
resolver.parseCell(resolver, cell, cellData);
cell.setStringType(cellType);
return cell;
} else {
return null;
}
}
}
return null;
}
Aggregations