TizenRefApp-9006 [Gallery] Implement helper function to create 27/142127/3
authorIgor Nazarov <i.nazarov@samsung.com>
Wed, 2 Aug 2017 17:53:31 +0000 (20:53 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Thu, 3 Aug 2017 10:47:55 +0000 (13:47 +0300)
CustomMediaAlbum from app control file path array

Change-Id: Ib0db737ffff86fd4c72fb236a29f4f1e04d7da02

gallery/model/helpers.cpp [new file with mode: 0644]
gallery/model/helpers.h [new file with mode: 0644]
project_def.prop

diff --git a/gallery/model/helpers.cpp b/gallery/model/helpers.cpp
new file mode 100644 (file)
index 0000000..cf64994
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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 "helpers.h"
+
+#include "common.h"
+
+namespace gallery { namespace util {
+
+       CustomMediaAlbumSRef makeMediaAlbum(
+                       const char *const filePathArray[], const int count)
+       {
+               if (!filePathArray) {
+                       FAIL_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+                                       "filePathArray is NULL");
+               }
+
+               auto result = makeShared<CustomMediaAlbum>();
+
+               for (int i = 0; i < count; ++i) {
+
+                       const auto filePath = filePathArray[i];
+                       if (!filePath) {
+                               WLOG("filePath is NULL. Skipping...");
+                               continue;
+                       }
+
+                       auto item = MediaItem::newInstance(filePath);
+                       if (!item) {
+                               WLOG("MediaItem::newInstance() failed. Skipping...");
+                               continue;
+                       }
+
+                       result->addItem(std::move(item));
+               }
+
+               if (isEmpty(result)) {
+                       FAIL_RETURN_VALUE(RES_FAIL, {}, "result is empty");
+               }
+
+               return result;
+       }
+}}
diff --git a/gallery/model/helpers.h b/gallery/model/helpers.h
new file mode 100644 (file)
index 0000000..c578222
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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_HELPERS_H__
+#define __GALLERY_MODEL_HELPERS_H__
+
+#include "CustomMediaAlbum.h"
+
+namespace gallery { namespace util {
+
+       CustomMediaAlbumSRef makeMediaAlbum(
+                       const char *const filePathArray[], int count);
+}}
+
+#endif // __GALLERY_MODEL_HELPERS_H__
index 657acd9bbcfeaa12338013e50ca6e2b045867f60..d0f49b6eebe5026aa8bc10de12d013721ca61dc6 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/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
+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 gallery/model/helpers.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