From: Kim Tae Soo Date: Mon, 16 Mar 2015 05:09:39 +0000 (+0900) Subject: Move SetCurrentAlbum / CurrentAlbum function from CMusicController to CAlbumSongLayout X-Git-Tag: accepted/tizen/tv/20150316.053658^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc8fe641bd05b54937b8473b25c4eb083fa76be7;p=profile%2Ftv%2Fapps%2Fnative%2Fmusicplayer.git Move SetCurrentAlbum / CurrentAlbum function from CMusicController to CAlbumSongLayout Change-Id: I80e0c494af1b5393c5be96322ec2954f47f5659c Signed-off-by: Kim Tae Soo --- diff --git a/include/album-songs-layout.h b/include/album-songs-layout.h index c26dbf5..86b2f36 100644 --- a/include/album-songs-layout.h +++ b/include/album-songs-layout.h @@ -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); diff --git a/include/music-controller.h b/include/music-controller.h index 0b29bd9..d2a7cd1 100644 --- a/include/music-controller.h +++ b/include/music-controller.h @@ -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); diff --git a/src/playback/music-controller.cpp b/src/playback/music-controller.cpp index 7ae4712..a87f470 100644 --- a/src/playback/music-controller.cpp +++ b/src/playback/music-controller.cpp @@ -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()); diff --git a/src/views/album-layout.cpp b/src/views/album-layout.cpp index 2770396..d07aa4b 100644 --- a/src/views/album-layout.cpp +++ b/src/views/album-layout.cpp @@ -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); diff --git a/src/views/album-songs-layout.cpp b/src/views/album-songs-layout.cpp index 0daa036..685137c 100644 --- a/src/views/album-songs-layout.cpp +++ b/src/views/album-songs-layout.cpp @@ -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);