Source code re-arranged. 54/37154/6
authorKim Tae Soo <taesoo46.kim@samsung.com>
Fri, 20 Mar 2015 01:49:57 +0000 (10:49 +0900)
committerKim Tae Soo <taesoo46.kim@samsung.com>
Fri, 20 Mar 2015 07:49:23 +0000 (16:49 +0900)
Change-Id: I62a92bac157e33c3e875d76372d84e52b25dd444
Signed-off-by: Kim Tae Soo <taesoo46.kim@samsung.com>
include/artist-layout.h
include/common.h
src/views/album-layout.cpp
src/views/album-songs-layout.cpp
src/views/category-layout.cpp
src/views/category-songs-layout.cpp
src/views/common-ui.cpp
src/views/folder-layout.cpp
src/views/playback-view.cpp
src/views/playlist-layout.cpp
src/views/song-layout.cpp

index 53ad620..4df42c4 100644 (file)
@@ -25,7 +25,7 @@ private:
 protected:
        virtual void t_HandleItemSelect(SCatItemInfo *itinfo);
        virtual bool t_GetMediaList(Eina_List **list);
-       virtual EContextType t_ContextType(void) { return CONTEXT_TYPE_PLAYLIST; }
+       virtual EContextType t_ContextType(void) { return CONTEXT_TYPE_ARTIST; }
        virtual ECategoryType t_CategoryType(void) { return CAT_TYPE_ARTIST; }
 
 public:
index cb21752..b0f77fa 100644 (file)
@@ -121,8 +121,8 @@ enum EActionType {
 };
 
 struct SContentInfo {
-       enum EContextType type;
-       enum EPlayStatus status;
+       EContextType type;
+       EPlayStatus status;
 
        void (*update)(void *data, enum EActionType type, int id);
        void (*close)(void *data);
index f1dbcb1..b4229d1 100644 (file)
@@ -189,20 +189,33 @@ void CAlbumLayout::m_OnCtxtUpdate(EActionType type, int lid)
        if (!m->ctxtinfo || !m->ctxtinfo->context)
                return;
 
-       if (type == ACTION_TYPE_ADDNEXT)
+       m->mhandle->MediaGetList(LIST_TYPE_ALBUM_SONG,
+               m->ctxtinfo->context, &list);
+
+       switch (type) {
+       case ACTION_TYPE_PLAY:
+               mode = ADD_TYPE_FRESH;
+               break;
+
+       case ACTION_TYPE_ADDNEXT:
                mode = ADD_TYPE_NEXT;
-       else
+               break;
+
+       case ACTION_TYPE_ADDLAST:
                mode = ADD_TYPE_END;
+               break;
 
-       m->mhandle->MediaGetList(LIST_TYPE_ALBUM_SONG,
-               m->ctxtinfo->context, &list);
-       if (type ==  ACTION_TYPE_ADDTO) {
-               if (!m->mhandle->MediaAddsongsPlaylist(lid, list))
-                       _ERR(" Adding songs to playlist failed ");
-               else
+       case ACTION_TYPE_ADDTO:
+               if (m->mhandle->MediaAddsongsPlaylist(lid, list))
                        CCommonUI::CreateMsgBox(m->base, MUSIC_TEXT_ADDTO_MSG);
-
+               else
+                       _ERR(" Adding songs to playlist failed ");
                return;
+
+       default:
+               _ERR("Invalid Action Type");
+               ASSERT(0);
+               break;
        }
 
        m->mhandle->UpdatePlaylist(list, mode);
@@ -214,7 +227,7 @@ void CAlbumLayout::m_OnCtxtUpdate(EActionType type, int lid)
                m->mhandle->SetCurrentSong(sinfo->Id());
        }
 
-       CCommonUI::UpdatePlaybackView((EAddType)type, Layout(), m->focusedItem);
+       CCommonUI::UpdatePlaybackView(mode, Layout(), m->focusedItem);
 }
 
 
