Move SetCurrentAlbum / CurrentAlbum function from CMusicController to CAlbumSongLayout 26/36826/1 accepted/tizen/tv/20150316.053658 submit/tizen_tv/20150316.051231
authorKim Tae Soo <taesoo46.kim@samsung.com>
Mon, 16 Mar 2015 05:09:39 +0000 (14:09 +0900)
committerKim Tae Soo <taesoo46.kim@samsung.com>
Mon, 16 Mar 2015 05:09:39 +0000 (14:09 +0900)
Change-Id: I80e0c494af1b5393c5be96322ec2954f47f5659c
Signed-off-by: Kim Tae Soo <taesoo46.kim@samsung.com>
include/album-songs-layout.h
include/music-controller.h
src/playback/music-controller.cpp
src/views/album-layout.cpp
src/views/album-songs-layout.cpp

index c26dbf5..86b2f36 100644 (file)
@@ -66,6 +66,9 @@ public:
        bool Create(CLayoutMgr *mgr);
        virtual void Destroy(void);
 
+       void SetCurrentAlbum(CAlbumInfo *albumInfo);
+       CAlbumInfo*CurrentAlbum(void);
+
 public:
        virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
        virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev);
index 0b29bd9..d2a7cd1 100644 (file)
@@ -91,11 +91,7 @@ public:
        bool GetPosition(int *const milseconds);
 
        bool SetCurrentSong(char *mediaid);
-
        bool GetCurrentSong(CSongInfo **const sinfo);
-       bool SetCurrentAlbum(CAlbumInfo *alinfo);
-
-       CAlbumInfo *CurrentAlbum(void);
 
        bool UpdatePlaylist(Eina_List *slist, int addmode);
        bool EmptyPlaylist(void);
index 7ae4712..a87f470 100644 (file)
@@ -825,34 +825,6 @@ bool CMusicController::SetCurrentSong(char *mediaid)
 }
 
 
-CAlbumInfo *CMusicController::CurrentAlbum(void)
-{
-       if (!m)
-               return NULL;
-
-       return m->alinfo;
-}
-
-
-bool CMusicController::SetCurrentAlbum(CAlbumInfo *alinfo)
-{
-       if (!m)
-               return false;
-
-       if (alinfo)
-               m->alinfo->Duplicate(alinfo);
-       else {
-               CAlbumInfo *emptyInfo = new CAlbumInfo;
-               emptyInfo->Create();
-               m->alinfo->Duplicate(emptyInfo);
-               emptyInfo->Destroy();
-               delete emptyInfo;
-       }
-
-       return true;
-}
-
-
 bool CMusicController::SetPlayState(EPlayStatus state)
 {
        ASSERT(FlagCreate());
index 2770396..d07aa4b 100644 (file)
@@ -232,8 +232,7 @@ void CAlbumLayout::m_OnItemSelect(Elm_Object_Item *it, const char *emission, con
                return;
        }
 
-       m->mhandle->SetCurrentAlbum(itinfo->alinfo);
-
+       m->layoutAlbumSongs->SetCurrentAlbum(itinfo->alinfo);
        m_ShowAlbumSongs();
 }
 
@@ -513,7 +512,7 @@ void CAlbumLayout::t_OnShow(void)
                itinfo = m_FindItemInfoById(m->it_infolist,
                        atoi(m->album_id));
                if (itinfo) {
-                       m->mhandle->SetCurrentAlbum(itinfo->alinfo);
+                       m->layoutAlbumSongs->SetCurrentAlbum(itinfo->alinfo);
                        m_ShowAlbumSongs();
                        return;
                }
@@ -536,12 +535,13 @@ void CAlbumLayout::Update(bool focusFlag)
                return;
        }
 
