CACollectionViewCell* DMClassifCatalogViewController::collectionCellAtIndex(CACollectionView *collectionView, const CCSize& cellSize, unsigned int section, unsigned int row, unsigned int item)
{
    DMCatalogCollectionCell* cell = cell = (DMCatalogCollectionCell*)collectionView->dequeueReusableCellWithIdentifier("ID");
    if (cell == NULL)
    {
        cell = new DMCatalogCollectionCell();
        cell->init("ID", cellSize);
        cell->autorelease();
    }
    
    if (row * m_uiItems + item < m_vDatas.size())
    {
        const DMBriefInfo& info = m_vDatas.at(row * m_uiItems + item);
        
        cell->setBookNameText(info.title);
        cell->setInfoText(info.subtitle);
        cell->setBookImageFromUrl(info.cover);
    }
    else
    {
        cell->setVisible(false);
    }
    
    return cell;
}
Esempio n. 2
0
CACollectionViewCell* DMCatalogController::collectionCellAtIndex(CACollectionView *collectionView, const CCSize& cellSize, unsigned int section, unsigned int row, unsigned int item)
{
    if (row * m_uiItems + item + 1 >= m_mvData[m_sTitle].size())
    {
        return NULL;
    }
    
    DMCatalogCollectionCell* cell = cell = (DMCatalogCollectionCell*)collectionView->dequeueReusableCellWithIdentifier("ID");
    if (cell == NULL)
    {
        cell = new DMCatalogCollectionCell();
        cell->init("ID", cellSize);
        cell->autorelease();
    }

    if (m_mvData.count(m_sTitle) > 0)
    {
        const DMBriefInfo& info = m_mvData[m_sTitle].at(row * m_uiItems + item + 1);
        
        cell->setBookNameText(info.title);
        cell->setInfoText(info.subtitle);
        cell->setBookImageFromUrl(info.cover);
    }
    
    return cell;
}