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 SecondViewController::tableViewDidSelectRowAtIndexPath(CATableView* table, unsigned int section, unsigned int row) { static bool s = true; CAWindow* window = CAApplication::getApplication()->getRootWindow(); CADrawerController* drawer = (CADrawerController*)window->getRootViewController(); CANavigationController* nav = (CANavigationController*)drawer->getRightViewController(); CATabBarController* tab = (CATabBarController*)nav->getViewControllerAtIndex(0); nav->setNavigationBarHidden(!s, true); tab->setTabBarHidden(!s, true); s = !s; return; }
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(); } }
bool RootWindow::init() { if (!CAWindow::init()) { return false; } CAApplication::getApplication()->setNotificationView(CAView::createWithFrame(this->getBounds(), CAColor_green)); CAVector<CAViewController*> controllerVec; m_home = new MainViewController(); if (m_home) { m_home->setTabBarItem(CATabBarItem::create(unicode_to_utf8(mainBar[0]), CAImage::create("main/bar_0.png"),CAImage::create("main/bar_pre_0.png"))); m_home->init(); m_home->autorelease(); controllerVec.pushBack(m_home); } m_session = new SessionsViewController(); if (m_session) { m_session->init(); m_session->autorelease(); m_session->setTabBarItem(CATabBarItem::create(unicode_to_utf8(mainBar[1]), CAImage::create("main/bar_1.png"),CAImage::create("main/bar_pre_1.png"))); controllerVec.pushBack(m_session); } m_my = new MyStatusViewController(); if (m_my) { m_my->setTabBarItem(CATabBarItem::create(unicode_to_utf8(mainBar[2]), CAImage::create("main/bar_2.png"),CAImage::create("main/bar_pre_2.png"))); m_my->init(); m_my->autorelease(); controllerVec.pushBack(m_my); } CATabBarController* tabBarController = new CATabBarController(); tabBarController->initWithViewControllers(controllerVec); tabBarController->setTabBarSelectedBackgroundColor(CAColor_clear); tabBarController->setTabBarTitleColorForSelected(CAColor_white); tabBarController->setTabBarBackgroundImage(CAImage::create("common/sky_bg.png")); /* CANavigationBarItem* temp_nav = CANavigationBarItem::create(""); temp_nav->setNagigationBarHidden(true); tabBarController->setScrollEnabled(false); tabBarController->setNavigationBarItem(temp_nav); tabBarController->setTabBarTitleColorForSelected(CAColor_white); tabBarController->autorelease(); */ m_pRootNavigationController = new CANavigationController(); m_pRootNavigationController->initWithRootViewController(tabBarController); m_pRootNavigationController->setNavigationBarBackgroundImage(CAImage::create("common/sky_bg.png")); m_pRootNavigationController->setNavigationBarHidden(true, false); m_pRootNavigationController->setScrollEnabled(false); FUser user = FUserManager::sharedFUserManager()->onLineUser(); if (user.loginname.length() == 0) { LoginViewController* _viewController = new LoginViewController(); _viewController->init(); this->setRootViewController(_viewController); _viewController->release(); } else { FDataManager::getInstance()->setUserId(user.uid); this->setRootViewController(m_pRootNavigationController); } CAApplication::getApplication()->setNotificationView(NULL); return true; }