summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2016-01-06 10:18:24 (GMT)
committerJehun Lim <jehun.lim@samsung.com>2016-01-06 10:18:24 (GMT)
commit6f00dfab339a5dfbfb548e87ac62126c6803a1c9 (patch)
treeaf780991650e2f112496c41cd8f250ddbc4806bb
parent7aeb282445b6cfad793c75bfd4ad0d7c5f003085 (diff)
downloadair_mediahub-6f00dfab339a5dfbfb548e87ac62126c6803a1c9.zip
air_mediahub-6f00dfab339a5dfbfb548e87ac62126c6803a1c9.tar.gz
air_mediahub-6f00dfab339a5dfbfb548e87ac62126c6803a1c9.tar.bz2
movie: manage recently watched item using media idrefs/changes/27/56327/1
Change-Id: I3536b2411b883ef4f8bdeae97df0aca2f0a317a7 Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
-rw-r--r--src/layout/movie.c43
-rw-r--r--src/util/util.c6
-rw-r--r--src/view/detail.c6
3 files changed, 42 insertions, 13 deletions
diff --git a/src/layout/movie.c b/src/layout/movie.c
index 520c213..a2a86d2 100644
--- a/src/layout/movie.c
+++ b/src/layout/movie.c
@@ -61,7 +61,7 @@ struct _priv {
Eina_List *media_list;
- app_media *recent_info;
+ char *recent_id;
int view_mode;
int source_type;
@@ -122,8 +122,11 @@ static bool _update_recent_info(Evas_Object *base, app_media_info *info)
static bool _update_recent(void *data, Evas_Object *base)
{
+ Eina_List *list;
Evas_Object *recent;
+ app_media *am;
app_media_info *info;
+ struct datamgr *dmgr;
struct _priv *priv;
if (!data || !base) {
@@ -139,7 +142,21 @@ static bool _update_recent(void *data, Evas_Object *base)
return false;
}
- info = app_media_get_info(priv->recent_info);
+ am = NULL;
+
+ dmgr = priv->dmgr[E_DATA_MEDIA];
+ if (!dmgr)
+ return false;
+
+ list = dmgr->ops->get_list(dmgr->handle, E_LIST_MEDIA, NULL);
+
+ am = util_find_media_info(list, priv->recent_id);
+ if (!am) {
+ _ERR("failed to get app media");
+ return false;
+ }
+
+ info = app_media_get_info(am);
if (!info) {
_ERR("failed to get app media info");
return false;
@@ -296,8 +313,8 @@ static void _recent_key_down_cb(void *data, Evas_Object *obj,
!strcmp(ev->keyname, KEY_CONTEXT_MENU)) {
vdata.list = dmgr->ops->get_list(dmgr->handle,
E_LIST_MEDIA, NULL);
- vdata.index = util_get_media_index(vdata.list,
- priv->recent_info);
+ vdata.index = util_get_media_index_from_id(vdata.list,
+ priv->recent_id);
vdata.id = VIEW_BASE;
viewmgr_update_view(VIEW_ACTION_MENU, UPDATE_CONTENT, &vdata);
@@ -321,7 +338,8 @@ static void _recent_selected_cb(void *data, Evas_Object *obj)
return;
vdata.list = dmgr->ops->get_list(dmgr->handle, E_LIST_MEDIA, NULL);
- vdata.index = util_get_media_index(vdata.list, priv->recent_info);
+ vdata.index = util_get_media_index_from_id(vdata.list, priv->recent_id);
+
vdata.id = VIEW_BASE;
viewmgr_update_view(VIEW_VIEWER, UPDATE_CONTENT, &vdata);
@@ -459,6 +477,9 @@ static void _update_recent_item(struct _priv *priv, const char *id)
if (!dmgr)
return;
+ free(priv->recent_id);
+ priv->recent_id = NULL;
+
info = NULL;
list = dmgr->ops->get_list(dmgr->handle, E_LIST_MEDIA, NULL);
@@ -474,7 +495,8 @@ static void _update_recent_item(struct _priv *priv, const char *id)
_ERR("failed to get app media info");
}
- priv->recent_info = am;
+ if (info && info->media_id)
+ priv->recent_id = strdup(info->media_id);
if (!listmgr_update_play_info(priv->listmgr, info))
_ERR("failed to update recently watched item");
@@ -624,6 +646,8 @@ static void _destroy(void *layout_data)
_destroy_utils(priv);
+ free(priv->recent_id);
+
evas_object_del(priv->layout);
free(priv);
@@ -665,7 +689,6 @@ static void _update(void *layout_data, int update_type, void *data)
struct view_update_data *vdata;
struct _priv *priv;
struct datamgr *dmgr;
- app_media_info *mi;
int mode;
if (!layout_data) {
@@ -685,10 +708,8 @@ static void _update(void *layout_data, int update_type, void *data)
case UPDATE_CONTENT_ITEM:
listmgr_update_content_item(priv->listmgr);
- if (priv->recent_info) {
- mi = app_media_get_info(priv->recent_info);
- _update_recent_item(priv, mi->media_id);
- }
+ if (priv->recent_id)
+ _update_recent_item(priv, priv->recent_id);
break;
case UPDATE_FOCUS:
if (!data) {
diff --git a/src/util/util.c b/src/util/util.c
index 38e8e75..9ce3081 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -348,6 +348,9 @@ int util_get_media_index_from_id(Eina_List *list, const char *id)
app_media_info *info;
int index;
+ if (!id)
+ return -1;
+
index = 0;
EINA_LIST_FOREACH(list, l, am) {
info = app_media_get_info(am);
@@ -369,6 +372,9 @@ app_media *util_find_media_info(Eina_List *list, const char *id)
app_media *am;
app_media_info *info;
+ if (!id)
+ return NULL;
+
EINA_LIST_FOREACH(list, l, am) {
info = app_media_get_info(am);
if (!info)
diff --git a/src/view/detail.c b/src/view/detail.c
index 20865f6..41aec30 100644
--- a/src/view/detail.c
+++ b/src/view/detail.c
@@ -187,8 +187,10 @@ static void _pop_view(struct _priv *priv)
vdata.id = NULL;
if (view_info[priv->view_type].app_contents_type != CONTENTS_GALLERY) {
- mi = app_media_get_info(priv->play_info);
- vdata.id = mi->media_id;
+ if (priv->play_info) {
+ mi = app_media_get_info(priv->play_info);
+ vdata.id = mi->media_id;
+ }
}
viewmgr_update_view(VIEW_BASE, UPDATE_BACK, &vdata);