MainView: Replace MainView singleton with simple object. 82/92182/4
authorKamil Lipiszko <k.lipiszko@samsung.com>
Thu, 13 Oct 2016 14:33:52 +0000 (16:33 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Mon, 17 Oct 2016 11:31:34 +0000 (04:31 -0700)
This commit changes MainView pattern from singleton to
simple object. Now it is created during application startup
and is passed to other pages and page views as constructor's
argument.

Change-Id: I8f8dcf982f0da55d99be169ee5106ff6575a5356

24 files changed:
clock/inc/Controller/MainController.h
clock/inc/Presenter/DeleteAlarmPresenter.h
clock/inc/Presenter/EditAlarmPresenter.h
clock/inc/View/AlarmView.h
clock/inc/View/DeleteAlarmView.h
clock/inc/View/EditAlarmView.h
clock/inc/View/MainView.h
clock/inc/View/PageView.h
clock/inc/View/StopWatchView.h
clock/inc/View/TimerView.h
clock/inc/View/WeekFlagsView.h
clock/inc/View/WorldClockView.h
clock/src/Controller/MainController.cpp
clock/src/Presenter/DeleteAlarmPresenter.cpp
clock/src/Presenter/EditAlarmPresenter.cpp
clock/src/View/AlarmView.cpp
clock/src/View/DeleteAlarmView.cpp
clock/src/View/EditAlarmView.cpp
clock/src/View/MainView.cpp
clock/src/View/PageView.cpp
clock/src/View/StopWatchView.cpp
clock/src/View/TimerView.cpp
clock/src/View/WeekFlagsView.cpp
clock/src/View/WorldClockView.cpp

index 524b23a..fa11c51 100644 (file)
 
 #include "Utils/EventBus.h"
 #include "View/EditAlarmView.h"
+#include "View/DeleteAlarmView.h"
+#include "View/MainView.h"
 #include "Presenter/EditAlarmPresenter.h"
+#include "Presenter/DeleteAlarmPresenter.h"
 
 #include "View/AlarmView.h"
 #include "View/StopWatchView.h"
@@ -106,7 +109,7 @@ namespace controller {
                        /**
                         * @brief Constructs MainController class object.
                         */
-                       MainController() {};
+                       MainController();
 
                        /**
                         * @brief Creates new "Edit/Create" alarm page.
@@ -127,8 +130,12 @@ namespace controller {
                        presenter::StopWatchPresenter *stop_watch_presenter_;
                        presenter::TimerPresenter *timer_presenter_;
                        presenter::EditAlarmPresenter *edit_presenter_;
+                       presenter::DeleteAlarmPresenter *delete_presenter_;
 
-                       view::EditAlarmView *edit_view_;
+                       view::MainView main_view_;
+
+                       view::EditAlarmView edit_page_;
+                       view::DeleteAlarmView delete_page_;
 
                        /**
                         * @brief Creates new "Edit" alarm page.
index 14a737c..0d34a90 100644 (file)
@@ -26,6 +26,7 @@ namespace presenter {
        class DeleteAlarmPresenter {
                public:
                        DeleteAlarmPresenter(view::DeleteAlarmView *view, model::AlarmProvider *model);
+                       ~DeleteAlarmPresenter();
                private:
                        view::DeleteAlarmView *view_;
                        model::AlarmProvider *model_;
index f0ab43a..3213029 100644 (file)
@@ -24,6 +24,7 @@ namespace presenter {
        class EditAlarmPresenter {
                public:
                        EditAlarmPresenter(model::Alarm *alarm, view::EditAlarmView& view);
+                       ~EditAlarmPresenter();
                private:
                        model::Alarm *alarm_;
                        view::EditAlarmView &view_;
index f39f08c..b3cb240 100644 (file)
@@ -30,7 +30,7 @@ namespace view {
                        typedef std::function<void(int)> ToggleCallback;
                        typedef std::function<void(void)> ButtonClickedCallback;
 
-                       AlarmView();
+                       AlarmView(ui::IView &main);
                        void Clear();
                        int ItemAppend(utils::Time time, const char *name,
                                        const model::WeekFlags flags, bool active);
index 3fa9083..ca511f1 100644 (file)
@@ -28,7 +28,7 @@ namespace view {
                public:
                        typedef std::function<void(void)> ButtonClickedCallback;
 
-                       DeleteAlarmView();
+                       DeleteAlarmView(ui::IView &main);
 
                        void RegisterCancelButtonClickedCallback(ButtonClickedCallback cb) { onCancelButtonClicked_ = cb; }
                        void RegisterDeleteButtonClickedCallback(ButtonClickedCallback cb) { onDeleteButtonClicked_ = cb; }
@@ -38,7 +38,7 @@ namespace view {
                                        const model::WeekFlags flags, bool active);
                        std::vector<int> GetSelectedItems() const;
                protected:
-                       virtual void CreateContent();
+                       virtual void CreateContent(Evas_Object *parent);
                        virtual void DestroyContent();
                private:
                        Evas_Object *content_;
index 8c8493d..d4c8fac 100644 (file)
@@ -26,7 +26,7 @@
 #include "View/WeekFlagsView.h"
 
 namespace view {
-       class EditAlarmView : protected PageView {
+       class EditAlarmView : public PageView {
                public:
                struct AlarmViewInfo {
                        utils::Time time;
@@ -43,13 +43,14 @@ namespace view {
                        void RegisterEditDoneCallback(EditDoneCallback cb) { onEditDone_ = cb; }
                        void RegisterEditCancelCallback(EditCancelCallback cb) { onEditCancel_ = cb; }
 
-                       EditAlarmView();
+                       EditAlarmView(ui::IView &main);
+
                        Evas_Object *GetEvasObject();
 
                        const AlarmViewInfo& GetData() const { return data_; }
                        void SetData(const AlarmViewInfo &info);
                protected:
-                       virtual void CreateContent();
+                       virtual void CreateContent(Evas_Object *parent);
                        virtual void DestroyContent();
 
                private:
index 98b87de..d09de20 100644 (file)
@@ -53,9 +53,10 @@ namespace view {
                public:
 
                        /**
-                        * @brief Retrieves singleton instance.
+                        * @brief Constructs MainView class object
+                        * @remarks Creates base GUI
                         */
-                       static MainView &GetInstance();
+                       MainView();
 
                        /**
                         * @brief Destructor
@@ -91,13 +92,6 @@ namespace view {
                         */
                        IView *GetView(ViewType type);
                private:
-
-                       /**
-                        * @brief Constructs MainView class object
-                        * @remarks Creates base GUI
-                        */
-                       MainView();
-
                        /**
                         * Adds conformant to window.
                         */
index 8ce164c..2b61fdc 100644 (file)
@@ -44,7 +44,7 @@ namespace view {
                        /**
                         * @brief Constructs class object.
                         */
-                       PageView();
+                       PageView(ui::IView &main);
 
                        /**
                         * @brief Cleans all resources needed to be cleaned up.
@@ -54,7 +54,7 @@ namespace view {
                        /**
                         * @brief Creates page content.
                         */
-                       virtual void CreateContent() = 0;
+                       virtual void CreateContent(Evas_Object *parent) = 0;
 
                        /**
                         * @brief Creates page content.
@@ -82,14 +82,15 @@ namespace view {
                        void RegisterPoppedCallback(std::function<void(void)>);
 
                protected:
+                       Elm_Object_Item *navi_item_;
 
-                       /*
-                        * Get parent naviframe handle
+                       /**
+                        * Returns naviframe parent of the page.
                         */
                        Evas_Object *GetNaviframe();
-
-                       Elm_Object_Item *navi_item_;
                private:
+                       Evas_Object *naviframe_;
+
                        static void ItemDeletedCallback(void*, Evas_Object*, void *);
                        std::vector<std::function<void(void)>> onPopped_;
                        void EmitPoppedEvent();
index 09c07cb..af83dcb 100644 (file)
@@ -56,7 +56,7 @@ namespace view {
 
        class StopWatchView : public ui::IView {
        public:
-               StopWatchView();
+               StopWatchView(ui::IView &main);
                ~StopWatchView();
 
                Evas_Object *GetEvasObject(void);
index 4ee2adb..e3e0748 100644 (file)
@@ -53,7 +53,7 @@ namespace view {
        class TimerView : public ui::IView {
        public:
 
-               TimerView();
+               TimerView(ui::IView &main);
                ~TimerView();
 
                Evas_Object *GetEvasObject();
index 7132203..3ea4208 100644 (file)
 namespace view {
        class WeekFlagsView : public PageView {
                public:
-                       WeekFlagsView(model::WeekFlags &flags);
+                       WeekFlagsView(ui::IView &main, model::WeekFlags &flags);
                        Evas_Object *GetEvasObject();
                protected:
-                       virtual void CreateContent();
+                       virtual void CreateContent(Evas_Object *parent);
                        virtual void DestroyContent();
                private:
                        struct CheckBoxDesc {
index 603b678..b06a6a3 100644 (file)
@@ -42,7 +42,7 @@ namespace view {
 
        class WorldClockView: public ui::IView {
                public:
-                       WorldClockView();
+                       WorldClockView(ui::IView &main);
 
                        Evas_Object *GetEvasObject(){return world_clock_main_;};
 
@@ -62,7 +62,7 @@ namespace view {
 
                private:
                        void CreateTimezoneDetails();
-                       void CreateCustomLocationsList();
+                       void CreateCustomLocationsList(Evas_Object *parent);
                        void CreateTimezoneCitiesList();
                        Evas_Object *CreateFloatingButton();
 
index a4fb72d..16e7a22 100644 (file)
@@ -37,6 +37,12 @@ MainController &MainController::GetInstance()
        return instance;
 }
 
+MainController::MainController() :
+       edit_page_(main_view_), delete_page_(main_view_),
+       delete_presenter_(nullptr), edit_presenter_(nullptr)
+{
+}
+
 MainController::~MainController()
 {
 
@@ -58,12 +64,10 @@ int MainController::Init()
        stop_watch_model_ = new model::StopWatch();
        timer_model_ = new model::Timer();
 
-       MainView::GetInstance().CreateContent();
-
-       alarm_presenter_ = new AlarmPresenter((AlarmView *)MainView::GetInstance().GetView(ALARM), AlarmProvider::GetInstance());
-       world_clock_presenter_ = new WorldClockPresenter((WorldClockView *)MainView::GetInstance().GetView(WORLD_CLOCK), world_clock_model_);
-       stop_watch_presenter_ = new StopWatchPresenter((StopWatchView *)MainView::GetInstance().GetView(STOP_WATCH), stop_watch_model_);
-       timer_presenter_ = new TimerPresenter((TimerView *)MainView::GetInstance().GetView(TIMER), timer_model_);
+       alarm_presenter_ = new AlarmPresenter((AlarmView *)main_view_.GetView(ALARM), AlarmProvider::GetInstance());
+       world_clock_presenter_ = new WorldClockPresenter((WorldClockView *)main_view_.GetView(WORLD_CLOCK), world_clock_model_);
+       stop_watch_presenter_ = new StopWatchPresenter((StopWatchView *)main_view_.GetView(STOP_WATCH), stop_watch_model_);
+       timer_presenter_ = new TimerPresenter((TimerView *)main_view_.GetView(TIMER), timer_model_);
 
        listeners_.push_back(utils::EventBus::AddListener<AlarmCreateRequestEvent>(
                        std::bind(&MainController::CreateNewAlarmPage, this, _1)));
@@ -93,32 +97,23 @@ void MainController::Deinit()
 
 void MainController::CreateNewAlarmPage(Event &e)
 {
-       delete edit_view_;
        delete edit_presenter_;
 
-       edit_view_ = new EditAlarmView();
-       edit_presenter_ = new EditAlarmPresenter(nullptr, *edit_view_);
+       edit_presenter_ = new EditAlarmPresenter(nullptr, edit_page_);
 }
 
 void MainController::CreateEditAlarmPage(Event &e)
 {
        AlarmEditRequestEvent &ev = (AlarmEditRequestEvent&)e;
 
-       delete edit_view_;
        delete edit_presenter_;
 
-       edit_view_ = new EditAlarmView();
-       edit_presenter_ = new EditAlarmPresenter(&ev.GetAlarm(), *edit_view_);
+       edit_presenter_ = new EditAlarmPresenter(&ev.GetAlarm(), edit_page_);
 }
 
 void MainController::CreateNewDeleteAlarmsPage(Event &e)
 {
-       static DeleteAlarmView *view;
-       static DeleteAlarmPresenter *presenter;
-
-       if (view) delete view;
-       if (presenter) delete presenter;
+       delete delete_presenter_;
 
-       view = new DeleteAlarmView();
-       presenter = new DeleteAlarmPresenter(view, AlarmProvider::GetInstance());
+       delete_presenter_ = new DeleteAlarmPresenter(&delete_page_, AlarmProvider::GetInstance());
 }
index 7d55ec8..e3848ac 100644 (file)
@@ -16,6 +16,8 @@ DeleteAlarmPresenter::DeleteAlarmPresenter(DeleteAlarmView *view, AlarmProvider
 
        std::vector<std::reference_wrapper<Alarm>> alarms = model_->GetAlarms();
 
+       view_->PushPage();
+
        for (auto a: alarms) {
                int id = view_->ItemAppend(
                                a.get().GetTime(),
@@ -26,6 +28,11 @@ DeleteAlarmPresenter::DeleteAlarmPresenter(DeleteAlarmView *view, AlarmProvider
        }
 }
 
+DeleteAlarmPresenter::~DeleteAlarmPresenter()
+{
+       view_->PopPage();
+}
+
 void DeleteAlarmPresenter::OnDeleteButtonClicked()
 {
        std::vector<int> deleted = view_->GetSelectedItems();
index 1968eea..0980530 100644 (file)
@@ -16,6 +16,13 @@ EditAlarmPresenter::EditAlarmPresenter(model::Alarm *alarm, view::EditAlarmView&
        view_.RegisterEditDoneCallback(std::bind(&EditAlarmPresenter::OnEditDone, this));
        view_.RegisterEditCancelCallback(std::bind(&EditAlarmPresenter::OnEditCancel, this));
        view_.SetData(GetInfoForAlarm(alarm));
+
+       view_.PushPage();
+}
+
+EditAlarmPresenter::~EditAlarmPresenter()
+{
+       view_.PopPage();
 }
 
 view::EditAlarmView::AlarmViewInfo EditAlarmPresenter::GetDefaultInfo() const
index a28c874..76cee41 100644 (file)
@@ -140,10 +140,10 @@ void AlarmView::Del(void *data, Evas_Object *obj)
        delete id;
 }
 
-AlarmView::AlarmView()
+AlarmView::AlarmView(ui::IView &main)
 {
        /* Base Layout */
-       content_ = elm_layout_add(MainView::GetInstance().GetEvasObject());
+       content_ = elm_layout_add(main.GetEvasObject());
        evas_object_size_hint_weight_set(content_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        elm_layout_theme_set(content_, "layout", "application", "default");
        evas_object_show(content_);
index 378d517..e70df8f 100644 (file)
@@ -46,10 +46,9 @@ static char *Time2FormattedString(const Time &time)
        return strdup(formatted_time.str().c_str());
 }
 
-DeleteAlarmView::DeleteAlarmView()
-       : all_selected_(false)
+DeleteAlarmView::DeleteAlarmView(ui::IView &main)
+       : PageView(main), all_selected_(false)
 {
-       PushPage();
 }
 
 void DeleteAlarmView::ItemSelectToggle(void *data, Evas_Object *obj, void *event)
@@ -78,26 +77,26 @@ void DeleteAlarmView::ItemSelected(void *data, Evas_Object *obj, void *event)
        elm_genlist_item_selected_set(id->it, EINA_FALSE);
 }
 
-void DeleteAlarmView::CreateContent()
+void DeleteAlarmView::CreateContent(Evas_Object *parent)
 {
        elm_object_item_style_set(navi_item_, "basic");
 
        // left toolbar button
-       left_btn_ = elm_button_add(GetNaviframe());
+       left_btn_ = elm_button_add(parent);
        elm_object_text_set(left_btn_, "CANCEL");
        elm_object_style_set(left_btn_, "naviframe/title_left");
        evas_object_smart_callback_add(left_btn_, "clicked", OnCancelButtonClickedCb, this);
        evas_object_show(left_btn_);
 
        // right toolbar button
-       right_btn_ = elm_button_add(GetNaviframe());
+       right_btn_ = elm_button_add(parent);
        elm_object_style_set(right_btn_, "naviframe/title_right");
        elm_object_text_set(right_btn_, "DELETE");
        evas_object_smart_callback_add(right_btn_, "clicked", OnDeleteButtonClickedCb, this);
        evas_object_show(right_btn_);
 
        // main scrollable content
-       content_ = elm_genlist_add(GetNaviframe());
+       content_ = elm_genlist_add(parent);
        evas_object_size_hint_expand_set(content_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(content_, EVAS_HINT_FILL, EVAS_HINT_FILL);
        elm_genlist_mode_set(content_, ELM_LIST_COMPRESS);
index 5598f01..0e261ba 100644 (file)
@@ -11,12 +11,11 @@ using namespace utils;
 using namespace model;
 
 
-EditAlarmView::EditAlarmView() :
-       week_flags_view_(data_.flags)
+EditAlarmView::EditAlarmView(ui::IView &main)
+       : PageView(main), week_flags_view_(main, data_.flags)
 {
        week_flags_view_.RegisterPoppedCallback(
                        std::bind(&EditAlarmView::OnWeekFlagsPagePopped, this));
-       PushPage();
 }
 
 Evas_Object *EditAlarmView::GetEvasObject()
@@ -125,27 +124,27 @@ void EditAlarmView::OnConfirmButtonClickedCb(void *data, Evas_Object *obj, void
        view->PopPage();
 }
 
-void EditAlarmView::CreateContent()
+void EditAlarmView::CreateContent(Evas_Object *parent)
 {
        // set page style - "basic" style is supported by default tizen theme
        elm_object_item_style_set(navi_item_, "basic");
 
        // left toolbar button
-       left_btn_ = elm_button_add(GetNaviframe());
+       left_btn_ = elm_button_add(parent);
        elm_object_text_set(left_btn_, "CANCEL");
        elm_object_style_set(left_btn_, "naviframe/title_left");
        evas_object_smart_callback_add(left_btn_, "clicked", OnCancelButtonClickedCb, this);
        evas_object_show(left_btn_);
 
        // right toolbar button
-       right_btn_ = elm_button_add(GetNaviframe());
+       right_btn_ = elm_button_add(parent);
        elm_object_text_set(right_btn_, "DONE");
        elm_object_style_set(right_btn_, "naviframe/title_right");
        evas_object_smart_callback_add(right_btn_, "clicked", OnConfirmButtonClickedCb, this);
        evas_object_show(right_btn_);
 
        // main scrollable content
-       content_ = elm_genlist_add(GetNaviframe());
+       content_ = elm_genlist_add(parent);
        evas_object_size_hint_expand_set(content_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(content_, EVAS_HINT_FILL, EVAS_HINT_FILL);
        elm_genlist_mode_set(content_, ELM_LIST_COMPRESS);
index 64e848a..19c4a53 100644 (file)
@@ -78,13 +78,6 @@ void toolbar_it_cb (void *data, Evas_Object *obj, void *event_info)
        elm_object_item_content_set(top, page->GetEvasObject());
 }
 
-
-MainView &MainView::GetInstance()
-{
-       static MainView instance;
-       return instance;
-}
-
 MainView::MainView()
 {
        DBG("CreateBaseGui()");
@@ -103,6 +96,7 @@ MainView::MainView()
 
        ConformantAdd();
        NaviframeAdd();
+       CreateContent();
 
        evas_object_show(window_);
 }
@@ -151,10 +145,10 @@ void MainView::NaviframeAdd()
 
 void MainView::CreatePages()
 {
-       alarm_ = new AlarmView();
-       world_clock_ = new WorldClockView();
-       stop_watch_ = new StopWatchView();
-       timer_ = new TimerView();
+       alarm_ = new AlarmView(*this);
+       world_clock_ = new WorldClockView(*this);
+       stop_watch_ = new StopWatchView(*this);
+       timer_ = new TimerView(*this);
 }
 
 
index e5bbe59..eea0050 100644 (file)
@@ -30,9 +30,9 @@ PageView::~PageView()
        PopPage();
 }
 
-PageView::PageView()
+PageView::PageView(ui::IView &main)
+       : naviframe_(main.GetEvasObject()), navi_item_(nullptr)
 {
-       navi_item_ = NULL;
 }
 
 void PageView::ItemDeletedCallback(void *data, Evas_Object *o, void *event)
@@ -49,12 +49,12 @@ void PageView::PushPage()
        if (navi_item_) return;
 
        navi_item_ = elm_naviframe_item_push(
-                       MainView::GetInstance().GetEvasObject(),
+                       GetNaviframe(),
                        NULL, NULL, NULL, NULL, NULL);
        elm_object_item_data_set(navi_item_, this);
        elm_object_item_del_cb_set(navi_item_, PageView::ItemDeletedCallback);
 
-       CreateContent();
+       CreateContent(GetNaviframe());
 }
 
 void PageView::PopPage()
@@ -72,7 +72,7 @@ void PageView::PopPage()
 
 Evas_Object *PageView::GetNaviframe()
 {
-       return MainView::GetInstance().GetEvasObject();
+       return naviframe_;
 }
 
 void PageView::RegisterPoppedCallback(std::function<void(void)> f)
index db087a8..5172d3c 100644 (file)
@@ -31,9 +31,9 @@ const Elm_Genlist_Item_Class StopWatchView::list_itc = {
        .func.text_get = GetListText,
 };
 
-StopWatchView::StopWatchView()
+StopWatchView::StopWatchView(ui::IView &main)
 {
-       layout_ = elm_layout_add(MainView::GetInstance().GetEvasObject());
+       layout_ = elm_layout_add(main.GetEvasObject());
 
        if (!elm_layout_file_set(layout_, GetEdjeFilePath(), GROUP)) {
                ERR("elm_layout_file_set failed");
index 650f3bd..91e3549 100644 (file)
@@ -34,9 +34,9 @@ static Elm_Entry_Filter_Limit_Size limit_size = {
        .max_byte_count = 0
 };
 
-TimerView::TimerView() : set_time_()
+TimerView::TimerView(ui::IView &main) : set_time_()
 {
-       layout_ = elm_layout_add(MainView::GetInstance().GetEvasObject());
+       layout_ = elm_layout_add(main.GetEvasObject());
 
        if (!elm_layout_file_set(layout_, GetEdjeFilePath(), GROUP)) {
                ERR("elm_layout_file_set failed");
index 4bb8522..e94fc82 100644 (file)
@@ -11,8 +11,8 @@ using namespace utils;
 using namespace model;
 
 
-WeekFlagsView::WeekFlagsView(WeekFlags &flags)
-       : flags_(flags)
+WeekFlagsView::WeekFlagsView(ui::IView &main, WeekFlags &flags)
+       : PageView(main), flags_(flags)
 {
 }
 
@@ -65,9 +65,9 @@ void WeekFlagsView::AppendCheckableListItem(const char *str, WeekDay val)
        check_boxes_.push_back(desc);
 }
 
-void WeekFlagsView::CreateContent()
+void WeekFlagsView::CreateContent(Evas_Object *parent)
 {
-       list_ = elm_list_add(GetNaviframe());
+       list_ = elm_list_add(parent);
        evas_object_size_hint_weight_set(list_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(list_, EVAS_HINT_FILL, EVAS_HINT_FILL);
        evas_object_show(list_);
index 34ca405..953a67f 100644 (file)
@@ -57,9 +57,9 @@ Elm_Genlist_Item_Class WorldClockView::world_clock_itc_= {
 };
 
 
-void WorldClockView::CreateCustomLocationsList()
+void WorldClockView::CreateCustomLocationsList(Evas_Object *parent)
 {
-       custom_locations_list_ = elm_genlist_add(MainView::GetInstance().GetEvasObject());
+       custom_locations_list_ = elm_genlist_add(parent);
        evas_object_size_hint_expand_set(custom_locations_list_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(custom_locations_list_, EVAS_HINT_FILL, EVAS_HINT_FILL);
        elm_genlist_homogeneous_set(custom_locations_list_, EINA_TRUE);
@@ -237,9 +237,9 @@ void message_cb(void *data, Evas_Object *obj, Edje_Message_Type type, int id, vo
        }
 }
 
-WorldClockView::WorldClockView()
+WorldClockView::WorldClockView(ui::IView &main)
 {
-       world_clock_main_ = elm_layout_add(MainView::GetInstance().GetEvasObject());
+       world_clock_main_ = elm_layout_add(main.GetEvasObject());
        evas_object_size_hint_align_set(world_clock_main_, EVAS_HINT_FILL, EVAS_HINT_FILL);
        evas_object_size_hint_weight_set(world_clock_main_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        elm_layout_theme_set(world_clock_main_, "layout", "application", "default");
@@ -260,7 +260,7 @@ WorldClockView::WorldClockView()
        edje_object_message_handler_set(elm_layout_edje_get(world_clock_), message_cb, NULL);
 
        CreateTimezoneDetails();
-       CreateCustomLocationsList();
+       CreateCustomLocationsList(main.GetEvasObject());
 
        Evas_Object *fb = CreateFloatingButton();
        elm_object_part_content_set(world_clock_main_, "elm.swallow.floatingbutton", fb);