TizenRefApp-9005 [Gallery] Implement CustomMediaAlbum 23/142123/2
authorIgor Nazarov <i.nazarov@samsung.com>
Wed, 2 Aug 2017 14:59:20 +0000 (17:59 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Thu, 3 Aug 2017 10:42:59 +0000 (13:42 +0300)
- Implemented CustomMediaAlbum class;
- Light refactoring.

Change-Id: Ib88ab6e45cb3cfb2de14216e48ac8c2b6cd1b95a

12 files changed:
gallery/model/CustomMediaAlbum.cpp [new file with mode: 0644]
gallery/model/CustomMediaAlbum.h [new file with mode: 0644]
gallery/model/IMediaAlbum.h
gallery/model/MediaItem.h
gallery/model/SoundManager.h
gallery/model/impl/GalleryAlbum.cpp
gallery/model/impl/GalleryAlbum.h
gallery/presenters/pages/PreviewPage.cpp
gallery/presenters/pages/PreviewPage.h
gallery/presenters/pages/ThumbnailPage.cpp
gallery/presenters/pages/ThumbnailPage.h
project_def.prop

diff --git a/gallery/model/CustomMediaAlbum.cpp b/gallery/model/CustomMediaAlbum.cpp
new file mode 100644 (file)
index 0000000..175d91b
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "CustomMediaAlbum.h"
+
+#include "common.h"
+
+namespace gallery {
+
+       CustomMediaAlbum::CustomMediaAlbum()
+       {
+       }
+
+       CustomMediaAlbum::~CustomMediaAlbum()
+       {
+       }
+
+       void CustomMediaAlbum::addItem(MediaItemSRef item)
+       {
+               m_items.emplace_back(std::move(item));
+       }
+
+       void CustomMediaAlbum::addChangeHandler(const NotiHandler &handler)
+       {
+               LOG_RETURN_VOID(RES_NOT_SUPPORTED, "Wrong call.");
+       }
+
+       void CustomMediaAlbum::delChangeHandler(const NotiHandler &handler)
+       {
+               LOG_RETURN_VOID(RES_NOT_SUPPORTED, "Wrong call.");
+       }
+
+       Result CustomMediaAlbum::forEachMedia(const EachCb cb) const
+       {
+               for (const auto &item: m_items) {
+                       if (!cb(item)) {
+                               break;
+                       }
+               }
+               return RES_OK;
+       }
+
+       Result CustomMediaAlbum::getMediaCount(int &count) const
+       {
+               count = m_items.size();
+               return RES_OK;
+       }
+
+       void CustomMediaAlbum::defragment()
+       {
+               LOG_RETURN_VOID(RES_NOT_SUPPORTED, "Wrong call.");
+       }
+}
diff --git a/gallery/model/CustomMediaAlbum.h b/gallery/model/CustomMediaAlbum.h
new file mode 100644 (file)
index 0000000..f989365
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GALLERY_MODEL_CUSTOM_MEDIA_ALBUM_H__
+#define __GALLERY_MODEL_CUSTOM_MEDIA_ALBUM_H__
+
+#include "IMediaAlbum.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(CustomMediaAlbum);
+
+       class CustomMediaAlbum final : public IMediaAlbum {
+       public:
+               CustomMediaAlbum();
+               virtual ~CustomMediaAlbum();
+
+               void addItem(MediaItemSRef item);
+
+               // IMediaAlbum //
+
+               virtual void addChangeHandler(
+                               const NotiHandler &handler) final override;
+               virtual void delChangeHandler(
+                               const NotiHandler &handler) final override;
+
+               virtual ucl::Result forEachMedia(EachCb cb) const final override;
+               virtual ucl::Result getMediaCount(int &count) const final override;
+
+               virtual void defragment() final override;
+
+       private:
+               MediaItems m_items;
+       };
+}
+
+#endif // __GALLERY_MODEL_CUSTOM_MEDIA_ALBUM_H__
index 80eb22210646ab9126eb6374004f383469c1dbea..d20930995f2cd3b516820df47af05342f45975fd 100644 (file)
@@ -25,7 +25,7 @@ namespace gallery {
 
        class IMediaAlbum : public ucl::Polymorphic {
        public:
-               using EachCb = ucl::Delegate<bool(MediaItemSRef &&media)>;
+               using EachCb = ucl::Delegate<bool(MediaItemSRef media)>;
 
        public:
                virtual void addChangeHandler(const NotiHandler &handler) = 0;
index 98491b1abe332e328b11977af896dbefe85b1ea2..439de369ab9cdd5b4bd9922f4479db89c9f42478 100644 (file)
@@ -68,8 +68,8 @@ namespace gallery {
        public:
                static MediaItemSRef newInstance(media_info_h media);
                static MediaItemSRef newInstance(std::string filePath);
-               virtual ~MediaItem();
 
+       public:
                bool isValid() const;
                int getFlags() const;
                MediaType getType() const;
@@ -89,6 +89,7 @@ namespace gallery {
        protected:
                friend class ucl::ReffedObj<MediaItem>;
                MediaItem(int flags, MediaType type);
+               virtual ~MediaItem();
 
                ucl::Result prepare(media_info_h media);
                ucl::Result prepareImage(media_info_h media);
index e5adddb8622a4ff0550f0e752589a5d093d91a7b..4a95acf78e9d3dddfabd92d2c5dc2c3c712bdc2c 100644 (file)
@@ -31,6 +31,7 @@ namespace gallery {
        public:
                static SoundManagerSRef newInstance();
 
+       public:
                bool isMediaDeviceReady() const;
 
                int getCurrentMediaVolume() const;
index fbe2ad6a958ee2133cd9d65d316bdcc500c5589d..dcbdbb8e03f52b5f19fa2e103a43cdc0193cb1e1 100644 (file)
@@ -199,16 +199,16 @@ namespace gallery {
                m_onChange -= handler;
        }
 
-       Result GalleryAlbum::forEachMedia(EachCb cb) const
+       Result GalleryAlbum::forEachMedia(const EachCb cb) const
        {
                if (!m_isValid) {
                        LOG_RETURN(RES_INVALID_DATA, "m_isValid: false;");
                }
 
-               for (auto item: m_items) {
+               for (const auto &item: m_items) {
                        if (!item->isValid()) {
                                WLOG("Fragmented!");
-                       } else if (!cb(std::move(item))) {
+                       } else if (!cb(item)) {
                                break;
                        }
                }
index 358e5b5281dd26651039c44705ad23a16efb9452..f5e57880a6e8d2f3dcd7ed2b4ebf30e5643655d9 100644 (file)
@@ -32,8 +32,8 @@ namespace gallery {
        class GalleryAlbum final : public IMediaAlbum {
        public:
                static GalleryAlbumSRef newInstance();
-               virtual ~GalleryAlbum();
 
+       public:
                // IMediaAlbum //
 
                virtual void addChangeHandler(
@@ -49,6 +49,7 @@ namespace gallery {
        private:
                friend class ucl::ReffedObj<GalleryAlbum>;
                GalleryAlbum();
+               virtual ~GalleryAlbum();
 
                ucl::Result prepare();
 
index 7b70dc5de06391fa0dfe0064515bbad25035c7d6..88ad393c1b2c7451cc0d263f5a00a72023775f98 100644 (file)
@@ -397,7 +397,7 @@ namespace gallery {
                }
        }
 
-       bool PreviewPage::onEachMedia(MediaItemSRef &&media)
+       bool PreviewPage::onEachMedia(MediaItemSRef media)
        {
                m_items.emplace_back(makeShared<Item>(
                                std::move(media), *m_imageGrid, m_items.size()));
index 0df248dcec425efd47b0fcf0c9f2f974f606d1f3..05a35913df848af41e37395e7de29d0c8734e5d0 100644 (file)
@@ -78,7 +78,7 @@ namespace gallery {
                void checkViewerPage();
 
                void onAlbumChanged();
-               bool onEachMedia(MediaItemSRef &&media);
+               bool onEachMedia(MediaItemSRef media);
 
                void closeTempViews();
                void switchToSelectMode();
index 13ffdc51ce95e107b3b49a52dd5369a7be1cb767..52522a9e32fd34943fadd38f4b093a3e344d8296 100644 (file)
@@ -236,7 +236,7 @@ namespace gallery {
                }
        }
 
-       bool ThumbnailPage::onEachMedia(MediaItemSRef &&media)
+       bool ThumbnailPage::onEachMedia(MediaItemSRef media)
        {
                m_mediaItems.emplace_back(std::move(media));
                return true;
index f808c8a3e41c58c811945ca2c55cbd4ccc6f1d8b..05f97f03b5517bfa495d0455edba6d9318bc8dc5 100644 (file)
@@ -62,7 +62,7 @@ namespace gallery {
                int getSafeItemIndex(int itemIndex) const;
 
                void onAlbumChanged();
-               bool onEachMedia(MediaItemSRef &&media);
+               bool onEachMedia(MediaItemSRef media);
 
                void onPageExitRequest(Page &page);
 
index d779955d0706b076d9b5ab04e2036adf2e5292d4..657acd9bbcfeaa12338013e50ca6e2b045867f60 100644 (file)
@@ -9,7 +9,7 @@ type = app
 profile = wearable-4.0\r
 \r
 # C/CPP Sources\r
-USER_SRCS = gallery/presenters/Instance.cpp ucl/source/mvp/GuiPresenter.cpp gallery/presenters/pages/ThumbnailPage.cpp ucl/source/appfw/InstanceManagerBase.cpp gallery/presenters/InstanceManager.cpp gallery/presenters/misc/SelectModePresenter.cpp ucl/source/util/logging.cpp gallery/resources.cpp gallery/presenters/pages/ViewerPage.cpp gallery/presenters/misc/MoreOptionsPresenter.cpp gallery/presenters/misc/AtspiHighlightHelper.cpp ucl/source/mvp/ListPresenter.cpp gallery/model/SoundManager.cpp ucl/source/misc/Variant.cpp gallery/presenters/base/Dialog.cpp ucl/source/misc/Timeout.cpp gallery/presenters/misc/ProcessingPresenter.cpp ucl/source/util/types/Result.cpp gallery/model/impl/GalleryAlbum.cpp gallery/presenters/misc/helpers.cpp ucl/source/gui/Genlist.cpp gallery/presenters/pages/NoContentPage.cpp gallery/view/ImageViewer.cpp gallery/presenters/pages/PreviewPage.cpp gallery/view/PageContent.cpp gallery/view/TouchParser.cpp ucl/source/gui/WidgetItem.cpp gallery/presenters/dialogs/AlertDialog.cpp gallery/model/Gallery.cpp gallery/model/impl/helpers.cpp ucl/source/gui/Naviframe.cpp ucl/source/appfw/UIApp.cpp ucl/source/appfw/SysEventProvider.cpp gallery/presenters/pages/VideoPlayerPage.cpp gallery/main.cpp ucl/source/gui/Layout.cpp gallery/presenters/base/Page.cpp gallery/model/MediaItem.cpp gallery/view/helpers.cpp ucl/source/gui/Window.cpp ucl/source/gui/Widget.cpp gallery/model/impl/BaseJob.cpp ucl/source/mvp/ListItemPresenter.cpp ucl/source/gui/NaviItem.cpp ucl/source/gui/ElmWidget.cpp gallery/view/ImageGrid.cpp ucl/source/appfw/helpers.cpp ucl/source/gui/EdjeWidget.cpp \r
+USER_SRCS = gallery/presenters/Instance.cpp ucl/source/mvp/GuiPresenter.cpp gallery/model/CustomMediaAlbum.cpp gallery/presenters/pages/ThumbnailPage.cpp ucl/source/appfw/InstanceManagerBase.cpp gallery/presenters/InstanceManager.cpp gallery/presenters/misc/SelectModePresenter.cpp ucl/source/util/logging.cpp gallery/resources.cpp gallery/presenters/pages/ViewerPage.cpp gallery/presenters/misc/MoreOptionsPresenter.cpp gallery/presenters/misc/AtspiHighlightHelper.cpp ucl/source/mvp/ListPresenter.cpp gallery/model/SoundManager.cpp ucl/source/misc/Variant.cpp gallery/presenters/base/Dialog.cpp ucl/source/misc/Timeout.cpp gallery/presenters/misc/ProcessingPresenter.cpp ucl/source/util/types/Result.cpp gallery/model/impl/GalleryAlbum.cpp gallery/presenters/misc/helpers.cpp ucl/source/gui/Genlist.cpp gallery/presenters/pages/NoContentPage.cpp gallery/view/ImageViewer.cpp gallery/presenters/pages/PreviewPage.cpp gallery/view/PageContent.cpp gallery/view/TouchParser.cpp ucl/source/gui/WidgetItem.cpp gallery/presenters/dialogs/AlertDialog.cpp gallery/model/Gallery.cpp gallery/model/impl/helpers.cpp ucl/source/gui/Naviframe.cpp ucl/source/appfw/UIApp.cpp ucl/source/appfw/SysEventProvider.cpp gallery/presenters/pages/VideoPlayerPage.cpp gallery/main.cpp ucl/source/gui/Layout.cpp gallery/presenters/base/Page.cpp gallery/model/MediaItem.cpp gallery/view/helpers.cpp ucl/source/gui/Window.cpp ucl/source/gui/Widget.cpp gallery/model/impl/BaseJob.cpp ucl/source/mvp/ListItemPresenter.cpp ucl/source/gui/NaviItem.cpp ucl/source/gui/ElmWidget.cpp gallery/view/ImageGrid.cpp ucl/source/appfw/helpers.cpp ucl/source/gui/EdjeWidget.cpp \r
 \r
 # EDC Sources\r
 USER_EDCS =  \r