use of com.tmall.wireless.tangram3.dataparser.concrete.Card in project Tangram-Android by alibaba.
the class TangramEngine method updateCard.
public void updateCard(Card card) {
if (card != null && mGroupBasicAdapter != null) {
Range<Integer> cardRange = mGroupBasicAdapter.getCardRange(card);
for (int i = cardRange.getLower(); i < cardRange.getUpper(); i++) {
BaseCell cell = mGroupBasicAdapter.getItemByPosition(i);
cell.extras.put("_flag_invalidate_", true);
}
mGroupBasicAdapter.notifyItemRangeChanged(cardRange.getLower(), cardRange.getUpper());
}
}
use of com.tmall.wireless.tangram3.dataparser.concrete.Card in project Tangram-Android by alibaba.
the class BaseTangramEngine method findGroups.
@SuppressWarnings("unchecked")
@NonNull
public List<Card> findGroups(final Predicate<Card> predicate) {
Preconditions.checkState(mGroupBasicAdapter != null, "Must call bindView() first");
List<Card> groups = (List<Card>) mGroupBasicAdapter.getGroups();
if (predicate == null) {
return groups;
}
List<Card> rs = new LinkedList<Card>();
for (Card g : groups) {
if (predicate.isMatch(g)) {
rs.add(g);
}
}
return rs;
}
use of com.tmall.wireless.tangram3.dataparser.concrete.Card in project Tangram-Android by alibaba.
the class PojoDataParser method parseGroup.
@NonNull
@Override
public List<Card> parseGroup(@Nullable JSONArray data, @NonNull final ServiceManager serviceManager) {
if (data == null) {
return new ArrayList<>();
}
try {
checkCardResolverAndMVHelper(serviceManager);
final int size = data.size();
final List<Card> result = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
JSONObject cardData = data.getJSONObject(i);
final Card card = parseSingleGroup(cardData, serviceManager);
if (card instanceof IDelegateCard) {
List<Card> cards = ((IDelegateCard) card).getCards(new CardResolver() {
@Override
public Card create(String type) {
Card c = cardResolver.create(type);
c.serviceManager = serviceManager;
c.id = card.id;
c.setStringType(type);
c.rowId = card.rowId;
return c;
}
});
for (Card c : cards) {
if (c.isValid()) {
result.add(c);
}
}
} else {
result.add(card);
}
}
mvHelper.resolver().setCards(result);
return result;
} catch (Exception e) {
if (errorSupport == null) {
errorSupport = serviceManager.getService(InternalErrorSupport.class);
}
HashMap<String, Object> params = new HashMap<>();
params.put("exception", Log.getStackTraceString(e));
errorSupport.onError(InternalErrorSupport.ERROR_PARSE_CARDS_ERROR, "Parse group error.", params);
e.printStackTrace();
}
return null;
}
use of com.tmall.wireless.tangram3.dataparser.concrete.Card in project Tangram-Android by alibaba.
the class PojoDataParser method parseCard.
protected void parseCard(Card card, JSONObject data, ServiceManager serviceManager, Map<String, ComponentInfo> componentInfoMap) {
card.id = data.getString(KEY_ID);
if (card.id == null) {
card.id = "";
}
// parsing header
JSONObject header = data.getJSONObject(KEY_HEADER);
BaseCell headerCell = parseSingleComponent(header, card, serviceManager, componentInfoMap);
parseHeaderCell(headerCell, card);
// parsing body
JSONArray componentArray = data.getJSONArray(KEY_ITEMS);
if (componentArray != null) {
final int cellLength = componentArray.size();
for (int i = 0; i < cellLength; i++) {
final JSONObject cellData = componentArray.getJSONObject(i);
parseSingleComponent(cellData, card, card.serviceManager, componentInfoMap);
}
}
// parsing footer
JSONObject footer = data.getJSONObject(KEY_FOOTER);
BaseCell footerCell = parseSingleComponent(footer, card, serviceManager, componentInfoMap);
parseFooterCell(footerCell, card);
}
use of com.tmall.wireless.tangram3.dataparser.concrete.Card in project Tangram-Android by alibaba.
the class PojoDataParser method parseHeaderCell.
protected void parseHeaderCell(BaseCell headerCell, Card card) {
card.mHeader = headerCell;
if (card instanceof GridCard) {
GridCard gridCard = (GridCard) card;
gridCard.ensureBlock(card.mHeader);
} else if (card instanceof OnePlusNCard) {
OnePlusNCard onePlusNCard = (OnePlusNCard) card;
onePlusNCard.ensureBlock(card.mHeader);
}
}
Aggregations