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 <FBaseSysLog.h>
19 #include <FGrpBitmap.h>
20 #include "FUiCtrl_GalleryItemProviderAdaptor.h"
21 #include "FUiCtrl_IGalleryItemProvider.h"
22 #include "FUiCtrl_GalleryItem.h"
23 #include "FUiCtrl_GalleryBitmap.h"
26 using namespace Tizen::Graphics;
28 namespace Tizen { namespace Ui { namespace Controls {
30 _GalleryItemProviderAdaptor::_GalleryItemProviderAdaptor(_IGalleryItemProvider& itemProvider)
31 : __itemProvider(itemProvider)
36 _GalleryItemProviderAdaptor::~_GalleryItemProviderAdaptor(void)
42 _GalleryItemProviderAdaptor::SetGalleryItemProvider(_IGalleryItemProvider& itemProvider)
44 __itemProvider = itemProvider;
50 _GalleryItemProviderAdaptor::LoadItem(int groupIndex, int itemIndex)
52 SysTryReturn(NID_UI_CTRL, itemIndex >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] Item index argument is negative.");
54 _GalleryItem* pItem = __itemProvider.CreateItem(itemIndex);
55 SysTryReturn(NID_UI_CTRL, pItem != null, null, E_SYSTEM, "[E_SYSTEM] Did not create a GalleryItem");
57 SetLastResult(E_SUCCESS);
63 _GalleryItemProviderAdaptor::UnloadItem(_IListItemCommon* pItem, int groupIndex, int itemIndex)
65 SysTryReturn(NID_UI_CTRL, pItem != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Gallery Item is null");
66 SysTryReturn(NID_UI_CTRL, itemIndex >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] Item index is negative.");
67 //SysTryReturn(NID_UI_CTRL, itemIndex < GetItemCount(), null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Item index argument is out of range.");
69 _GalleryItem* pGalleryItem = dynamic_cast<_GalleryItem*>(pItem);
70 SysTryReturn(NID_UI_CTRL, pGalleryItem != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] pItem is not a _GalleryItem object");
72 bool deleteSuccess = true;
73 if (pGalleryItem->GetAppInfo() != null)
75 deleteSuccess = __itemProvider.UnloadItem(itemIndex, pGalleryItem);
82 if (deleteSuccess == true)
86 else if (GetLastResult() != E_SUCCESS)
88 return GetLastResult();
92 return E_INVALID_STATE;
97 _GalleryItemProviderAdaptor::GetItemCount(int groupIndex) const
99 return __itemProvider.GetItemCount();
103 _GalleryItemProviderAdaptor::DeleteItem(_IListItemCommon* pItem, int groupIndex, int itemIndex)
105 SysTryReturn(NID_UI_CTRL, pItem != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Gallery Item is null.");
106 SysTryReturn(NID_UI_CTRL, itemIndex >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] Item index is negative.");
108 _GalleryItem* pGalleryItem = dynamic_cast<_GalleryItem*>(pItem);
109 SysTryReturn(NID_UI_CTRL, pGalleryItem != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] pItem is not a _GalleryItem object");
111 bool deleteSuccess = true;
112 if (pGalleryItem->GetAppInfo() != null)
114 deleteSuccess = __itemProvider.DeleteItem(itemIndex, pGalleryItem);
121 if (deleteSuccess == true)
125 else if (GetLastResult() != E_SUCCESS)
127 return GetLastResult();
131 return E_INVALID_STATE;
135 }}} // Tizen::Ui::Controls