summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2015-12-03 07:26:30 (GMT)
committerJehun Lim <jehun.lim@samsung.com>2015-12-03 08:28:00 (GMT)
commite3e8844802cb162ead4415f9b9e9c2abfb1e6aa1 (patch)
tree99a850cd036af53d44ff4bb4f8ffd5cd491dc4b0
parent37f4aea8000a9f41c81d2457f30dfa0fe28deb4d (diff)
downloadair_mediahub-e3e8844802cb162ead4415f9b9e9c2abfb1e6aa1.zip
air_mediahub-e3e8844802cb162ead4415f9b9e9c2abfb1e6aa1.tar.gz
air_mediahub-e3e8844802cb162ead4415f9b9e9c2abfb1e6aa1.tar.bz2
add thumbnail creation routinerefs/changes/59/53259/3
Change-Id: Ib592348c3acfc57db650ac89b05953d5e7f07917 Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
-rw-r--r--include/util/util.h3
-rw-r--r--src/grid/grid_gallery.c29
-rw-r--r--src/grid/grid_movie.c29
-rw-r--r--src/util/listmgr.c3
-rw-r--r--src/util/util.c24
5 files changed, 88 insertions, 0 deletions
diff --git a/include/util/util.h b/include/util/util.h
index 2857f20..3c29281 100644
--- a/include/util/util.h
+++ b/include/util/util.h
@@ -41,5 +41,8 @@ int util_get_media_index(Eina_List *list, void *info);
int util_get_media_index_from_id(Eina_List *list, const char *id);
app_media *util_find_media_info(Eina_List *list, const char *id);
void util_add_to_recent(Eina_List *list, int index);
+void util_create_thumbnail(Evas_Object *grid, app_media *am,
+ void (*completed_cb)(media_content_error_e,
+ const char *, void *));
#endif /* __AIR_MEDIAHUB_UTIL_H__ */
diff --git a/src/grid/grid_gallery.c b/src/grid/grid_gallery.c
index 23d69d3..e9de31e 100644
--- a/src/grid/grid_gallery.c
+++ b/src/grid/grid_gallery.c
@@ -31,6 +31,29 @@
#define STR_PLACE_NAME "City"
+static void _create_thumbnail_completed_cb(media_content_error_e err,
+ const char *path, void *user_data)
+{
+ Elm_Object_Item *it;
+ app_media *am;
+
+ if (!user_data)
+ return;
+
+ it = user_data;
+
+ media_content_connect();
+
+ am = elm_object_item_data_get(it);
+
+ app_media_update(am);
+
+ elm_gengrid_item_fields_update(it, PART_ELM_SWALLOW_THUMBNAIL,
+ ELM_GENGRID_ITEM_FIELD_CONTENT);
+
+ media_content_disconnect();
+}
+
static char *_media_text_get(void *data, Evas_Object *obj, const char *part)
{
app_media *am;
@@ -81,6 +104,12 @@ static Evas_Object *_media_content_get(void *data,
eo = NULL;
if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) {
+ if (!info->thumbnail_path) {
+ util_create_thumbnail(obj, am,
+ _create_thumbnail_completed_cb);
+ return NULL;
+ }
+
eo = util_add_image(obj, info->thumbnail_path);
if (!eo) {
_ERR("failed to create image object");
diff --git a/src/grid/grid_movie.c b/src/grid/grid_movie.c
index f8bc519..0341f57 100644
--- a/src/grid/grid_movie.c
+++ b/src/grid/grid_movie.c
@@ -31,6 +31,29 @@
#define STR_GENRE_NAME "Genre"
+static void _create_thumbnail_completed_cb(media_content_error_e err,
+ const char *path, void *user_data)
+{
+ Elm_Object_Item *it;
+ app_media *am;
+
+ if (!user_data)
+ return;
+
+ it = user_data;
+
+ media_content_connect();
+
+ am = elm_object_item_data_get(it);
+
+ app_media_update(am);
+
+ elm_gengrid_item_fields_update(it, PART_ELM_SWALLOW_THUMBNAIL,
+ ELM_GENGRID_ITEM_FIELD_CONTENT);
+
+ media_content_disconnect();
+}
+
static char *_media_text_get(void *data, Evas_Object *obj, const char *part)
{
app_media *am;
@@ -71,6 +94,12 @@ static Evas_Object *_media_content_get(void *data, Evas_Object *obj,
eo = NULL;
if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) {
+ if (!info->thumbnail_path) {
+ util_create_thumbnail(obj, am,
+ _create_thumbnail_completed_cb);
+ return NULL;
+ }
+
eo = util_add_image(obj, info->thumbnail_path);
if (!eo) {
_ERR("failed to create image object");
diff --git a/src/util/listmgr.c b/src/util/listmgr.c
index ee0d5ec..b3e8d34 100644
--- a/src/util/listmgr.c
+++ b/src/util/listmgr.c
@@ -28,6 +28,7 @@
#include "util/util.h"
#define STR_GRID_ID "grid_id"
+#define STR_GRID_CONTENT "grid_content"
#define MAX_GRID_WIDTH 1858
@@ -450,6 +451,8 @@ static Evas_Object *_add_list_item_grid(struct listmgr *lmgr,
inputmgr_add_callback(grid, LISTMGR_GRID, &_grid_handler, lmgr);
+ evas_object_data_set(grid, STR_GRID_CONTENT, gi->list);
+
return grid;
}
diff --git a/src/util/util.c b/src/util/util.c
index 80c2328..43daa06 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -23,6 +23,8 @@
#include "define.h"
#include "util/util.h"
+#define STR_GRID_CONTENT "grid_content"
+
#define VIDEO_COPYRIGHT "Unknown"
/*
@@ -395,3 +397,25 @@ void util_add_to_recent(Eina_List *list, int index)
app_media_update(am);
}
+
+void util_create_thumbnail(Evas_Object *grid, app_media *am,
+ void (*completed_cb)(media_content_error_e,
+ const char *, void *))
+{
+ Eina_List *list;
+ Elm_Object_Item *it;
+ int index;
+ int r;
+
+ list = evas_object_data_get(grid, STR_GRID_CONTENT);
+ index = util_get_media_index(list, am);
+
+ it = elm_gengrid_first_item_get(grid);
+ while (index--)
+ it = elm_gengrid_item_next_get(it);
+
+ r = media_info_create_thumbnail(app_media_get_media_handle(am),
+ completed_cb, it);
+ if (r != MEDIA_CONTENT_ERROR_NONE)
+ _ERR("failed to create thumbnail");
+}