TSAM-12468 Text display slowly 53/109053/3 submit/tizen_3.0/20170106.152409
authorSergei Kobec <s.kobec@samsung.com>
Fri, 6 Jan 2017 15:14:22 +0000 (17:14 +0200)
committerSergei Kobec <s.kobec@samsung.com>
Fri, 6 Jan 2017 15:14:22 +0000 (17:14 +0200)
Change-Id: I72c24016b6511d2bd16b126656274f0ad7ac930b
Signed-off-by: Sergei Kobec <s.kobec@samsung.com>
lib-contacts/inc/Contacts/List/SearchField.h
lib-contacts/src/Contacts/List/SearchField.cpp

index 54a0d86..77ee801 100644 (file)
@@ -18,6 +18,7 @@
 #define CONTACTS_LIST_CONTACT_SEARCH_FIELD_H
 
 #include "Ui/Editfield.h"
+#include <Ecore.h>
 #include <functional>
 #include <string>
 
@@ -31,6 +32,14 @@ namespace Contacts
                class SearchField : public Ui::Editfield
                {
                public:
+                       SearchField();
+                       ~SearchField();
+
+                       SearchField(const SearchField &) = delete;
+                       SearchField(SearchField &&) = delete;
+                       SearchField& operator=(const SearchField &) = delete;
+                       SearchField& operator=(SearchField &&) = delete;
+
                        /**
                         * @brief Entry change callback.
                         */
@@ -57,9 +66,11 @@ namespace Contacts
                        void updateGuideText();
                        void onDonePressed(Evas_Object *entry, void *eventInfo);
                        void onChanged(Evas_Object *entry, void *eventInfo);
+                       Eina_Bool runOnChanged();
 
                        ChangeCallback m_OnChanged;
                        std::string m_Text;
+                       Ecore_Timer *m_ChangedTimer;
                };
        }
 }
index 36d84ff..a0c178c 100644 (file)
 
 using namespace Contacts::List;
 
+SearchField::SearchField()
+       : m_ChangedTimer(nullptr)
+{
+}
+
+SearchField::~SearchField()
+{
+       if (m_ChangedTimer) {
+               ecore_timer_del(m_ChangedTimer);
+       }
+}
+
 const char *SearchField::getText() const
 {
        return m_Text.c_str();
@@ -80,7 +92,19 @@ void SearchField::onChanged(Evas_Object *entry, void *eventInfo)
        m_Text = text ? text : "";
        free(text);
 
+       if (m_ChangedTimer) {
+               ecore_timer_reset(m_ChangedTimer);
+       } else {
+               m_ChangedTimer = ecore_timer_add(0.3, makeCallback(&SearchField::runOnChanged), this);
+       }
+}
+
+Eina_Bool SearchField::runOnChanged()
+{
        if (m_OnChanged) {
                m_OnChanged(m_Text.c_str());
        }
+
+       m_ChangedTimer = nullptr;
+       return ECORE_CALLBACK_CANCEL;
 }