index c0ea801..f167d2e 100644 (file)
@@ -164,19 +164,32 @@ void CAlbumSongsLayout::m_OnCtxtUpdate(EActionType type, int lid)
        if (!m->ctxtinfo || !m->ctxtinfo->context)
                return;
 
-       if (type == ACTION_TYPE_ADDNEXT)
+       list = eina_list_append(list, m->ctxtinfo->context);
+
+       switch (type) {
+       case ACTION_TYPE_PLAY:
+               mode = ADD_TYPE_FRESH;
+               break;
+
+       case ACTION_TYPE_ADDNEXT:
                mode = ADD_TYPE_NEXT;
-       else
+               break;
+
+       case ACTION_TYPE_ADDLAST:
                mode = ADD_TYPE_END;
+               break;
 
-       list = eina_list_append(list, m->ctxtinfo->context);
-       if (type == ACTION_TYPE_ADDTO) {
-               if (!m->mhandle->MediaAddsongsPlaylist(lid, list))
-                       _ERR(" Adding songs to playlist failed ");
-               else
+       case ACTION_TYPE_ADDTO:
+               if (m->mhandle->MediaAddsongsPlaylist(lid, list))
                        CCommonUI::CreateMsgBox(m->base, MUSIC_TEXT_ADDTO_MSG);
-
+               else
+                       _ERR(" Adding songs to playlist failed ");
                return;
+
+       default:
+               _ERR("Invalid Action Type");
+               ASSERT(0);
+               break;
        }
 
        m->mhandle->UpdatePlaylist(list, mode);
@@ -187,7 +200,7 @@ void CAlbumSongsLayout::m_OnCtxtUpdate(EActionType type, int lid)
                m->mhandle->SetCurrentSong(((CSongInfo *)m->ctxtinfo->context)->Id());
        }
 
-       CCommonUI::UpdatePlaybackView((EAddType)type, Layout(), m->focused_item);
+       CCommonUI::UpdatePlaybackView(mode, Layout(), m->focused_item);
 }
 
 void CAlbumSongsLayout::sm_CbCtxtClose(void *dt)
index 0767255..039e6de 100644 (file)
@@ -241,16 +241,7 @@ void CCategoryLayout::t_OnCtxtUpdate(enum EActionType type, int lid)
        if (!t.ctxtinfo || !t.ctxtinfo->context)
                return;
 
