detail: add selected callback for artist album item 17/48817/1
authorJehun Lim <jehun.lim@samsung.com>
Wed, 30 Sep 2015 06:38:16 +0000 (15:38 +0900)
committerJehun Lim <jehun.lim@samsung.com>
Wed, 30 Sep 2015 06:38:16 +0000 (15:38 +0900)
Change-Id: I10ea7b4a92a03300e6bddc5fd62412ee25b42797
Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
include/data/datamgr.h
src/layout/gallery.c
src/layout/movie.c
src/layout/music.c
src/view/detail.c

index f0222b3..158ace4 100644 (file)
 #include "data/albumdata.h"
 #include "data/folderdata.h"
 
+#define MOVIE_MEDIA_COND "media_type=1 AND copyright!=\"Unknown\""
+#define GALLERY_MEDIA_COND "media_type=0 OR (media_type=1 AND copyright=\"Unknown\")"
+#define MUSIC_MEDIA_COND "media_type=3"
+
 enum data_type {
        E_DATA_MEDIA = 0,
        E_DATA_ALBUM,
index 44a4808..f8a5157 100644 (file)
@@ -32,8 +32,6 @@
 #include "util/util.h"
 #include "util/locmgr.h"
 
-#define LIST_MEDIA_COND "media_type=0 OR (media_type=1 AND copyright=\"Unknown\")"
-
 #define TEXT_NOCONTENT "No Photo & Video"
 
 #define GRID_PADDING 6
@@ -230,7 +228,7 @@ static bool _create_utils(struct _priv *priv)
        int i;
 
        for (i = 0; i < E_DATA_MAX; i++) {
-               dmgr = datamgr_create(i, LIST_MEDIA_COND, E_SOURCE_ALL);
+               dmgr = datamgr_create(i, GALLERY_MEDIA_COND, E_SOURCE_ALL);
                if (!dmgr) {
                        _ERR("failed to create datamgr");
                        _destroy_datamgr(priv);
index 9267939..37023bd 100644 (file)
@@ -33,8 +33,6 @@
 #include "util/progressbar.h"
 #include "util/util.h"
 
-#define LIST_MEDIA_COND "media_type=1 AND copyright!=\"Unknown\""
-
 #define TEXT_NOCONTENT "No Movies"
 #define TEXT_RECENTLY_WATCHED "Recently watched"
 
@@ -460,7 +458,7 @@ static bool _create_utils(struct _priv *priv)
        int i;
 
        for (i = 0; i < E_DATA_MAX; i++) {
-               dmgr = datamgr_create(i, LIST_MEDIA_COND, E_SOURCE_ALL);
+               dmgr = datamgr_create(i, MOVIE_MEDIA_COND, E_SOURCE_ALL);
                if (!dmgr) {
                        _ERR("failed to create datamgr");
                        _destroy_datamgr(priv);
index 19a0fce..cf1ac9a 100644 (file)
@@ -32,8 +32,6 @@
 #include "util/listmgr.h"
 #include "util/util.h"
 
-#define LIST_MEDIA_COND "media_type=3"
-
 #define TEXT_NOCONTENT "No Music"
 #define TEXT_NOW_PLAYING "Now Playing"
 
@@ -433,7 +431,7 @@ static bool _create_utils(struct _priv *priv)
        int i;
 
        for (i = 0; i < E_DATA_MAX; i++) {
-               dmgr = datamgr_create(i, LIST_MEDIA_COND, E_SOURCE_ALL);
+               dmgr = datamgr_create(i, MUSIC_MEDIA_COND, E_SOURCE_ALL);
                if (!dmgr) {
                        _ERR("failed to create datamgr");
                        _destroy_datamgr(priv);
index 5e0dfcb..066521b 100644 (file)
@@ -40,6 +40,13 @@ static void _get_movie_count(char *str, int size, Eina_List *list);
 static void _get_song_count(char *str, int size, Eina_List *list);
 static void _get_album_count(char *str, int size, Eina_List *list);
 
+static void _album_selected(void *data);
+
+struct _list_info {
+       Eina_List *list;
+       const char *title;
+};
+
 struct _view_info {
        const char *grid_style;
        int grid_item_x;
@@ -47,8 +54,10 @@ struct _view_info {
        char *(*get_grid_text)(void *data, Evas_Object *obj, const char *part);
        Evas_Object *(*get_grid_content)(void *data, Evas_Object *obj,
                                const char *part);
-
        void (*get_content_info)(char *str, int size, Eina_List *list);
+
+       void (*selected)(void *data);
+       bool detail_update;
 };
 
 static struct _view_info view_info[E_DETAIL_MAX] = {
@@ -59,6 +68,7 @@ static struct _view_info view_info[E_DETAIL_MAX] = {
                .get_grid_text = _grid_text_get,
                .get_grid_content = _grid_content_get,
                .get_content_info = _get_movie_count,
+               .detail_update = EINA_FALSE,
        },
        [E_DETAIL_MUSIC_ALBUM] = {
                .grid_style = STYLE_MUSIC_SONG_DETAIL,
@@ -67,6 +77,7 @@ static struct _view_info view_info[E_DETAIL_MAX] = {
                .get_grid_text = _grid_text_get,
                .get_grid_content = _grid_content_get,
                .get_content_info = _get_song_count,
+               .detail_update = EINA_FALSE,
        },
        [E_DETAIL_MUSIC_ARTIST] = {
                .grid_style = STYLE_MUSIC_ALBUM,
@@ -75,6 +86,8 @@ static struct _view_info view_info[E_DETAIL_MAX] = {
                .get_grid_text = _album_text_get,
                .get_grid_content = _album_content_get,
                .get_content_info = _get_album_count,
+               .selected = _album_selected,
+               .detail_update = EINA_TRUE,
        },
 };
 
@@ -86,24 +99,60 @@ struct _priv {
        Elm_Object_Item *focused_it;
 
        Eina_List *media_list;
+       Eina_List *view_list;
+
+       struct datamgr *dmgr;
 
        int view_type;
+       int depth;
 
        struct _view_info *vinfo;
 };
 
+static void _update_view(struct _priv *priv)
+{
+       struct _list_info *linfo;
+       struct view_update_data vdata;
+
+       linfo = eina_list_data_get(priv->view_list);
+       priv->view_list = eina_list_remove(priv->view_list, linfo);
+
+       vdata.list = linfo->list;
+       vdata.index = E_DETAIL_MUSIC_ARTIST;
+       vdata.id = linfo->title;
+
+       viewmgr_update_view(VIEW_DETAIL, UPDATE_CONTENT, &vdata);
+       viewmgr_push_view(VIEW_DETAIL);
+
+       priv->depth--;
+
+       free(linfo);
+}
+
+static void _pop_view(void)
+{
+       viewmgr_update_view(VIEW_BASE, UPDATE_BACK, NULL);
+       viewmgr_pop_view();
+}
+
 static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
                        Evas_Event_Key_Down *ev)
 {
-       if (!ev) {
+       struct _priv *priv;
+
+       if (!data || !ev) {
                _ERR("invalid argument");
                return;
        }
 
+       priv = data;
+
        if (!strcmp(ev->keyname, KEY_BACK) ||
                !strcmp(ev->keyname, KEY_ESC)) {
-               viewmgr_update_view(VIEW_BASE, UPDATE_BACK, NULL);
-               viewmgr_pop_view();
+               if (priv->depth > 0)
+                       _update_view(priv);
+               else
+                       _pop_view();
        }
 }
 
@@ -121,7 +170,7 @@ static void _focused_cb(int id, void *data, Evas_Object *obj,
                priv->focused_it = it;
 }
 
-static void _selected(void *data)
+static void _media_selected(void *data)
 {
        struct _priv *priv;
        struct view_update_data vdata;
@@ -152,16 +201,67 @@ static void _selected(void *data)
        }
 }
 
+static void _album_selected(void *data)
+{
+       struct _priv *priv;
+       struct view_update_data vdata;
+       struct _list_info *linfo;
+       struct datamgr *dmgr;
+       struct album_info *ai;
+
+       if (!data) {
+               _ERR("invalid argument");
+               return;
+       }
+
+       priv = data;
+
+       dmgr = priv->dmgr;
+
+       ai = elm_object_item_data_get(priv->focused_it);
+       if (!ai) {
+               _ERR("failed to get album info");
+               return;
+       }
+
+       linfo = calloc(1, sizeof(*linfo));
+       if (!linfo) {
+               _ERR("failed to allocate list info");
+               return;
+       }
+
+       linfo->list = priv->media_list;
+       linfo->title = ai->artist;
+
+       priv->view_list = eina_list_append(priv->view_list, linfo);
+
+       vdata.list = dmgr->ops->get_list(dmgr->handle,
+                               E_LIST_ALBUM_MEDIA, &ai->id);
+       vdata.index = E_DETAIL_MUSIC_ALBUM;
+       vdata.id = ai->name;
+
+       viewmgr_update_view(VIEW_DETAIL, UPDATE_CONTENT, &vdata);
+       viewmgr_push_view(VIEW_DETAIL);
+
+       priv->depth++;
+}
+
 static void _selected_cb(int id, void *data, Evas_Object *obj,
                        Elm_Object_Item *it)
 {
        struct _priv *priv;
+       void (*_selected)(void *data);
 
        if (!data || !it)
                return;
 
        priv = data;
 
+       if (priv->vinfo->detail_update)
+               _selected = priv->vinfo->selected;
+       else
+               _selected = _media_selected;
+
        ecore_job_add(_selected, priv);
 }
 
@@ -369,6 +469,7 @@ static bool _update_thumbnail_area(struct _priv *priv)
        Elm_Object_Item *it;
        void *data;
 
+       elm_object_focus_set(priv->grid, EINA_FALSE);
        elm_gengrid_clear(priv->grid);
 
        elm_gengrid_item_size_set(priv->grid,
@@ -417,6 +518,7 @@ static Evas_Object *_create(Evas_Object *win, void *data)
 {
        struct _priv *priv;
        Evas_Object *base;
+       struct datamgr *dmgr;
 
        if (!win) {
                _ERR("failed to get win object");
@@ -442,11 +544,20 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                                EVAS_HINT_EXPAND);
        elm_win_resize_object_add(win, base);
 
+       dmgr = datamgr_create(E_DATA_ALBUM, MUSIC_MEDIA_COND, E_SOURCE_ALL);
+       if (!dmgr) {
+               _ERR("failed to create datamgr");
+               free(priv);
+               return NULL;
+       }
+
        priv->win = win;
        priv->base = base;
+       priv->dmgr = dmgr;
 
        if (!_draw_thumbnail_area(priv)) {
                _ERR("failed to draw items");
+               datamgr_destroy(dmgr);
                free(priv);
                return NULL;
        }
@@ -548,6 +659,8 @@ static void _destroy(void *view_data)
 
        priv = view_data;
 
+       datamgr_destroy(priv->dmgr);
+
        evas_object_del(priv->base);
 
        free(priv);