genlist : refactoring reusable contents
authorSangHyeon Lee <sh10233.lee@samsung.com>
Tue, 22 Nov 2016 11:43:30 +0000 (20:43 +0900)
committerTaehyub Kim <taehyub.kim@samsung.com>
Tue, 29 Nov 2016 12:32:35 +0000 (21:32 +0900)
1. remove contents when reusable content are not pre-defined.
2. focus intialization when content is cached.

Change-Id: I75d26fb80f9875425164a3b2b8d675b091da032b
Signed-off-by: SangHyeon Lee <sh10233.lee@samsung.com>
src/mobile_lib/elm_genlist.c

index 7aa5f67bcf9c8303f86ab6402fc0f13f4d84522b..d44b69a7121bbb79d9dd5841240bd39086a7dfa3 100644 (file)
@@ -454,18 +454,6 @@ _item_cache_pop(Elm_Gen_Item *it)
    return EINA_FALSE;
 }
 
-static Eina_List *
-_content_cache_add(Elm_Gen_Item *it, Eina_List **cache)
-{
-   Evas_Object *content = NULL;
-   EINA_LIST_FREE(it->content_objs, content)
-     {
-        *cache = eina_list_append(*cache, content);
-     }
-
-   return *cache;
-}
-
 // TIZEN_ONLY(20150828) : to prevent unnecessary genlist rendering
 // _changed is called instead of evas_object_smart_changed API.
 static void
@@ -1184,8 +1172,27 @@ _item_unrealize(Elm_Gen_Item *it,
    if (it->base->color_classes)
      edje_object_color_class_clear(VIEW(it));
 //
-   _item_cache_push(it, _content_cache_add(it, &cache));
+   EINA_LIST_FREE(it->content_objs, content)
+     {
+        if (it->itc->version >= 3 && it->itc->func.reusable_content_get)
+          {
+             // Unfocus content object for initialization.
+             if (GL_IT(it)->wsd->focused_content == content)
+               {
+                  elm_object_focus_set(content, EINA_FALSE);
+                  GL_IT(it)->wsd->focused_content = NULL;
+               }
+             cache = eina_list_append(cache, content);
+          }
+        else
+          {
+             if (GL_IT(it)->wsd->focused_content == content)
+               GL_IT(it)->wsd->focused_content = NULL;
+             evas_object_del(content);
+          }
+     }
 
+     _item_cache_push(it, cache);
 
    it->realized = EINA_FALSE;
 }