-       if (type == ACTION_TYPE_ADDNEXT)
-               mode = ADD_TYPE_NEXT;
-       else
-               mode = ADD_TYPE_END;
-
-       if (t.depth == E_DEPTH_SONG) {
-               sinfo = (CSongInfo *)t.ctxtinfo->context;
-               list = eina_list_append(list, sinfo);
-       }
-       else if (t.depth == E_DEPTH_ALBUM) {
+       if (t.depth == E_DEPTH_ALBUM) {
                m->pMusicController->MediaGetList(LIST_TYPE_ALBUM_SONG,
                        t.ctxtinfo->context, &list);
                sinfo = (CSongInfo *)eina_list_data_get(list);
@@ -276,21 +267,40 @@ void CCategoryLayout::t_OnCtxtUpdate(enum EActionType type, int lid)
                sinfo = (CSongInfo *)eina_list_data_get(list);
        }
 
-       if (type ==  ACTION_TYPE_ADDTO) {
-               if (!m->pMusicController->MediaAddsongsPlaylist(lid, list))
-                       _ERR(" Adding songs to playlist failed ");
-               else
-                       CCommonUI::CreateMsgBox(t.base, MUSIC_TEXT_ADDTO_MSG);
+       switch (type) {
+       case ACTION_TYPE_PLAY:
+               mode = ADD_TYPE_FRESH;
+               break;
 
-               if (t.depth == E_DEPTH_CATEGORY) {
-                       EINA_LIST_FREE(list, obj) {
-                               sinfo = (CSongInfo *)obj;
-                               sinfo->Destroy();
-                               delete sinfo;
+       case ACTION_TYPE_ADDNEXT:
+               mode = ADD_TYPE_NEXT;
+               break;
+
+       case ACTION_TYPE_ADDLAST:
+               mode = ADD_TYPE_END;
+               break;
+
+       case ACTION_TYPE_ADDTO:
+               {
+                       if (m->pMusicController->MediaAddsongsPlaylist(lid, list))
+                               CCommonUI::CreateMsgBox(t.base, MUSIC_TEXT_ADDTO_MSG);
+                       else
+                               _ERR(" Adding songs to playlist failed ");
+
+                       if (t.depth == E_DEPTH_CATEGORY) {
+                               EINA_LIST_FREE(list, obj) {
+                                       sinfo = (CSongInfo *)obj;
+                                       sinfo->Destroy();
+                                       delete sinfo;
+                               }
                        }
                }
-
                return;
+
+       default:
+               _ERR("Invalid Action Type");
+               ASSERT(0);
+               break;
        }
 
        m->pMusicController->UpdatePlaylist(list, mode);
@@ -306,11 +316,10 @@ void CCategoryLayout::t_OnCtxtUpdate(enum EActionType type, int lid)
                        delete sinfo;
                }
        }
-       else {
+       else
                eina_list_free(list);
-       }
 
-       CCommonUI::UpdatePlaybackView((EAddType)type, Layout(), t.focused_item);
+       CCommonUI::UpdatePlaybackView(mode, Layout(), t.focused_item);
 }
 
 
@@ -1356,11 +1365,7 @@ void CCategoryLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Ke
                                ctxtinfo->cbdata = this;
                                ctxtinfo->update = sm_CbCtxtUpdate;
                                ctxtinfo->close = sm_CbCtxtClose;
-                               if (t.depth == E_DEPTH_SONG) {
-                                       ctxtinfo->type = CONTEXT_TYPE_SONG;
-                                       ctxtinfo->context = itinfo->sinfo;
-                               }
-                               else if (t.depth == E_DEPTH_ALBUM) {
+                               if (t.depth == E_DEPTH_ALBUM) {
                                        ctxtinfo->type = CONTEXT_TYPE_ALBUM;
                                        ctxtinfo->context = itinfo->alinfo;
                                }
index 27c1b22..074684a 100644 (file)
@@ -281,19 +281,32 @@ void CCategorySongsLayout::m_OnCtxtUpdate(EActionType type, int lid)
        if (!m->ctxtinfo || !m->ctxtinfo->context)
                return;
 
-       if (type == ACTION_TYPE_ADDNEXT)
+       list = eina_list_append(list, m->ctxtinfo->context);
+
+       switch (type) {
+       case ACTION_TYPE_PLAY:
+               mode = ADD_TYPE_FRESH;
+               break;
+
+       case ACTION_TYPE_ADDNEXT:
                mode = ADD_TYPE_NEXT;
-       else
+               break;
+
+       case ACTION_TYPE_ADDLAST:
                mode = ADD_TYPE_END;
+               break;
 
-       list = eina_list_append(list, m->ctxtinfo->context);
-       if (type == ACTION_TYPE_ADDTO) {
-               if (!m->mhandle->MediaAddsongsPlaylist(lid, list))
-                       _ERR(" Adding songs to playlist failed ");
-               else
+       case ACTION_TYPE_ADDTO:
+               if (m->mhandle->MediaAddsongsPlaylist(lid, list))
                        CCommonUI::CreateMsgBox(m->base, MUSIC_TEXT_ADDTO_MSG);
-
+               else
+                       _ERR(" Adding songs to playlist failed ");
                return;
+
+       default:
+               _ERR("Invalid Action Type");
+               ASSERT(0);
+               break;
        }
 
        m->mhandle->UpdatePlaylist(list, mode);
@@ -304,7 +317,7 @@ void CCategorySongsLayout::m_OnCtxtUpdate(EActionType type, int lid)
                m->mhandle->SetCurrentSong(((CSongInfo *)m->ctxtinfo->context)->Id());
        }
 
-       CCommonUI::UpdatePlaybackView((EAddType)type, Layout(), m->focused_item);
+       CCommonUI::UpdatePlaybackView(mode, Layout(), m->focused_item);
 }
 
 
index 058104b..352056f 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <Eina.h>
+#include <AppCommon.h>
 #include "i18n.h"
 #include "define.h"
 #include "dbg.h"
@@ -147,46 +148,51 @@ void CCommonUI::CreateMsgBox(Evas_Object *base, const char *msg)
 void CCommonUI::UpdatePlaybackView(EAddType type,
                Evas_Object *layout, Elm_Object_Item *focused_item)
 {
-       Evas_Object *obj;
+       ASSERT(layout);
 
+       Evas_Object *obj = NULL;
        CViewMgr* vmgr = CViewMgr::GetInstance();
-       if (!vmgr || !layout)
-               return;
+       ASSERT(vmgr);
 
-       obj = NULL;
        if (!focused_item)
                obj = elm_object_focused_object_get(layout);
 
-       SParcel parcel;
-       memset(&parcel, 0, sizeof(SParcel));
-       parcel.updateType = E_PLAYLIST_UPDATE;
-
-       if (!vmgr->UpdateView((const char *)MUSIC_PLAYBACK_VIEW, &parcel)) {
-               if (!vmgr->PushView(MUSIC_PLAYBACK_VIEW, NULL))
-                       _ERR(" viewmgr  push view  failed ");
+       const char *msgStr = NULL;
+       switch (type) {
+       case ADD_TYPE_FRESH:
+               {
+                       SParcel parcel;
+                       memset(&parcel, 0, sizeof(SParcel));
+                       parcel.updateType = E_PLAYLIST_UPDATE;
+                       if (!vmgr->PushView((const char *)MUSIC_PLAYBACK_VIEW, &parcel))
+                               _ERR("PushView of PlaybackView Failed");
+               }
                return;
-       }
 
-       if (type == ADD_TYPE_FRESH) {
-               if (!vmgr->PushView(MUSIC_PLAYBACK_VIEW, NULL))
-                       _ERR(" viewmgr show failed ");
+       case ADD_TYPE_NEXT:
+               msgStr = MUSIC_TEXT_NEXT_MSG;
+               break;
 
-               return;
+       case ADD_TYPE_END:
+               msgStr = MUSIC_TEXT_LAST_MSG;
+               break;
+
+       default:
+               _ERR("Invalid Add Type!!");
+               ASSERT(0);
+               break;
        }
 
        if (focused_item) {
-               if (!vmgr->PushView(MUSIC_BASE_VIEW, NULL)) {
-                       _ERR(" viewmgr show failed ");
+               // Pop ContextView to show BaseView
+               if (!vmgr->PopView()) {
+                       _ERR("PopView to show BaseView Failed");
                        return;
                }
                elm_object_item_focus_set(focused_item, EINA_TRUE);
-       } else {
-               if (obj)
-                       elm_object_focus_set(obj, EINA_TRUE);
        }
+       else if (obj)
+               elm_object_focus_set(obj, EINA_TRUE);
 
-       if (type == ADD_TYPE_NEXT)
-               CreateMsgBox(layout, MUSIC_TEXT_NEXT_MSG);
-       else
-               CreateMsgBox(layout, MUSIC_TEXT_LAST_MSG);
+       CreateMsgBox(layout, msgStr);
 }
index ad6c08b..6471d2a 100644 (file)
@@ -301,11 +301,6 @@ void CFolderLayout::m_OnCtxtUpdate(EActionType type, int lid)
        if (!m->ctxtinfo || !m->ctxtinfo->context)
                return;
 
-       if (type == ACTION_TYPE_ADDNEXT)
-               mode = ADD_TYPE_NEXT;
-       else
-               mode = ADD_TYPE_END;
-
        if (m->depth == E_DEPTH_SONG) {
                sinfo = (CSongInfo *)m->ctxtinfo->context;
                list = eina_list_append(list, sinfo);
@@ -316,13 +311,30 @@ void CFolderLayout::m_OnCtxtUpdate(EActionType type, int lid)
                sinfo = (CSongInfo *)eina_list_data_get(list);
        }
 
-       if (type == ACTION_TYPE_ADDTO) {
-               if (!m->mhandle->MediaAddsongsPlaylist(lid, list))
-                       _ERR(" Adding songs to playlist failed ");
-               else
-                       CCommonUI::CreateMsgBox(m->base, MUSIC_TEXT_ADDTO_MSG);
+       switch (type) {
+       case ACTION_TYPE_PLAY:
+               mode = ADD_TYPE_FRESH;
+               break;
+
+       case ACTION_TYPE_ADDNEXT:
+               mode = ADD_TYPE_NEXT;
+               break;
 
+       case ACTION_TYPE_ADDLAST:
+               mode = ADD_TYPE_END;
+               break;
+
+       case ACTION_TYPE_ADDTO:
+               if (m->mhandle->MediaAddsongsPlaylist(lid, list))
+                       CCommonUI::CreateMsgBox(m->base, MUSIC_TEXT_ADDTO_MSG);
+               else
+                       _ERR(" Adding songs to playlist failed ");
                return;
+
+       default:
+               _ERR("Invalid Action Type");
+               ASSERT(0);
+               break;
        }
 
        m->mhandle->UpdatePlaylist(list, mode);
index bfe5a6b..510098f 100644 (file)
@@ -304,11 +304,6 @@ void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid)
                return;
        }
 
-       if (!m->mgr->PushView(MUSIC_PLAYBACK_VIEW, NULL)) {
-               _ERR("CViewMgr::PushView failed");
-               return;
-       }
-
        elm_object_item_focus_set(m->focused_item, EINA_TRUE);
 }
 
@@ -325,11 +320,6 @@ void CPlaybackView::sm_CbCtxtClose(void *dt)
                return;
        }
 
