[Implementation] Implemented possibility to delay onCreated() callback.
Delayed initialization of invisible tabs to improve launch time.
Change-Id: I7fad05d8b3029304c1b5a63b591a7064d5d47a2c
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
#define PREFERENCE_KEY_LAST_TAB "last_tab"
#define PREFERENCE_KEY_LOGS_FILTER "logs_filter"
+#define TAB_CREATE_DELAY 1.0
+
using Contacts::List::ListView;
using Logs::List::LogsView;
using Phone::Dialer::DialerView;
m_Tabs[TabContacts] = new ListView();
for (auto &&tab : m_Tabs) {
+ tab->setCreateTimer(TAB_CREATE_DELAY);
m_Navigator->addView(tab);
}
}
Evas_Object *create(Evas_Object *parent);
/**
+ * @brief Set delay between onCreate() and onCreated().
+ * @param[in] time Delay time
+ */
+ void setCreateTimer(double time);
+
+ /**
+ * @brief Remove delay between onCreate() and onCreated().
+ * @remark If timer is currently running onCreated() will be called immediately.
+ */
+ void resetCreateTimer();
+
+ /**
* @return Control type.
*/
int getType() const;
int m_Type;
Evas_Object *m_Object;
+ Ecore_Timer *m_CreateTimer;
};
template <typename ControlType>
using namespace Ui;
Control::Control(int type)
- : m_Type(type), m_Object(nullptr)
+ : m_Type(type), m_Object(nullptr), m_CreateTimer(nullptr)
{
}
Control::~Control()
{
+ if (m_CreateTimer) {
+ ecore_timer_del(m_CreateTimer);
+ }
+
destroyEvasObject();
}
{
if (!m_Object) {
setEvasObject(onCreate(parent));
- onCreated();
+ if (!m_CreateTimer) {
+ onCreated();
+ } else {
+ ecore_timer_thaw(m_CreateTimer);
+ }
}
return m_Object;
}
+void Control::setCreateTimer(double time)
+{
+ if (m_CreateTimer) {
+ ecore_timer_del(m_CreateTimer);
+ }
+
+ m_CreateTimer = ecore_timer_add(time, [](void *data) {
+ Control *control = (Control *) data;
+ control->m_CreateTimer = nullptr;
+ control->onCreated();
+ return EINA_FALSE;
+ }, this);
+ ecore_timer_freeze(m_CreateTimer);
+}
+
+void Control::resetCreateTimer()
+{
+ if (m_CreateTimer) {
+ ecore_timer_del(m_CreateTimer);
+ m_CreateTimer = nullptr;
+
+ if (m_Object) {
+ onCreated();
+ }
+ }
+}
+
int Control::getType() const
{
return m_Type;
{
m_IsCurrent = isCurrent;
if (m_IsCurrent) {
+ resetCreateTimer();
onRotation(degree);
}
Ui::GenGroupItem *createListSection(SectionId sectionId);
void fillPersonList();
+ void fillLayout();
Ui::Genlist *createGenlist(Evas_Object *parent);
Evas_Object *createEmptyLayout(Evas_Object *parent);
void updateEmptyLayout();
Evas_Object *ListView::onCreate(Evas_Object *parent)
{
- Evas_Object *layout = elm_layout_add(parent);
- elm_layout_theme_set(layout, "layout", "application", "fastscroll");
-
- m_Box = elm_box_add(layout);
- m_NoContent = createEmptyLayout(m_Box);
- m_Genlist = createGenlist(m_Box);
- elm_box_pack_end(m_Box, m_Genlist->getEvasObject());
-
- elm_object_part_content_set(layout, "elm.swallow.content", m_Box);
- elm_object_part_content_set(layout, "elm.swallow.fastscroll", createIndex(layout));
-
- m_SearchItem = createSearchItem();
- m_AddButton = createAddButton(layout);
-
- return layout;
+ return elm_layout_add(parent);
}
void ListView::onCreated()
{
+ fillLayout();
fillPersonList();
updateSections();
updateEmptyState();
}
}
+void ListView::fillLayout()
+{
+ Evas_Object *layout = getEvasObject();
+ elm_layout_theme_set(layout, "layout", "application", "fastscroll");
+
+ m_Index = createIndex(layout);
+ elm_object_part_content_set(layout, "elm.swallow.fastscroll", m_Index);
+
+ m_Box = elm_box_add(layout);
+ elm_object_part_content_set(layout, "elm.swallow.content", m_Box);
+
+ m_NoContent = createEmptyLayout(m_Box);
+ m_Genlist = createGenlist(m_Box);
+ elm_box_pack_end(m_Box, m_Genlist->getEvasObject());
+
+ m_SearchItem = createSearchItem();
+ m_AddButton = createAddButton(layout);
+}
+
Ui::Genlist *ListView::createGenlist(Evas_Object *parent)
{
Ui::Genlist *genlist = new Ui::Genlist();
- genlist->create(parent);
+ Evas_Object *obj = genlist->create(parent);
- evas_object_size_hint_weight_set(genlist->getEvasObject(), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(genlist->getEvasObject(), EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_show(genlist->getEvasObject());
+ evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(obj);
return genlist;
}
Evas_Object *ListView::createIndex(Evas_Object *parent)
{
- m_Index = elm_index_add(parent);
- elm_index_autohide_disabled_set(m_Index, EINA_TRUE);
- elm_index_omit_enabled_set(m_Index, EINA_TRUE);
+ Evas_Object *index = elm_index_add(parent);
+ elm_index_autohide_disabled_set(index, EINA_TRUE);
+ elm_index_omit_enabled_set(index, EINA_TRUE);
- evas_object_smart_callback_add(m_Index, "changed",
+ evas_object_smart_callback_add(index, "changed",
(Evas_Smart_Cb) makeCallback(&ListView::onIndexChanged), this);
- evas_object_smart_callback_add(m_Index, "selected",
+ evas_object_smart_callback_add(index, "selected",
(Evas_Smart_Cb) makeCallback(&ListView::onIndexSelected), this);
- return m_Index;
+ return index;
}
void ListView::updateIndex()
void LogsView::onCreated()
{
m_LogProvider.setInsertCallback(std::bind(&LogsView::onLogInserted, this, _1));
-
fillLayout();
}
virtual void onNavigation(bool isCurrentView) override;
virtual void onMenuPressed() override;
+ void fillLayout();
Evas_Object *createEntry(Evas_Object *parent);
Evas_Object *createSearchControl(Evas_Object *parent);
Evas_Object *createKeypad(Evas_Object *parent);
makeCallbackWithLastParam(&DialerView::onDbChanged), this);
contacts_db_add_changed_cb(_contacts_phone_log._uri,
makeCallbackWithLastParam(&DialerView::onDbChanged), this);
+
+ fillLayout();
}
Evas_Object *DialerView::onCreate(Evas_Object *parent)
{
- elm_theme_extension_add(nullptr, App::getResourcePath(APPS_COMMON_BUTTONS_EDJ).c_str());
-
- Evas_Object *layout = elm_layout_add(parent);
- Eina_Bool res = elm_layout_file_set(layout, layoutFilePath.c_str(), GROUP_DIALER);
- WARN_IF(res != EINA_TRUE, "elm_layout_file_set() failed");
-
- elm_object_part_content_set(layout, PART_SWALLOW_ENTRY, createEntry(layout));
- elm_object_part_content_set(layout, PART_SWALLOW_PREDICTIVE, createSearchControl(layout));
- elm_object_part_content_set(layout, PART_SWALLOW_KEYPAD, createKeypad(layout));
- elm_object_part_content_set(layout, PART_SWALLOW_CALL, createCallButton(layout));
- elm_object_part_content_set(layout, PART_SWALLOW_BACKSPACE, createBackspaceButton(layout));
-
- return layout;
+ return elm_layout_add(parent);
}
void DialerView::setNumber(const std::string &number)
menu->show();
}
+void DialerView::fillLayout()
+{
+ Evas_Object *layout = getEvasObject();
+ Eina_Bool res = elm_layout_file_set(layout, layoutFilePath.c_str(), GROUP_DIALER);
+ WARN_IF(res != EINA_TRUE, "elm_layout_file_set() failed");
+
+ elm_object_part_content_set(layout, PART_SWALLOW_ENTRY, createEntry(layout));
+ elm_object_part_content_set(layout, PART_SWALLOW_PREDICTIVE, createSearchControl(layout));
+ elm_object_part_content_set(layout, PART_SWALLOW_KEYPAD, createKeypad(layout));
+ elm_object_part_content_set(layout, PART_SWALLOW_CALL, createCallButton(layout));
+ elm_object_part_content_set(layout, PART_SWALLOW_BACKSPACE, createBackspaceButton(layout));
+}
+
Evas_Object *DialerView::createEntry(Evas_Object *parent)
{
m_Entry = new KeypadEntry();
Evas_Object *DialerView::createCallButton(Evas_Object *parent)
{
+ elm_theme_extension_add(nullptr, App::getResourcePath(APPS_COMMON_BUTTONS_EDJ).c_str());
+
Evas_Object *button = elm_button_add(parent);
elm_object_style_set(button, BUTTON_STYLE_CUSTOM_CIRCLE);
evas_object_smart_callback_add(button, "clicked",