Refactoring of callback mechanism / Modification focus of playback view 58/37358/2
authorKim Tae Soo <taesoo46.kim@samsung.com>
Wed, 25 Mar 2015 07:01:00 +0000 (16:01 +0900)
committerKim Tae Soo <taesoo46.kim@samsung.com>
Wed, 25 Mar 2015 07:10:41 +0000 (16:10 +0900)
Change-Id: I06d3fbb09647428848585e75070af89f368b1ac2
Signed-off-by: Kim Tae Soo <taesoo46.kim@samsung.com>
include/playback-view.h
src/main.cpp
src/views/playback-view.cpp

index 104f26a..7d4c0b8 100644 (file)
@@ -36,8 +36,12 @@ private:
 
 private:
        static Eina_Bool sm_CbUpdateSlider(void *dt);
+
        static Eina_Bool sm_CbLongpressTimer(void *dt);
+       void m_OnLongpressTimer(void);
+
        static Eina_Bool sm_CbWaitTimer(void *dt);
+       void m_OnWaitTimer(void);
 
        static void sm_CbItemSelect(void *data, Evas_Object *obj, void *event_info);
 
@@ -45,7 +49,10 @@ private:
        void m_OnGenlistItemCheckClicked(Elm_Object_Item *it, const char *emission, const char *source);
 
        static void sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid);
+       void m_OnCtxtUpdate(EActionType type, int lid);
+
        static void sm_CbCtxtClose(void *dt);
+       void m_OnCtxtClose(void);
 
        static void sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text);
        void m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text);
index 28fcf8f..a98f343 100644 (file)
@@ -69,8 +69,7 @@ private:
        static void sm_CbPopView(void* cookie, const char *szDestroyViewId, CBaseView *pShowView)
        {
                const char *viewId = pShowView->ViewId();
-               if (!strcmp(viewId, MUSIC_CONTEXT_VIEW) ||
-                       !strcmp(viewId, MUSIC_PLAYBACK_VIEW))
+               if (!strcmp(viewId, MUSIC_CONTEXT_VIEW))
                        CViewMgr::GetInstance()->UpdateView(viewId, NULL);
        }
 
index bf30235..35f1642 100644 (file)
@@ -112,7 +112,6 @@ struct SPlaybackView {
        SContentInfo *ctxtinfo;
        int press_status;
 
-       CPlaybackView *parent;
        CHandleVolume *pHandleVolume;
 
        SPlaybackView() {
@@ -202,30 +201,43 @@ Eina_Bool CPlaybackView::sm_CbUpdateSlider(void *dt)
 
 Eina_Bool CPlaybackView::sm_CbLongpressTimer(void *dt)
 {
-       SPlaybackView *m = (SPlaybackView *)dt;
-
-       m->parent->m_HandleOnRepeated();
+       CPlaybackView *root = (CPlaybackView *)dt;
+       if (root)
+               root->m_OnLongpressTimer();
 
        return ECORE_CALLBACK_RENEW;
 }
 
 
+void CPlaybackView::m_OnLongpressTimer(void)
+{
+       m_HandleOnRepeated();
+}
+
+
 Eina_Bool CPlaybackView::sm_CbWaitTimer(void *dt)
 {
-       SPlaybackView *m = (SPlaybackView *)dt;
+       CPlaybackView *root = (CPlaybackView *)dt;
+       if (root)
+               root->m_OnWaitTimer();
+
+       return ECORE_CALLBACK_CANCEL;
+}
+
 
+void CPlaybackView::m_OnWaitTimer(void)
+{
        m->press_status = PRESS_LONG;
        if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
                /* Handle long press */
-               m->parent->m_PlaybackPause();
-               m->etLongPress = ecore_timer_add(LP_INTERVAL, sm_CbLongpressTimer, m);
+               m_PlaybackPause();
+               m->etLongPress = ecore_timer_add(LP_INTERVAL, sm_CbLongpressTimer, this);
        }
        else {
                m->press_status = PRESS_LONG_PAUSE;
        }
 
        m->etWait = NULL;
-       return ECORE_CALLBACK_CANCEL;
 }
 
 
@@ -264,17 +276,21 @@ void CPlaybackView::m_OnGenlistItemCheckClicked(Elm_Object_Item *it, const char
 
 void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid)
 {
-       SPlaybackView *m = (SPlaybackView *)dt;
-       SItemInfo *itinfo = NULL;
-       Elm_Object_Item *focucedItem = NULL;
+       CPlaybackView *root = (CPlaybackView *)dt;
+       if (root)
+               root->m_OnCtxtUpdate(type, lid);
+}
 
-       if (!m)
-               return;
+
+void CPlaybackView::m_OnCtxtUpdate(EActionType type, int lid)
+{
+       SItemInfo *itinfo = NULL;
+       Elm_Object_Item *focusedItem = NULL;
 
        if (!m->ctxtinfo || !m->ctxtinfo->context)
                return;
 
-       itinfo = m->parent->m_FindItemInfoFromSong(m->elInfo,
+       itinfo = m_FindItemInfoFromSong(m->elInfo,
                (CSongInfo *)m->ctxtinfo->context);
        if (!itinfo) {
                _ERR(" Unable to find song in the list ");
@@ -283,23 +299,28 @@ void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid)
 
        if (type == ACTION_TYPE_DELETE) {
                itinfo->check_status = true;
-               m->parent->m_DeleteSelectedItems();
+               m_DeleteSelectedItems();
 
                if (!m->mgr->PopView()) {
                        _ERR("CViewMgr::PopView failed");
                        return;
                }
 
-               focucedItem = m->cs_itinfo->item;
+               SParcel parcel;
+               memset(&parcel, 0, sizeof(SParcel));
+               parcel.updateType = E_PLAYLIST_UPDATE;
+               t_OnUpdate(&parcel);
+
+               focusedItem = m->cs_itinfo->item;
        }
        else { // ACTION_TYPE_PLAY
                if (m->ctxtinfo->status == PLAY_STATUS_PLAY)
-                       m->parent->m_KeyPausePress();
+                       m_KeyPausePress();
                else {
                        if (itinfo == m->cs_itinfo)
-                               m->parent->m_KeyPlayPress();
+                               m_KeyPlayPress();
                        else
-                               m->parent->m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item);
+                               m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item);
                }
 
                if (!m->mgr->PopView()) {
@@ -307,20 +328,26 @@ void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid)
                        return;
                }
 
-               focucedItem = m->focused_item;
+               focusedItem = m->focused_item;
        }
 
