+static Evas_Object * __emoticon_gl_recent_content_get(void *data, Evas_Object *obj, const char *part)
+{
+ if (is_content_reuse_on) {
+ unsigned int index = (uintptr_t)data;
+ int new_index = 0;
+
+ //PRINTFUNC(DLOG_DEBUG,"%s %d", part, index);
+ if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
+ if (!strcmp(part, "elm.icon.1")) {
+ if (index >= recent_emoji_list.size()) return NULL;
+ new_index = index;
+ } else if (!strcmp(part, "elm.icon.2")) {
+ if (index + 1 >= recent_emoji_list.size()) return NULL;
+ new_index = index + 1;
+ } else if (!strcmp(part, "elm.icon.3")) {
+ if (index + 2 >= recent_emoji_list.size()) return NULL;
+ new_index = index + 2;
+ }
+
+ Evas_Object* btn = NULL;
+ btn = (Evas_Object*)emoticon_recents_pool[new_index].content;
+ emoticon_recents_pool[new_index].used = 1;
+ return btn;
+ } else if (!strcmp(part, "base")) {
+ Evas_Object* btn = elm_button_add(obj);
+ elm_object_style_set(btn, "ime/transparent");
+ return btn;
+ }
+ } else {
+ unsigned int index = (uintptr_t)data;
+ int new_index = 0;
+
+ //PRINTFUNC(DLOG_DEBUG,"%s %d", part, index);
+ if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
+ if (!strcmp(part, "elm.icon.1")) {
+ if (index >= recent_emoji_list.size()) return NULL;
+ new_index = index;
+ } else if (!strcmp(part, "elm.icon.2")) {
+ if (index + 1 >= recent_emoji_list.size()) return NULL;
+ new_index = index + 1;
+ } else if (!strcmp(part, "elm.icon.3")) {
+ if (index + 2 >= recent_emoji_list.size()) return NULL;
+ new_index = index + 2;
+ }
+ return get_recent_emoticon_button(obj, new_index);
+ } else if (!strcmp(part, "base")) {
+ Evas_Object* btn = elm_button_add(obj);
+ elm_object_style_set(btn, "ime/transparent");
+ return btn;
+ }
+ }
+ return NULL;
+}
+
+static Evas_Object * __emoticon_gl_emoticon_content_get(void *data, Evas_Object *obj, const char *part)
+{
+ //PRINTFUNC(DLOG_DEBUG,"%s", __func__);
+ if (is_content_reuse_on) {
+ int index = (uintptr_t)data;
+ int new_index = 0;
+
+ if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
+ if (!strcmp(part, "elm.icon.1")) {
+ if (index >= EMOTICON_CNT) return NULL;
+ new_index = index;
+ } else if (!strcmp(part, "elm.icon.2")) {
+ if (index + 1 >= EMOTICON_CNT) return NULL;
+ new_index = index + 1;
+ } else if (!strcmp(part, "elm.icon.3")) {
+ if (index + 2 >= EMOTICON_CNT) return NULL;
+ new_index = index + 2;
+ }
+
+ Evas_Object* btn = NULL;
+ btn = (Evas_Object*)emoticon_contents_pool[new_index].content;
+ emoticon_contents_pool[new_index].used = 1;
+#if 0
+ char utf_8[10] = {0, };
+ snprintf(utf_8, sizeof(utf_8), "%d", new_index);
+ elm_object_part_text_set(btn, "elm.text", strdup(utf_8));
+#else
+ int length;
+ const Eina_Unicode unicode_event[2] = { (Eina_Unicode)emoticon_info[new_index].code, 0 };
+ char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length);
+ elm_object_part_text_set(btn, "elm.text", utf_8);
+ evas_object_data_set(btn, "index", (void*)(uintptr_t)new_index);
+
+ if (utf_8)
+ free(utf_8);
+#endif
+ return btn;
+
+ } else if (!strcmp(part, "base")) {
+ Evas_Object* btn = elm_button_add(obj);
+ elm_object_style_set(btn, "ime/transparent");
+ return btn;
+ }
+ } else {
+ int index = (uintptr_t)data;
+ int new_index = 0;
+
+ if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
+ if (!strcmp(part, "elm.icon.1")) {
+ if (index >= EMOTICON_CNT) return NULL;
+ new_index = index;
+ } else if (!strcmp(part, "elm.icon.2")) {
+ if (index + 1 >= EMOTICON_CNT) return NULL;
+ new_index = index + 1;
+ } else if (!strcmp(part, "elm.icon.3")) {
+ if (index + 2 >= EMOTICON_CNT) return NULL;
+ new_index = index + 2;
+ }
+ return get_emoticon_button(obj, new_index);
+ } else if (!strcmp(part, "base")) {
+ Evas_Object* btn = elm_button_add(obj);
+ elm_object_style_set(btn, "ime/transparent");
+ return btn;
+ }
+ }
+ return NULL;
+}
+
+void _create_reusable_recents(Evas_Object *parent)
+{
+ if (!parent) {
+ PRINTFUNC(DLOG_ERROR, "parent is null");
+ return;
+ }
+
+ unsigned int i;
+ for (i = 0; i < recent_emoji_list.size(); i++ ) {
+ emoticon_recents_pool[i].index = i;
+ emoticon_recents_pool[i].content = get_recent_emoticon_button(parent, i);
+ emoticon_recents_pool[i].used = 0;
+ }
+}
+
+static Eina_Bool _lazy_loader_cb_for_contents(void *data)
+{
+ Evas_Object *gl = (Evas_Object *)data;
+ if (!gl) {
+ PRINTFUNC(DLOG_ERROR, "gl is null");
+ lazy_loading_timer_for_contents = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (loading_done_for_contents == EMOTICON_CNT) {
+ PRINTFUNC(DLOG_DEBUG, "lazy loading contents done");
+ lazy_loading_timer_for_contents = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ int loading_top = 0;
+ if (loading_done_for_contents + LOADING_CONTENT_UNIT > EMOTICON_CNT) {
+ loading_top = EMOTICON_CNT;
+ } else {
+ loading_top = loading_done_for_contents + LOADING_CONTENT_UNIT;
+ }
+
+ PRINTFUNC(DLOG_DEBUG, "_lazy_loader_cb_for_contents loading_done = %d", loading_done_for_contents);
+
+ int i;
+ for (i = loading_done_for_contents; i < loading_top; i++) {
+ emoticon_contents_pool[i].index = i;
+ emoticon_contents_pool[i].used = 0;
+
+ if (emoticon_contents_pool[i].content == NULL) { // reusable
+ emoticon_contents_pool[i].content = get_emoticon_button(gl, i);
+ }
+ }
+
+ loading_done_for_contents = loading_top;
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+void create_reusable_button(Evas_Object *parent)
+{
+ if (!parent) {
+ PRINTFUNC(DLOG_ERROR, "parent is null");
+ return;
+ }
+ loading_done_for_contents = INITAL_CONTENT_UNIT;
+
+ int i;
+ for (i = 0; i < INITAL_CONTENT_UNIT; i++ ) {
+ emoticon_contents_pool[i].index = i;
+ emoticon_contents_pool[i].used = 0;
+
+ if (emoticon_contents_pool[i].content == NULL) { // reusable
+ emoticon_contents_pool[i].content = get_emoticon_button(parent, i);
+ }
+ }
+
+ lazy_loading_timer_for_contents = ecore_timer_add(0.25, _lazy_loader_cb_for_contents, (void *)parent);
+}
+
+static Eina_Bool _lazy_loader_cb_for_items(void *data)
+{
+ Evas_Object *gl = (Evas_Object *)data;
+ if (!gl) {
+ PRINTFUNC(DLOG_ERROR, "gl is null");
+ lazy_loading_timer_for_items = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (loading_done_for_item == EMOTICON_CNT) {
+ PRINTFUNC(DLOG_DEBUG, "lazy loading item done");
+ //elm_genlist_realized_items_update(gl);
+ elm_genlist_item_class_free(itc_emoticon);
+ lazy_loading_timer_for_items = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ int loading_top = 0;
+ if (loading_done_for_item + LOADING_ITEM_UNIT > EMOTICON_CNT) {
+ loading_top = EMOTICON_CNT;
+ } else {
+ loading_top = loading_done_for_item + LOADING_ITEM_UNIT;
+ }
+
+ if (loading_top > loading_done_for_contents) {
+ PRINTFUNC(DLOG_DEBUG, "Wait for content loading");
+ return ECORE_CALLBACK_RENEW;
+ }
+ PRINTFUNC(DLOG_DEBUG, "_lazy_loader_cb_for_items loading_done_for_item = %d", loading_done_for_item);
+
+ int i;
+ for (i = loading_done_for_item; i < loading_top; i++ ) {
+ if (i%3 == 0)
+ elm_genlist_item_append(gl, itc_emoticon, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)(uintptr_t)i);
+ }
+
+ loading_done_for_item = loading_top;
+ return ECORE_CALLBACK_RENEW;
+}
+
+void _create_reusable_contents(Evas_Object *gl){
+ if (!gl) {
+ PRINTFUNC(DLOG_ERROR, "gl is null");
+ return;
+ }
+ int i;
+ loading_done_for_item = INITAL_ITEM_UNIT;
+
+ for (i = 0; i < INITAL_ITEM_UNIT; i++ ) {
+ if (i%3 == 0)
+ elm_genlist_item_append(gl, itc_emoticon, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)(uintptr_t)i);
+ }
+
+ lazy_loading_timer_for_items = ecore_timer_add(0.1, _lazy_loader_cb_for_items, (void *)gl);
+}
+
+Evas_Object* _create_emoticon_genlist(void* data)