summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Nazarov <i.nazarov@samsung.com>2017-08-02 17:59:20 +0300
committerIgor Nazarov <i.nazarov@samsung.com>2017-08-03 13:42:59 +0300
commitd320bbd5a29a64a5ba2e9e94355c7db7f6b21976 (patch)
tree99cecf94bdedb4715358990ed2790df1aa723750
parentbebbaa9cb40aabcb313f89e5e481e6fdc0ea046a (diff)
downloadgallery-d320bbd5a29a64a5ba2e9e94355c7db7f6b21976.tar.gz
gallery-d320bbd5a29a64a5ba2e9e94355c7db7f6b21976.tar.bz2
gallery-d320bbd5a29a64a5ba2e9e94355c7db7f6b21976.zip
TizenRefApp-9005 [Gallery] Implement CustomMediaAlbum
- Implemented CustomMediaAlbum class; - Light refactoring. Change-Id: Ib88ab6e45cb3cfb2de14216e48ac8c2b6cd1b95a
-rw-r--r--gallery/model/CustomMediaAlbum.cpp66
-rw-r--r--gallery/model/CustomMediaAlbum.h50
-rw-r--r--gallery/model/IMediaAlbum.h2
-rw-r--r--gallery/model/MediaItem.h3
-rw-r--r--gallery/model/SoundManager.h1
-rw-r--r--gallery/model/impl/GalleryAlbum.cpp6
-rw-r--r--gallery/model/impl/GalleryAlbum.h3
-rw-r--r--gallery/presenters/pages/PreviewPage.cpp2
-rw-r--r--gallery/presenters/pages/PreviewPage.h2
-rw-r--r--gallery/presenters/pages/ThumbnailPage.cpp2
-rw-r--r--gallery/presenters/pages/ThumbnailPage.h2
-rw-r--r--project_def.prop2
12 files changed, 130 insertions, 11 deletions
diff --git a/gallery/model/CustomMediaAlbum.cpp b/gallery/model/CustomMediaAlbum.cpp
new file mode 100644
index 0000000..175d91b
--- /dev/null
+++ b/gallery/model/CustomMediaAlbum.cpp
@@ -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
index 0000000..f989365
--- /dev/null
+++ b/gallery/model/CustomMediaAlbum.h
@@ -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__
diff --git a/gallery/model/IMediaAlbum.h b/gallery/model/IMediaAlbum.h
index 80eb222..d209309 100644
--- a/gallery/model/IMediaAlbum.h
+++ b/gallery/model/IMediaAlbum.h
@@ -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;
diff --git a/gallery/model/MediaItem.h b/gallery/model/MediaItem.h
index 98491b1..439de36 100644
--- a/gallery/model/MediaItem.h
+++ b/gallery/model/MediaItem.h
@@ -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);
diff --git a/gallery/model/SoundManager.h b/gallery/model/SoundManager.h
index e5adddb..4a95acf 100644
--- a/gallery/model/SoundManager.h
+++ b/gallery/model/SoundManager.h
@@ -31,6 +31,7 @@ namespace gallery {
public:
static SoundManagerSRef newInstance();
+ public:
bool isMediaDeviceReady() const;
int getCurrentMediaVolume() const;
diff --git a/gallery/model/impl/GalleryAlbum.cpp b/gallery/model/impl/GalleryAlbum.cpp
index fbe2ad6..dcbdbb8 100644
--- a/gallery/model/impl/GalleryAlbum.cpp
+++ b/gallery/model/impl/GalleryAlbum.cpp
@@ -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;
}
}
diff --git a/gallery/model/impl/GalleryAlbum.h b/gallery/model/impl/GalleryAlbum.h
index 358e5b5..f5e5788 100644
--- a/gallery/model/impl/GalleryAlbum.h
+++ b/gallery/model/impl/GalleryAlbum.h
@@ -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();
diff --git a/gallery/presenters/pages/PreviewPage.cpp b/gallery/presenters/pages/PreviewPage.cpp
index 7b70dc5..88ad393 100644
--- a/gallery/presenters/pages/PreviewPage.cpp
+++ b/gallery/presenters/pages/PreviewPage.cpp
@@ -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()));
diff --git a/gallery/presenters/pages/PreviewPage.h b/gallery/presenters/pages/PreviewPage.h
index 0df248d..05a3591 100644
--- a/gallery/presenters/pages/PreviewPage.h
+++ b/gallery/presenters/pages/PreviewPage.h
@@ -78,7 +78,7 @@ namespace gallery {
void checkViewerPage();
void onAlbumChanged();
- bool onEachMedia(MediaItemSRef &&media);
+ bool onEachMedia(MediaItemSRef media);
void closeTempViews();
void switchToSelectMode();
diff --git a/gallery/presenters/pages/ThumbnailPage.cpp b/gallery/presenters/pages/ThumbnailPage.cpp
index 13ffdc5..52522a9 100644
--- a/gallery/presenters/pages/ThumbnailPage.cpp
+++ b/gallery/presenters/pages/ThumbnailPage.cpp
@@ -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;
diff --git a/gallery/presenters/pages/ThumbnailPage.h b/gallery/presenters/pages/ThumbnailPage.h
index f808c8a..05f97f0 100644
--- a/gallery/presenters/pages/ThumbnailPage.h
+++ b/gallery/presenters/pages/ThumbnailPage.h
@@ -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);
diff --git a/project_def.prop b/project_def.prop
index d779955..657acd9 100644
--- a/project_def.prop
+++ b/project_def.prop
@@ -9,7 +9,7 @@ type = app
profile = wearable-4.0
# C/CPP Sources
-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
+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
# EDC Sources
USER_EDCS =