Exemplo n.º 1
0
void DMCatalogController::onRequestFinished(const HttpResponseStatus& status, const CSJson::Value& json)
{
    if (status == HttpResponseSucceed)
    {
        m_mvData.clear();

        for (int i=0; i<SUBSCRIBE_SECTION_COUNT; i++)
        {
            std::vector<DMBriefInfo> vec;
            const CSJson::Value& info = json[catalogTitleTag[i]];
            const CSJson::Value& headlines = info["headlines"];
            vec.push_back(DMBriefInfo(headlines["id"].asString(),
                                      headlines["cover"].asString(),
                                      headlines["title"].asString(),
                                      headlines["subtitle"].asString()));
            const CSJson::Value& episode = info["episode"];
            for (int j=0; j<episode.size(); j++)
            {
                const CSJson::Value& value = episode[j];
                vec.push_back(DMBriefInfo(value["id"].asString(),
                                          value["cover"].asString(),
                                          value["title"].asString(),
                                          value["last_update_chapter_name"].asString()));
            }
            
            m_mvData[catalogTitleTag[i]]= vec;
        }
        if (m_pCollectionView)
        {
            m_pCollectionView->reloadData();
            const DMBriefInfo& info = m_mvData[m_sTitle].front();
            m_pHeaderLabel->setText("《" + info.title + "》" + info.subtitle);
            m_pHeaderImageView->setUrl(info.cover);
        }
        
        CATabBarController* tabBarController = this->getTabBarController();
        
        for (int i=0; i<6; i++)
        {
            DMCatalogController* catalog = dynamic_cast<DMCatalogController*>(tabBarController->getViewControllerAtIndex(i));
            if (catalog && catalog->m_pLoading)
            {
                catalog->m_pLoading->stopAnimating();
            }
        }
    }
    else
    {

    }
    
}
void DMClassifCatalogViewController::onRequestFinished(const HttpResponseStatus& status, const CSJson::Value& json)
{
    if (status == HttpResponseSucceed)
    {
        if (!m_bFooterRefreshing)
        {
            m_vDatas.clear();
        }
        
        const CSJson::Value& info = json["data"];
        
        for (int i=0; i<info.size(); i++)
        {
            const CSJson::Value& value = info[i];
            m_vDatas.push_back(DMBriefInfo(value["id"].asString(),
                                      value["cover"].asString(),
                                      value["title"].asString(),
                                      value["last_update_chapter_name"].asString()));
        }

        
    }
    else
    {
        
    }
    
    do
    {
        CC_BREAK_IF(m_pLoading == NULL);
        if (m_pLoading->isAnimating())
        {
            m_pLoading->stopAnimating();
        }
        else
        {
            m_pCollectionView->reloadData();
        }
    }
    while (0);
}