use of com.tmall.wireless.tangram3.structure.BaseCell in project Tangram-Android by alibaba.
the class Card method addCells.
public void addCells(Card parent, int index, @Nullable List<BaseCell> cells) {
if (cells != null) {
int i = 0;
for (BaseCell cell : cells) {
addCellInternal(parent, index + i, cell, false);
i++;
}
}
adjustPendingCells(false);
if (mPlaceholderCell != null && this.mCells.contains(mPlaceholderCell))
this.mCells.remove(mPlaceholderCell);
if (requirePlaceholderCell()) {
this.mCells.add(mPlaceholderCell);
}
}
use of com.tmall.wireless.tangram3.structure.BaseCell in project Tangram-Android by alibaba.
the class Card method adjustPendingCells.
private void adjustPendingCells(boolean silent) {
if (mPendingCells.size() > 0) {
Collections.sort(mPendingCells, CellPositionComparator.COMPARATOR);
for (Iterator<BaseCell> iter = mPendingCells.iterator(); iter.hasNext(); ) {
BaseCell next = iter.next();
if (next.position < 0)
continue;
if (next.position < mCells.size()) {
mCells.add(next.position, next);
mInQueueCells.add(next);
iter.remove();
if (!silent)
next.added();
} else {
break;
}
}
}
if (mInQueueCells.size() > 0) {
// when do clean, the cell is already removed
Collections.sort(mInQueueCells, CellPositionComparator.REVERSE_COMPARATOR);
for (Iterator<BaseCell> iter = mInQueueCells.iterator(); iter.hasNext(); ) {
BaseCell next = iter.next();
if (next.position < 0)
continue;
if (next.position > mCells.size()) {
mPendingCells.add(next);
iter.remove();
} else {
break;
}
}
}
if (TangramBuilder.isPrintLog()) {
if (mPendingCells.size() > 0 && mInQueueCells.size() > 0) {
Preconditions.checkState(mPendingCells.get(0).position >= mInQueueCells.get(mInQueueCells.size() - 1).position, "Items in pendingQueue must have large position than Items in queue");
}
}
}
use of com.tmall.wireless.tangram3.structure.BaseCell in project Tangram-Android by alibaba.
the class Card method addCellInternal.
public boolean addCellInternal(@Nullable BaseCell cell, boolean silent) {
if (cell != null) {
cell.parentId = id;
cell.parent = this;
cell.serviceManager = serviceManager;
MVHelper mvHelper = getMVHelper();
if (mvHelper != null) {
if (mvHelper.isValid(cell, serviceManager)) {
if (cell.position >= 0 && !TextUtils.isEmpty(load)) {
cell.pos = cell.position;
mPendingCells.add(cell);
return true;
} else {
cell.pos = mHeader != null ? this.mCells.size() + 1 : this.mCells.size();
}
if (!silent && mIsActivated) {
// do cell added
cell.added();
}
this.mCells.add(cell);
if (mFooter != null) {
mFooter.pos = cell.pos + 1;
}
return true;
}
}
}
return false;
}
use of com.tmall.wireless.tangram3.structure.BaseCell in project Tangram-Android by alibaba.
the class SlideCard method storeCache.
private void storeCache() {
List<BaseCell> initCells = getCells();
BaseCell placeHolder = getPlaceholderCell();
if (initCells != null && !initCells.isEmpty()) {
TabContentCache tabContentCache = new TabContentCache(mIndex, initCells, placeHolder);
tabContentCache.id = id;
tabContentCache.loaded = loaded;
tabContentCache.loading = loading;
tabContentCache.page = page;
tabContentCache.hasMore = hasMore;
mCacheMap.put(mIndex, tabContentCache);
}
}
use of com.tmall.wireless.tangram3.structure.BaseCell in project Tangram-Android by alibaba.
the class OnePlusNCard method convertLayoutHelper.
@Nullable
@Override
public LayoutHelper convertLayoutHelper(@Nullable LayoutHelper oldHelper) {
OnePlusNLayoutHelper layoutHelper;
if (oldHelper instanceof OnePlusNLayoutHelper) {
layoutHelper = (OnePlusNLayoutHelper) oldHelper;
} else {
layoutHelper = new OnePlusNLayoutHelper();
}
layoutHelper.setItemCount(mCells.size());
if (mCells.size() == 1) {
BaseCell isHeader = mCells.get(0);
layoutHelper.setHasHeader(isHeader.gridDisplayType == BaseCell.GridDisplayType.block);
layoutHelper.setHasFooter(false);
} else if (mCells.size() >= 2) {
BaseCell isHeader = mCells.get(0);
layoutHelper.setHasHeader(isHeader.gridDisplayType == BaseCell.GridDisplayType.block);
BaseCell isFooter = mCells.get(mCells.size() - 1);
layoutHelper.setHasFooter(isFooter.gridDisplayType == BaseCell.GridDisplayType.block);
}
if (style instanceof ColumnStyle) {
ColumnStyle columnStyle = (ColumnStyle) style;
if (columnStyle.cols != null && columnStyle.cols.length > 0)
layoutHelper.setColWeights(columnStyle.cols);
else
layoutHelper.setColWeights(EMPTY_WEIGHTS);
if (!Float.isNaN(style.aspectRatio)) {
layoutHelper.setAspectRatio(style.aspectRatio);
}
if (columnStyle.rows != null && columnStyle.rows.length > 0) {
layoutHelper.setRowWeight(columnStyle.rows[0]);
}
layoutHelper.setBgColor(columnStyle.bgColor);
layoutHelper.setMargin(style.margin[Style.MARGIN_LEFT_INDEX], style.margin[Style.MARGIN_TOP_INDEX], style.margin[Style.MARGIN_RIGHT_INDEX], style.margin[Style.MARGIN_BOTTOM_INDEX]);
layoutHelper.setPadding(style.padding[Style.MARGIN_LEFT_INDEX], style.padding[Style.MARGIN_TOP_INDEX], style.padding[Style.MARGIN_RIGHT_INDEX], style.padding[Style.MARGIN_BOTTOM_INDEX]);
}
return layoutHelper;
}
Aggregations