-       if (!m->mgr->PushView(MUSIC_PLAYBACK_VIEW, NULL)) {
-               _ERR("CViewMgr::PushView failed");
-               return;
-       }
-
        elm_object_item_focus_set(m->focused_item, EINA_TRUE);
 }
 
@@ -978,7 +968,7 @@ void CPlaybackView::m_KeyBackPress(void)
        }
 
        t_OnHide();
-       m->mgr->PushView(MUSIC_BASE_VIEW, NULL);
+       m->mgr->PopView();
 }
 
 
index cd64474..44cc0a5 100644 (file)
@@ -105,42 +105,52 @@ void CPlaylistLayout::m_PlaylistCtxtAction(EActionType type)
 
        t.c_catinfo->Duplicate(catinfo);
 
-       if (type == ACTION_TYPE_DELETE) {
-               id = catinfo->CategoryId();
-               if (!CMusicController::GetInstance()->MediaDeletePlaylist(id))
-                       _ERR(" Delete playlist failed ");
-
-               t_UpdateLayout(false);
-               elm_object_focus_set(t.grid, EINA_TRUE);
-
-       }
-       else if (type == ACTION_TYPE_RENAME) {
-               text = catinfo->Name();
-               if (t.epopup->FlagCreate())
-                       t.epopup->Destroy();
+       switch (type) {
+       case ACTION_TYPE_DELETE:
+               {
+                       id = catinfo->CategoryId();
+                       if (!CMusicController::GetInstance()->MediaDeletePlaylist(id))
+                               _ERR(" Delete playlist failed ");
+
+                       t_UpdateLayout(false);
+                       elm_object_focus_set(t.grid, EINA_TRUE);
+               }
+               break;
 
-               t.epopup->Create(t.base, text, sm_CbEntryRename, this);
+       case ACTION_TYPE_RENAME:
+               {
+                       text = catinfo->Name();
+                       if (t.epopup->FlagCreate())
+                               t.epopup->Destroy();
 
-       }
-       else if (type == ACTION_TYPE_ADDSONG) {
-               t.depth = E_DEPTH_SELECT_LIST;
-               t.sel_type = SELECT_ADD;
-               t_UpdateLayoutWithFocus();
+                       t.epopup->Create(t.base, text, sm_CbEntryRename, this);
+               }
+               break;
 
-       }
-       else if (type == ACTION_TYPE_REMOVESONG) {
-               if (catinfo->SongCount() == 0) {
-                       elm_object_item_focus_set(t.focused_item, EINA_TRUE);
-                       CCommonUI::CreateMsgBox(Layout(), MUSIC_TEXT_NO_SONGS);
-                       return;
+       case ACTION_TYPE_ADDSONG:
+               {
+                       t.depth = E_DEPTH_SELECT_LIST;
+                       t.sel_type = SELECT_ADD;
+                       t_UpdateLayoutWithFocus();
                }
-               t.depth = E_DEPTH_SELECT_LIST;
-               t.sel_type = SELECT_REMOVE;
-               t_UpdateLayoutWithFocus();
+               break;
+
+       case ACTION_TYPE_REMOVESONG:
+               {
+                       if (catinfo->SongCount() == 0) {
+                               elm_object_item_focus_set(t.focused_item, EINA_TRUE);
+                               CCommonUI::CreateMsgBox(Layout(), MUSIC_TEXT_NO_SONGS);
+                               return;
+                       }
+                       t.depth = E_DEPTH_SELECT_LIST;
+                       t.sel_type = SELECT_REMOVE;
+                       t_UpdateLayoutWithFocus();
+               }
+               break;
 
-       }
-       else {
+       default:
                elm_object_item_focus_set(t.focused_item, EINA_TRUE);
+               break;
        }
 }
 
index 8e776b5..69a92f1 100644 (file)
@@ -199,19 +199,32 @@ void CSongLayout::m_OnCtxtUpdate(EActionType type, int lid)
        if (!m->ctxtinfo || !m->ctxtinfo->context)
                return;
 
-       if (type == ACTION_TYPE_ADDNEXT)
+       list = eina_list_append(list, m->ctxtinfo->context);
+
+       switch (type) {
+       case ACTION_TYPE_PLAY:
+               mode = ADD_TYPE_FRESH;
+               break;
+
+       case ACTION_TYPE_ADDNEXT:
                mode = ADD_TYPE_NEXT;
-       else
+               break;
+
+       case ACTION_TYPE_ADDLAST:
                mode = ADD_TYPE_END;
+               break;
 
-       list = eina_list_append(list, m->ctxtinfo->context);
-       if (type == ACTION_TYPE_ADDTO) {
-               if (!m->mhandle->MediaAddsongsPlaylist(lid, list))
-                       _ERR(" Adding songs to playlist failed ");
-               else
+       case ACTION_TYPE_ADDTO:
+               if (m->mhandle->MediaAddsongsPlaylist(lid, list))
                        CCommonUI::CreateMsgBox(m->base, MUSIC_TEXT_ADDTO_MSG);
-
+               else
+                       _ERR(" Adding songs to playlist failed ");
                return;
+
+       default:
+               _ERR("Invalid Action Type");
+               ASSERT(0);
+               break;
        }
 
        m->mhandle->UpdatePlaylist(list, mode);
@@ -222,7 +235,7 @@ void CSongLayout::m_OnCtxtUpdate(EActionType type, int lid)
                m->mhandle->SetCurrentSong(((CSongInfo *)m->ctxtinfo->context)->Id());
        }
 
-       CCommonUI::UpdatePlaybackView((EAddType)type, Layout(), m->focused_item);
+       CCommonUI::UpdatePlaybackView(mode, Layout(), m->focused_item);
 }