Esempio 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
    {

    }
    
}
Esempio n. 2
0
void CDNewsViewController::onRequestFinished(const HttpResponseStatus& status, const CSJson::Value& json)
{
    if (status == HttpResponseSucceed)
    {
        const CSJson::Value& value = json["result"];
        int length = value.size();
        m_msg.clear();
        m_page.clear();
        for (int i=0; i<3; i++) {
            newsPage temp_page;
            temp_page.m_title   = value[i]["title"].asString();
            temp_page.m_pic     = value[i]["image"].asString();
            temp_page.m_url     = value[i]["url"].asString();
            m_page.push_back(temp_page);
        }
        for (int index = 3; index < length; index++)
        {
            newsMsg temp_msg;
            temp_msg.m_title = value[index]["title"].asString();
            temp_msg.m_desc = value[index]["desc"].asString();
            temp_msg.m_url = value[index]["url"].asString();
            temp_msg.m_imageUrl = value[index]["image"].asString();
            m_msg.push_back(temp_msg);
        }

    }
    
    CATabBarController* tabBarController = this->getTabBarController();
    
    for (int i=0; i<5; i++)
    {
        CDNewsViewController* catalog = dynamic_cast<CDNewsViewController*>(tabBarController->getViewControllerAtIndex(i));
        if (catalog && catalog->p_pLoading)
        {
            catalog->p_pLoading->stopAnimating();
        }
    }
    
    if (p_TableView)
    {
        p_TableView->reloadData();
    }
}