From 791f88a7ed0e97d00f21830af43fc424234f3c3f Mon Sep 17 00:00:00 2001 From: Dmytro Dragan Date: Fri, 12 Aug 2016 15:52:27 +0300 Subject: [PATCH] TizenRefApp-6903 Startup performance optimization Change-Id: I18e9186ed1a6ec18f0370b0882ceb054d24ea064 Signed-off-by: Dmytro Dragan --- src/Common/MsgEngine/src/MsgEngine.cpp | 7 +-- .../inc/SystemSettingsManager.h | 1 + .../src/SystemSettingsManager.cpp | 16 +++-- src/MsgThread/Controller/inc/MsgThread.h | 5 +- src/MsgThread/Controller/src/MsgThread.cpp | 72 +++++++++++++++------- 5 files changed, 69 insertions(+), 32 deletions(-) diff --git a/src/Common/MsgEngine/src/MsgEngine.cpp b/src/Common/MsgEngine/src/MsgEngine.cpp index 9ac27c4..3ea83c0 100644 --- a/src/Common/MsgEngine/src/MsgEngine.cpp +++ b/src/Common/MsgEngine/src/MsgEngine.cpp @@ -60,7 +60,6 @@ int MsgEngine::openService() m_Storage.reset(new MsgStoragePrivate(m_MsgHandle)); m_Transport.reset(new MsgTransportPrivate(m_MsgHandle)); - m_Settings.reset(new MsgSettingsPrivate(m_MsgHandle)); m_Composer.reset(new MsgComposerPrivate()); #else // TODO: impl for public API @@ -133,14 +132,14 @@ const MsgTransport &MsgEngine::getTransport() const MsgSettings &MsgEngine::getSettings() { - assert(m_Settings.get()); + if(!m_Settings.get()) + m_Settings.reset(new MsgSettingsPrivate(m_MsgHandle)); return *m_Settings; } const MsgSettings &MsgEngine::getSettings() const { - assert(m_Settings.get()); - return *m_Settings; + return const_cast(this)->getSettings(); } MsgComposer &MsgEngine::getComposer() diff --git a/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h b/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h index 8b0c706..bf05c7b 100644 --- a/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h +++ b/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h @@ -72,6 +72,7 @@ namespace Msg void onTimeFormatChanged(); void onLanguageChanged(); + void prepareTel(); private: std::vector m_Listeners; diff --git a/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp b/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp index c174b7e..7aadd6f 100644 --- a/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp +++ b/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp @@ -31,16 +31,22 @@ using namespace Msg; SystemSettingsManager::SystemSettingsManager() : m_TelHandleList() { - int err = telephony_init(&m_TelHandleList); - MSG_LOG("telephony_init = ", err); - system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, CALLBACK(onTimeFormatChanged), this); system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, CALLBACK(onLanguageChanged), this); } SystemSettingsManager::~SystemSettingsManager() { - telephony_deinit(&m_TelHandleList); + if(m_TelHandleList.handle != nullptr) + telephony_deinit(&m_TelHandleList); +} + +void SystemSettingsManager::prepareTel() +{ + if(m_TelHandleList.handle != nullptr) + return; + int err = telephony_init(&m_TelHandleList); + MSG_LOG("telephony_init = ", err); } void SystemSettingsManager::addListener(ISystemSettingsManager &l) @@ -60,6 +66,7 @@ void SystemSettingsManager::removeListener(ISystemSettingsManager&l) bool SystemSettingsManager::isSimInserted() const { bool res = false; + const_cast(this)->prepareTel(); if(m_TelHandleList.count > 0) { @@ -76,6 +83,7 @@ bool SystemSettingsManager::isSimInserted() const bool SystemSettingsManager::isSimActive() const { bool res = false; + const_cast(this)->prepareTel(); if(m_TelHandleList.count > 0) { diff --git a/src/MsgThread/Controller/inc/MsgThread.h b/src/MsgThread/Controller/inc/MsgThread.h index 0319cca..d29475b 100644 --- a/src/MsgThread/Controller/inc/MsgThread.h +++ b/src/MsgThread/Controller/inc/MsgThread.h @@ -111,7 +111,10 @@ namespace Msg void search(const std::string &searchWord); // Search: - Evas_Object *createSearchPanel(Evas_Object *parent); + void prepareSearchPanel(); + void prepareSearchList(); + void prepareNoContentLayout(); + void prepareThreadList(); void setSearchMode(bool value); private: diff --git a/src/MsgThread/Controller/src/MsgThread.cpp b/src/MsgThread/Controller/src/MsgThread.cpp index d9d0e84..7dc15ba 100644 --- a/src/MsgThread/Controller/src/MsgThread.cpp +++ b/src/MsgThread/Controller/src/MsgThread.cpp @@ -42,20 +42,8 @@ MsgThread::MsgThread(NaviFrameController &parent) m_pFloatingBtn->setListener(this); m_pLayout->setFloatingButton(*m_pFloatingBtn); - m_pNoContent = new NoContentLayout(*m_pLayout); - m_pNoContent->show(); - - m_pThreadList = new ThreadList(*m_pLayout, getApp()); - m_pThreadList->setListener(this); - m_pThreadList->show(); - - m_pSearchList = new ThreadSearchList(*m_pLayout, getApp()); - m_pSearchList->setListener(this); - m_pSearchList->show(); - - m_pLayout->setNoContent(*m_pNoContent); - m_pLayout->setList(*m_pThreadList); - m_pLayout->setSearchList(*m_pSearchList); + prepareThreadList(); + prepareNoContentLayout(); getApp().getSysSettingsManager().addListener(*this); setMode(NormalMode); @@ -66,19 +54,53 @@ MsgThread::~MsgThread() getApp().getSysSettingsManager().removeListener(*this); } -Evas_Object *MsgThread::createSearchPanel(Evas_Object *parent) +void MsgThread::prepareSearchPanel() +{ + if(!m_pSearchPanel) + { + m_pSearchPanel = new MsgThreadSearchPanel(*m_pLayout); + m_pSearchPanel->setListener(this); + m_pSearchPanel->setGuideText("Search"); + getNaviBar().setSearch(*m_pSearchPanel); + } +} + +void MsgThread::prepareSearchList() +{ + if(!m_pSearchList) + { + m_pSearchList = new ThreadSearchList(*m_pLayout, getApp()); + m_pSearchList->setListener(this); + m_pSearchList->show(); + m_pLayout->setSearchList(*m_pSearchList); + } +} + +void MsgThread::prepareNoContentLayout() +{ + if(!m_pNoContent) + { + m_pNoContent = new NoContentLayout(*m_pLayout); + m_pNoContent->show(); + m_pLayout->setNoContent(*m_pNoContent); + } +} + +void MsgThread::prepareThreadList() { - m_pSearchPanel = new MsgThreadSearchPanel(*m_pLayout); - m_pSearchPanel->setListener(this); - m_pSearchPanel->setGuideText("Search"); - return *m_pSearchPanel; + if(!m_pThreadList) + { + m_pThreadList = new ThreadList(*m_pLayout, getApp()); + m_pThreadList->setListener(this); + m_pThreadList->show(); + m_pLayout->setList(*m_pThreadList); + } } void MsgThread::onAttached(ViewItem &item) { FrameController::onAttached(item); getNaviBar().setColor(NaviBar::NaviBlueColorId); - getNaviBar().setSearch(createSearchPanel(getNaviBar())); setHwButtonListener(*m_pLayout, this); setContent(*m_pLayout); } @@ -200,6 +222,8 @@ void MsgThread::setSearchMode(bool value) getNaviBar().showButton(NaviPrevButtonId, value); if(value) { + prepareSearchList(); + prepareSearchPanel(); m_Mode = SearchMode; m_pSearchPanel->clearEntry(); m_pSearchList->clear(); @@ -209,12 +233,14 @@ void MsgThread::setSearchMode(bool value) } else { - m_pSearchList->cancelSearch(); + if(m_pSearchList) + m_pSearchList->cancelSearch(); getNaviBar().hideSearch(); } update(); - m_pSearchPanel->setEntryFocus(value); + if(m_pSearchPanel) + m_pSearchPanel->setEntryFocus(value); } void MsgThread::update() @@ -256,7 +282,7 @@ void MsgThread::updateSelectItemsTitle() void MsgThread::search(const std::string &searchWord) { - if(m_Mode == SearchMode) + if(m_Mode == SearchMode && m_pSearchList) m_pSearchList->requestSearch(searchWord); } -- 2.7.4