Fix corner cases of view life cycle. 83/100883/1
authorHermet Park <hermet@hermet.pe.kr>
Tue, 29 Nov 2016 12:21:30 +0000 (21:21 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Tue, 29 Nov 2016 12:21:30 +0000 (21:21 +0900)
View life-cycle hasn't been tested strictly.
So, I tested it and fix all corner cases that I could find.

Change-Id: Ia18c3b029e0302487978a03cb6e136d13f5b1ebf

src/include/interface/UiIfaceOverlay.h
src/include/interface/UiIfaceView.h
src/lib/efl/mobile/UiMenu.cpp
src/lib/efl/mobile/UiPopup.cpp
src/lib/interface/UiIfaceOverlay.cpp
src/lib/interface/UiIfaceView.cpp
src/lib/interface/UiIfaceViewmgr.cpp

index 44b831169937d4548314996b01838d0654d51910..bc15461468c5993cba0265644bc0f11d5cf8068c 100644 (file)
@@ -75,7 +75,7 @@ public:
         *
         *  @see deactivate()
         */
-       virtual int activate() = 0;
+       virtual int activate();
 
        /**
         *  @brief Overlay deactivate.
@@ -86,7 +86,7 @@ public:
         *
         *  @see activate()
         */
-       virtual int deactivate() = 0;
+       virtual int deactivate();
 
        /**
         *  @brief Returns the active status of overlay.
index 34611067b98c31e2ff4fc7689bcfceefb7779759..678193f6656270e3dba194efae9347b9c6444310 100644 (file)
@@ -362,6 +362,7 @@ private:
        _UI_DECLARE_PRIVATE_IMPL(UiIfaceView);
        _UI_DECLARE_FRIENDS(UiIfaceViewmgr);
        _UI_DECLARE_FRIENDS(UiIfaceApp);
+       _UI_DECLARE_FRIENDS(UiIfaceOverlay);
 };
 
 }
index c3f5595209e01d82ebb24375745b6c43056275bf..4f530d8125c33c9211cf5d7b5445e7e7777e75a3 100644 (file)
@@ -30,7 +30,7 @@ static void _ctxpopupDelCb(void *data, Evas *e, Eo *obj, void *event_info)
        menu->unsetContent();
 }
 
-static bool _updateMenu(UiMenu *menu)
+static int _updateMenu(UiMenu *menu)
 {
        Elm_Win *win = menu->getBase();
        if (!win) return UI_VIEWMGR_ERROR_NOT_PERMITTED;
@@ -104,14 +104,17 @@ int UiMenu::deactivate()
        }
 
        elm_ctxpopup_dismiss(ctxpopup);
-       dynamic_cast<UiView *>(this->getView())->onResume();
 
-       return UI_VIEWMGR_ERROR_NONE;
+       return UiBaseOverlay::deactivate();
 }
 
 int UiMenu::activate()
 {
-       bool ret = _updateMenu(this);
+       int ret = UiBaseOverlay::activate();
+
+       if (ret != UI_VIEWMGR_ERROR_NONE) return ret;
+
+       ret = _updateMenu(this);
        if (ret != UI_VIEWMGR_ERROR_NONE) dynamic_cast<UiView *>(this->getView())->onPause();
 
        return ret;
index aa00d4e1befffc39fec0183af75947d36ea1ea44..1c62b94c0b6d053f11435276bb2120abd168a51b 100644 (file)
@@ -21,7 +21,7 @@ using namespace efl_viewmanager;
 
 static int _updatePopup(UiPopup *popup)
 {
-       if (popup->getView()->getState() != UI_VIEW_STATE_ACTIVATE)
+       if (popup->getView()->getState() != UI_VIEW_STATE_PAUSE)
                return UI_VIEWMGR_ERROR_NOT_PERMITTED;
 
        Elm_Win *win = popup->getBase();
@@ -82,15 +82,16 @@ int UiPopup::deactivate()
        }
 
        elm_popup_dismiss(popup);
-       dynamic_cast<UiView*>(this->getView())->onResume();
 
-       return UI_VIEWMGR_ERROR_NONE;
+       return UiBaseOverlay::deactivate();
 }
 
 int UiPopup::activate()
 {
-       int ret = _updatePopup(this);
-       if (ret != UI_VIEWMGR_ERROR_NONE) dynamic_cast<UiView*>(this->getView())->onPause();
+       int ret = UiBaseOverlay::activate();
+       if (ret != UI_VIEWMGR_ERROR_NONE) return ret;
+
+       ret = _updatePopup(this);
        return ret;
 }
 
index b5fc46120b2c344bc6b5608c51fc421d46ccd239..5b7c76bf22e7f314c48cfe7dace3c5a95fa84710 100644 (file)
@@ -78,7 +78,6 @@ UiIfaceView *UiIfaceOverlayImpl::getView() const noexcept
        return this->_view;
 }
 
-
 /***********************************************************************************************/
 /* External class Implementation                                                               */
 /***********************************************************************************************/
@@ -116,3 +115,17 @@ void UiIfaceOverlay::onBack()
 {
        this->deactivate();
 }
+
+int UiIfaceOverlay::activate()
+{
+       this->_impl->_view->onPause();
+
+       return UI_VIEWMGR_ERROR_NONE;
+}
+
+int UiIfaceOverlay::deactivate()
+{
+       this->_impl->_view->onResume();
+
+       return UI_VIEWMGR_ERROR_NONE;
+}
index f4efd152277adf9f9d103118e03ce7a0ec7be7a0..947edd5dd0d4a186e48b83880442279b28383a11 100644 (file)
@@ -150,7 +150,7 @@ UiIfaceViewImpl::~UiIfaceViewImpl()
                if ((view_count > 1) && (this->_viewmgr->getLastView() == this->_view))
                {
                        auto pview = this->_viewmgr->getView(view_count - 2);
-                       pview->onLoad();
+                       if (!pview->getContent()) pview->onLoad();
                        this->_viewmgr->popViewFinished(pview);
                        activateTopView = true;
                }
index 563acf535f320f1e2dc30f8b74d8204b44acc9ab..1e813f93c0d1a0bed14619f0a2edd825042cc3d8 100644 (file)
@@ -248,8 +248,7 @@ int UiIfaceViewmgrImpl::pushView(UiIfaceView *view)
        //If view manager is not activated yet, don't load view.
        if (!this->isActivated()) return UI_VIEWMGR_ERROR_NONE;
 
-       view->onLoad();
-       view->onDeactivate();
+       if (!view->getContent()) view->onLoad();
 
        if (this->_viewList.size() != 1) {
                this->setEventBlock(view, true);
@@ -294,7 +293,7 @@ int UiIfaceViewmgrImpl::popView()
        auto nx = prev(this->_viewList.end(), 2);
        auto pview = *nx;
        pview->_setPopping(true);
-       pview->onLoad();
+       if (!pview->getContent()) pview->onLoad();
        pview->onDeactivate();
        this->setEventBlock(pview, true);
 
@@ -393,8 +392,7 @@ int UiIfaceViewmgrImpl::activate()
 
        auto view = this->getLastView();
 
-       view->onLoad();
-       view->onDeactivate();
+       if (!view->getContent()) view->onLoad();
        view->onActivate();
 
        this->_inst->activateTopView();