-       alinfo = m->mhandle->CurrentAlbum();
+       alinfo = m->layoutAlbumSongs->CurrentAlbum();
        if (alinfo) {
                id = alinfo->AlbumId();
                itinfo = m_FindItemInfoById(m->it_infolist, id);
                if (itinfo) {
-                       m->mhandle->SetCurrentAlbum(NULL);
+                       m->layoutAlbumSongs->SetCurrentAlbum(NULL);
+
                        elm_gengrid_item_show(itinfo->item,
                                ELM_GENGRID_ITEM_SCROLLTO_IN);
                        elm_object_item_focus_set(itinfo->item, EINA_TRUE);
index 0daa036..685137c 100644 (file)
@@ -66,6 +66,7 @@ struct SAlbumSongsLayout {
        CMusicController* mhandle;
        CLayoutMgr *mgr;
        CViewMgr *vmgr;
+       CAlbumInfo *alinfo;
        SContentInfo *ctxtinfo;
        Eina_List *slist;
        Eina_List *it_infolist;
@@ -250,7 +251,6 @@ void  CAlbumSongsLayout::m_UpdateSongList(void)
        SAlbumSongsItemInfo *itinfo = NULL;
        Elm_Object_Item *item = NULL;
        int dur = 0;
-       CAlbumInfo *alinfo = NULL;
 
        if (!m->songlist || !m->item_class)
                return;
@@ -258,8 +258,7 @@ void  CAlbumSongsLayout::m_UpdateSongList(void)
        /* Remove existing songlist and prepare afresh */
        m_EmptySongList();
 
-       alinfo = m->mhandle->CurrentAlbum();
-       if (!m->mhandle->MediaGetList(LIST_TYPE_ALBUM_SONG, alinfo, &(m->slist))) {
+       if (!m->mhandle->MediaGetList(LIST_TYPE_ALBUM_SONG, m->alinfo, &(m->slist))) {
                _ERR(" Fetching song list from media failed ");
                return;
        }
@@ -361,7 +360,6 @@ void CAlbumSongsLayout::m_CreateTopSection(void)
        Evas_Object *img = NULL;
        char *path = NULL;
        char buf[MAX_LENGTH];
-       CAlbumInfo *alinfo = NULL;
        SBtnInfo btninfo[TOTAL_ADD_BTNS];
        Evas_Object *layout = Layout();
 
@@ -413,11 +411,8 @@ void CAlbumSongsLayout::m_CreateTopSection(void)
        }
 
        elm_object_focus_set(btn[0], EINA_TRUE);
-       alinfo = m->mhandle->CurrentAlbum();
-       if (!alinfo)
-               return;
 
-       path = alinfo->ThumbnailPath();
+       path = m->alinfo->ThumbnailPath();
        if (path) {
                elm_image_file_set(thumb, path, NULL);
                elm_image_aspect_fixed_set(thumb, EINA_FALSE);
@@ -432,9 +427,9 @@ void CAlbumSongsLayout::m_CreateTopSection(void)
        elm_object_part_content_set(layout, MUSIC_PART_ALBUM_THUMB,
                thumb);
        elm_object_part_text_set(layout, MUSIC_PART_ALBUM_NAME,
-               alinfo->Name());
+               m->alinfo->Name());
        elm_object_part_text_set(layout, MUSIC_PART_ALBUM_ARTIST,
-               alinfo->Artist());
+               m->alinfo->Artist());
 
        snprintf(buf, sizeof(buf), "%d", eina_list_count(m->slist));
        elm_object_part_text_set(layout, MUSIC_PART_ALBUM_SONGCOUNT, buf);
@@ -551,6 +546,7 @@ bool CAlbumSongsLayout::Create(CLayoutMgr *mgr)
        m->vmgr = vmgr;
        m->mhandle = mhandle;
        m->mgr = mgr;
+       m->alinfo = new CAlbumInfo;
 
        Connect(layout, ALBUM_SONGS_LAYOUT, TYPE_KEY_DOWN);
  
@@ -561,6 +557,10 @@ void CAlbumSongsLayout::Destroy(void)
 {
        ASSERT(m);
 
+       if (m->alinfo->FlagCreate())
+               m->alinfo->Destroy();
+       delete m->alinfo;
+
        m_EmptySongList();
        CExtBaseLayout::Destroy();
        evas_object_del(Layout());
@@ -571,6 +571,35 @@ void CAlbumSongsLayout::Destroy(void)
 }
 
 
+void CAlbumSongsLayout::SetCurrentAlbum(CAlbumInfo *albumInfo)
+{
+       ASSERT(m);
+
+       if (m->alinfo->FlagCreate())
+               m->alinfo->Destroy();
+
+       m->alinfo->Create();
+
+       if (albumInfo)
+               m->alinfo->Duplicate(albumInfo);
+       else {
+               CAlbumInfo *emptyInfo = new CAlbumInfo;
+               emptyInfo->Create();
+               m->alinfo->Duplicate(emptyInfo);
+               emptyInfo->Destroy();
+               delete emptyInfo;
+       }
+}
+
+
+CAlbumInfo* CAlbumSongsLayout::CurrentAlbum(void)
+{
+       ASSERT(m);
+
+       return m->alinfo;
+}
+
+
 void CAlbumSongsLayout::t_OnShow(void)
 {
        ASSERT(m);