2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 #include <FBaseErrors.h>
18 #include <FUiCtrlGalleryItem.h>
19 #include <FUiCtrlIGalleryItemProvider.h>
20 #include <FBaseSysLog.h>
21 #include "FUiCtrl_GalleryItemProviderAdaptorImpl.h"
22 #include "FUiCtrl_GalleryItemImpl.h"
23 #include "FUiCtrl_GalleryItem.h"
25 namespace Tizen { namespace Ui { namespace Controls {
27 _GalleryItemProviderAdaptorImpl::_GalleryItemProviderAdaptorImpl(void)
28 : __pItemProvider(null)
33 _GalleryItemProviderAdaptorImpl::~_GalleryItemProviderAdaptorImpl(void)
39 _GalleryItemProviderAdaptorImpl::SetGalleryItemProvider(const IGalleryItemProvider& itemProvider)
41 __pItemProvider = &const_cast<IGalleryItemProvider&>(itemProvider);
45 _GalleryItemProviderAdaptorImpl::HasGalleryItemProvider(void) const
47 return __pItemProvider != null ? true : false;
51 _GalleryItemProviderAdaptorImpl::CreateItem(int index)
53 if (HasGalleryItemProvider() == false)
58 GalleryItem* pPublicItem = __pItemProvider->CreateItem(index);
59 if (pPublicItem != null)
61 _GalleryItemImpl* pImplItem = _GalleryItemImpl::GetInstance(*pPublicItem);
62 SysTryReturn(NID_UI_CTRL, pImplItem != null, null, E_INVALID_STATE, "[E_INVALID_STATE] Gallery item impl is null.");
63 pImplItem->GetCore().SetAppInfo(pImplItem);
64 return &pImplItem->GetCore();
67 SetLastResult(E_SUCCESS);
72 _GalleryItemProviderAdaptorImpl::UnloadItem(int index, _GalleryItem* pItem)
74 if (HasGalleryItemProvider() == false)
79 SysTryReturn(NID_UI_CTRL, pItem != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The pItem is null.");
81 _GalleryItemImpl* pImplItem = static_cast<_GalleryItemImpl*>(pItem->GetAppInfo());
82 GalleryItem* pPublicItem = static_cast<GalleryItem*>(&pImplItem->GetPublic());
84 SetLastResult(E_SUCCESS);
85 if (__pItemProvider->DeleteItem(index, pPublicItem) == false)
94 _GalleryItemProviderAdaptorImpl::DeleteItem(int index, _GalleryItem* pItem)
96 _GalleryItemImpl* pImplItem = static_cast<_GalleryItemImpl*>(pItem->GetAppInfo());
97 GalleryItem* pPublicItem = &pImplItem->GetPublic();
100 SetLastResult(E_SUCCESS);
105 _GalleryItemProviderAdaptorImpl::GetItemCount(void) const
107 if (HasGalleryItemProvider() == false)
111 return __pItemProvider->GetItemCount();
114 }}} // Tizen::Ui::Controls