summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2015-09-30 13:00:35 +0900
committerJehun Lim <jehun.lim@samsung.com>2015-09-30 13:39:54 +0900
commit966f598f692fa9e2a836d710ee4e56176da0e85b (patch)
treed6fe61ef5135cb9b3ae87debc15803f6db724f11
parentb5da373f1c974571b30f12ac2102db4ddf1f3d72 (diff)
downloadair_mediahub-966f598f692fa9e2a836d710ee4e56176da0e85b.tar.gz
air_mediahub-966f598f692fa9e2a836d710ee4e56176da0e85b.tar.bz2
air_mediahub-966f598f692fa9e2a836d710ee4e56176da0e85b.zip
detail: add music artist detail view
Change-Id: I8f06e4322845938114305c02cc845245613d43ed Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
-rw-r--r--include/data/albumdata.h1
-rw-r--r--include/view.h1
-rw-r--r--src/data/albumdata.c36
-rw-r--r--src/grid/grid_music.c29
-rw-r--r--src/view/detail.c72
5 files changed, 128 insertions, 11 deletions
diff --git a/include/data/albumdata.h b/include/data/albumdata.h
index 0d566bc..6c39494 100644
--- a/include/data/albumdata.h
+++ b/include/data/albumdata.h
@@ -27,6 +27,7 @@ enum album_group_type {
enum album_list_type {
E_LIST_ALBUM_MEDIA = 0,
+ E_LIST_ARTIST_ALBUM,
};
struct album_info {
diff --git a/include/view.h b/include/view.h
index 7d52512..21e0f03 100644
--- a/include/view.h
+++ b/include/view.h
@@ -61,6 +61,7 @@ enum update_type {
enum detail_view_type {
E_DETAIL_MOVIE_GENRE = 0,
E_DETAIL_MUSIC_ALBUM,
+ E_DETAIL_MUSIC_ARTIST,
E_DETAIL_MAX
};
diff --git a/src/data/albumdata.c b/src/data/albumdata.c
index 1cd6b95..6f62715 100644
--- a/src/data/albumdata.c
+++ b/src/data/albumdata.c
@@ -23,17 +23,17 @@
struct albumdata;
-typedef bool (*get_album_list)(struct albumdata *ad);
+typedef bool (*get_album_list)(struct albumdata *ad, const char *cond);
typedef int (*media_compare)(struct group_info *gi, struct album_info *ai);
typedef void *(*media_compare_data_get)(struct album_info *ai);
typedef char *(*group_name_get)(struct album_info *ai);
-static bool _get_name_list(struct albumdata *ad);
+static bool _get_name_list(struct albumdata *ad, const char *cond);
static int _compare_name(struct group_info *, struct album_info *);
static void *_get_data_name(struct album_info *);
static char *_get_name(struct album_info *);
-static bool _get_artist_list(struct albumdata *ad);
+static bool _get_artist_list(struct albumdata *ad, const char *cond);
static int _compare_artist(struct group_info *, struct album_info *);
static void *_get_data_artist(struct album_info *);
static char *_get_artist(struct album_info *);
@@ -334,7 +334,7 @@ static bool _get_media_list(struct albumdata *ad, int album_id)
return true;
}
-static bool _get_name_list(struct albumdata *ad)
+static bool _get_name_list(struct albumdata *ad, const char *cond)
{
filter_h filter;
int ret;
@@ -345,7 +345,7 @@ static bool _get_name_list(struct albumdata *ad)
return false;
}
- if (!_create_filter(ad, &filter, NULL, E_FILTER_ALBUM)) {
+ if (!_create_filter(ad, &filter, cond, E_FILTER_ALBUM)) {
_ERR("failed to create filter");
media_content_disconnect();
return false;
@@ -367,7 +367,7 @@ static bool _get_name_list(struct albumdata *ad)
return true;
}
-static bool _get_artist_list(struct albumdata *ad)
+static bool _get_artist_list(struct albumdata *ad, const char *cond)
{
filter_h filter;
int ret;
@@ -443,6 +443,8 @@ static Eina_List *_get_list(void *handle, int type, void *data)
{
struct albumdata *ad;
int *album_id;
+ char *artist;
+ char buf[64];
if (!handle) {
_ERR("failed to get albumdata handle");
@@ -465,7 +467,22 @@ static Eina_List *_get_list(void *handle, int type, void *data)
album_id = data;
_get_media_list(ad, *album_id);
+
return ad->media_list;
+ case E_LIST_ARTIST_ALBUM:
+ if (ad->album_list) {
+ _destroy_album_list(ad->album_list);
+ ad->album_list = NULL;
+ }
+
+ ad->group_type = E_GROUP_ALBUM_NAME;
+
+ artist = data;
+
+ snprintf(buf, sizeof(buf), "MEDIA_ALBUM_ARTIST=\"%s\"", artist);
+ _get_name_list(ad, buf);
+
+ return ad->album_list;
default:
break;
}
@@ -494,7 +511,7 @@ static void _free_group_list(Eina_List *list)
EINA_LIST_FREE(list, gi) {
free(gi->name);
free(gi->data);
- eina_list_free(gi->list);
+ _destroy_album_list(gi->list);
free(gi);
}
@@ -531,7 +548,7 @@ static Eina_List *_get_group(void *handle, int type, void *data)
ad->album_list = NULL;
}
- if (!g_group_info[type].get_list(ad)) {
+ if (!g_group_info[type].get_list(ad, NULL)) {
_ERR("failed to get album list");
return NULL;
}
@@ -556,6 +573,9 @@ static Eina_List *_get_group(void *handle, int type, void *data)
gi->list = eina_list_append(gi->list, ai);
}
+ eina_list_free(ad->album_list);
+ ad->album_list = NULL;
+
return list;
}
diff --git a/src/grid/grid_music.c b/src/grid/grid_music.c
index 34a9058..b4e327c 100644
--- a/src/grid/grid_music.c
+++ b/src/grid/grid_music.c
@@ -376,6 +376,34 @@ static void _album_selected_cb(void *data, Elm_Object_Item *it)
viewmgr_push_view(VIEW_DETAIL);
}
+static void _artist_selected_cb(void *data, Elm_Object_Item *it)
+{
+ struct view_update_data vdata;
+ struct datamgr *dmgr;
+ struct album_info *ai;
+
+ if (!data || !it) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ dmgr = data;
+
+ ai = elm_object_item_data_get(it);
+ if (!ai) {
+ _ERR("failed to get album info");
+ return;
+ }
+
+ vdata.list = dmgr->ops->get_list(dmgr->handle,
+ E_LIST_ARTIST_ALBUM, ai->artist);
+ vdata.index = E_DETAIL_MUSIC_ARTIST;
+ vdata.id = ai->artist;
+
+ viewmgr_update_view(VIEW_DETAIL, UPDATE_CONTENT, &vdata);
+ viewmgr_push_view(VIEW_DETAIL);
+}
+
static struct grid_class _gclass[] = {
[E_MUSIC_SONG] = {
.item_style = STYLE_MUSIC_SONG,
@@ -430,6 +458,7 @@ static struct grid_data _gdata[] = {
.gclass = &_gclass[E_MUSIC_ARTIST],
.get_item_list = _get_artist_list,
.free_item_list = _free_item_list,
+ .selected_cb = _artist_selected_cb,
},
[E_MUSIC_GENRE] = {
.item_x = MUSIC_GENRE_ITEM_X,
diff --git a/src/view/detail.c b/src/view/detail.c
index ce28fdb..5e0dfcb 100644
--- a/src/view/detail.c
+++ b/src/view/detail.c
@@ -32,8 +32,13 @@ static char *_grid_text_get(void *data, Evas_Object *obj, const char *part);
static Evas_Object *_grid_content_get(void *data, Evas_Object *obj,
const char *part);
+static char *_album_text_get(void *data, Evas_Object *obj, const char *part);
+static Evas_Object *_album_content_get(void *data, Evas_Object *obj,
+ const char *part);
+
static void _get_movie_count(char *str, int size, Eina_List *list);
-static void _get_music_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);
struct _view_info {
const char *grid_style;
@@ -61,7 +66,15 @@ static struct _view_info view_info[E_DETAIL_MAX] = {
.grid_item_y = MUSIC_SONG_ITEM_Y,
.get_grid_text = _grid_text_get,
.get_grid_content = _grid_content_get,
- .get_content_info = _get_music_count,
+ .get_content_info = _get_song_count,
+ },
+ [E_DETAIL_MUSIC_ARTIST] = {
+ .grid_style = STYLE_MUSIC_ALBUM,
+ .grid_item_x = MUSIC_ALBUM_ITEM_X,
+ .grid_item_y = MUSIC_ALBUM_ITEM_Y,
+ .get_grid_text = _album_text_get,
+ .get_grid_content = _album_content_get,
+ .get_content_info = _get_album_count,
},
};
@@ -259,6 +272,54 @@ static Evas_Object *_grid_content_get(void *data, Evas_Object *obj,
return eo;
}
+static char *_album_text_get(void *data, Evas_Object *obj, const char *part)
+{
+ struct album_info *ai;
+
+ if (!data)
+ return NULL;
+
+ ai = data;
+
+ return strdup(ai->name);
+}
+
+static Evas_Object *_album_content_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ Evas_Object *eo;
+ struct album_info *ai;
+ struct color_data bg;
+
+ if (!data)
+ return NULL;
+
+ ai = data;
+
+ eo = NULL;
+ if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) {
+ eo = util_add_image(obj, ai->album_art);
+ if (!eo) {
+ _ERR("failed to create image object");
+ return NULL;
+ }
+ } else if (!strcmp(part, PART_ELM_SWALLOW_TEXTBG)) {
+ eo = evas_object_rectangle_add(obj);
+ if (!eo) {
+ _ERR("failed to create rectangle object");
+ return NULL;
+ }
+
+ app_contents_get_color(ai->name, NULL, &bg);
+ evas_object_color_set(eo, bg.r, bg.g, bg.b, bg.a);
+ }
+
+ if (eo)
+ evas_object_show(eo);
+
+ return eo;
+}
+
static Elm_Gengrid_Item_Class *_get_grid_item_class(struct _view_info *vinfo)
{
Elm_Gengrid_Item_Class *ic;
@@ -281,11 +342,16 @@ static void _get_movie_count(char *str, int size, Eina_List *list)
snprintf(str, size, "%d movies", eina_list_count(list));
}
-static void _get_music_count(char *str, int size, Eina_List *list)
+static void _get_song_count(char *str, int size, Eina_List *list)
{
snprintf(str, size, "%d songs", eina_list_count(list));
}
+static void _get_album_count(char *str, int size, Eina_List *list)
+{
+ snprintf(str, size, "%d albums", eina_list_count(list));
+}
+
static void _update_title_area(struct _priv *priv, const char *title)
{
char buf[64];