-       elm_object_item_focus_set(focucedItem, EINA_TRUE);
+       if (focusedItem) {
+               elm_genlist_item_show(focusedItem, ELM_GENLIST_ITEM_SCROLLTO_IN);
+               elm_object_item_focus_set(focusedItem, EINA_TRUE);
+       }
 }
 
 
 void CPlaybackView::sm_CbCtxtClose(void *dt)
 {
-       SPlaybackView *m = (SPlaybackView *)dt;
+       CPlaybackView *root = (CPlaybackView *)dt;
+       if (root)
+               root->m_OnCtxtClose();
+}
 
-       if (!m)
-               return;
 
+void CPlaybackView::m_OnCtxtClose(void)
+{
        if (!m->mgr->PopView()) {
                _ERR("CViewMgr::PopView failed");
                return;
@@ -1564,7 +1591,7 @@ void CPlaybackView::m_HandleOnPressed(Evas_Object *obj)
        m->press_status = PRESS_SHORT;
        m->eoPressedObj = obj;
 
-       m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, m);
+       m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, this);
 }
 
 
@@ -1637,8 +1664,6 @@ bool CPlaybackView::Create(void *data)
 
                _WHEN_SUCCESS{
                        m->press_status = PRESS_SHORT;
-                       m->parent = this;
-
                        evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m);
 
                        m_AddControlButtons();
@@ -1783,12 +1808,6 @@ void CPlaybackView::t_OnShow(void)
 
        m_UpdateCurrentSongInfo();
 
-       if (m->cs_itinfo) {
-               elm_genlist_item_show(m->cs_itinfo->item,
-                       ELM_GENLIST_ITEM_SCROLLTO_IN);
-               elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE);
-       }
-
        state = m->hMusicController->PlayState();
        if (state == PLAY_STATUS_INITIAL || state == PLAY_STATUS_STOP) {
                m_RemovePlaylist();
@@ -1797,6 +1816,12 @@ void CPlaybackView::t_OnShow(void)
                m_UpdateCurrentSongInfo();
        }
 
+       if (m->cs_itinfo) {
+               elm_genlist_item_show(m->cs_itinfo->item,
+                       ELM_GENLIST_ITEM_SCROLLTO_IN);
+               elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE);
+       }
+
        evas_object_show(m->eoBase);
 }
 
@@ -1903,7 +1928,7 @@ void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_
                        else
                                ctxtinfo->status = PLAY_STATUS_PAUSE;
 
-                       ctxtinfo->cbdata = m;
+                       ctxtinfo->cbdata = this;
                        ctxtinfo->update = sm_CbCtxtUpdate;
                        ctxtinfo->close = sm_CbCtxtClose;
                        ctxtinfo->type = CONTEXT_TYPE_PLAYSONG;