fix wrong behavior of insert_view_before/after() APIs. 27/91927/2
authorHermet Park <hermet@hermet.pe.kr>
Wed, 12 Oct 2016 07:43:01 +0000 (16:43 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Wed, 12 Oct 2016 07:47:13 +0000 (16:47 +0900)
Previously, the apis won't have considered considerably.
It's implmeneted better.

Change-Id: I885870a52d53417445a93a9bbc7e4f47afe47827

src/include/interface/UiIfaceView.h
src/lib/efl/mobile/c/ui_viewmgr.cpp
src/lib/interface/UiIfaceView.cpp
src/lib/interface/UiIfaceViewmgr.cpp

index d6d3e2614092921be7501827e48707a3a10e8b69..48f15784d244f487b622c01ce08a1ed51dfb42b0 100644 (file)
@@ -323,6 +323,8 @@ private:
         */
        void _setViewmgr(UiIfaceViewmgr *viewmgr);
 
+       void setPopping(bool popping);
+
        /**
         *  @brief Return the viewmgr instance.
         *
index bda2b5527ad095569296adad919d010324a302be..a720596af7b0457bf77f10899dc6335cb3e57467 100644 (file)
@@ -14,9 +14,9 @@ EAPI int ui_viewmgr_push_view(ui_view *view)
 
 EAPI int ui_viewmgr_insert_view_before(ui_view *view, ui_view *before)
 {
-       if (!before || !view)
+       if (!view)
        {
-               LOGE("Invalid Parameter view = %p, before = %p", view, before);
+               LOGE("Invalid Parameter view = %p", view);
                return TIZEN_ERROR_INVALID_PARAMETER;
        }
 
@@ -25,9 +25,9 @@ EAPI int ui_viewmgr_insert_view_before(ui_view *view, ui_view *before)
 
 EAPI int ui_viewmgr_insert_view_after(ui_view *view, ui_view *after)
 {
-       if (!after || !view)
+       if (!view)
        {
-               LOGE("Invalid Parameter view = %p, after = %p", view, after);
+               LOGE("Invalid Parameter view = %p", view);
                return TIZEN_ERROR_INVALID_PARAMETER;
        }
 
index ab49abdc480cbaa9b754d96ad875d9381ac08f98..e50fb64f1aea66f036fdf2db12cf491fcde029e0 100644 (file)
@@ -45,6 +45,7 @@ private:
        unsigned int _rotationCount = 0;                        ///< The number of available rotations.
        bool _eventBlock = false;                               ///< State of event block.
        bool _removableContent = true;                          ///< When this value is true, view removes it's content internally on unload state.
+       bool _popping = false;
 
 public:
        int setEventBlock(bool block);
@@ -137,8 +138,24 @@ UiIfaceViewImpl::UiIfaceViewImpl(UiIfaceView *view, const char *name)
 
 UiIfaceViewImpl::~UiIfaceViewImpl()
 {
-       this->_viewmgr->removeView(this->_view);
 
+       //This view is destroyed instantly.
+       if (this->_viewmgr && !this->_popping)
+       {
+               //Activate the previous view in this case.
+               unsigned int view_count = this->_viewmgr->getViewCount();
+
+               if ((view_count > 1) && (this->_viewmgr->getLastView() == this->_view))
+               {
+                       auto pview = this->_viewmgr->getView(view_count - 2);
+                       this->_viewmgr->popViewFinished(pview);
+               }
+
+               this->onUnload();
+               this->onDestroy();
+       }
+
+       if (this->_viewmgr) this->_viewmgr->removeView(this->_view);
        if (this->_rotations) delete[](this->_rotations);
 }
 
@@ -416,3 +433,8 @@ void UiIfaceView::onRegionChanged(const char *region)
 void UiIfaceView::onLanguageChanged(const char *language)
 {
 }
+
+void UiIfaceView::setPopping(bool popping)
+{
+       this->_impl->_popping = popping;
+}
index 75e4fbbe70298d55e3abc56609c24fbdbc1d4625..aa98fa8e284f8b9ef8b85c553e10f05cb20aec2c 100644 (file)
@@ -188,6 +188,7 @@ void UiIfaceViewmgrImpl::popViewFinished(UiIfaceView *view)
        //The previous view has been popped. It should become activate.
        view->onActivate();
        this->setEventBlock(view, false);
+       view->setPopping(false);
 }
 
 UiIfaceViewmgrImpl::UiIfaceViewmgrImpl(UiIfaceViewmgr* viewmgr)
@@ -283,6 +284,7 @@ int UiIfaceViewmgrImpl::popView()
                return TIZEN_ERROR_NONE;
        }
 
+       view->setPopping(true);
        view->onDeactivate();
        this->setEventBlock(view, true);
 
@@ -291,6 +293,7 @@ int UiIfaceViewmgrImpl::popView()
        //previous page is to be an active page.
        auto nx = prev(this->_viewList.end(), 2);
        auto pview = *nx;
+       pview->setPopping(true);
        pview->onLoad();
        pview->onDeactivate();
        this->setEventBlock(pview, true);