2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file GlVideoListPanel.cpp
19 * @brief This is the implementation file for VideoListPanel class.
24 #include "GlAlbumInfo.h"
25 #include "GlCommonUtil.h"
26 #include "GlFileListForm.h"
27 #include "GlFileListPresentationModel.h"
29 #include "GlVideoListPanel.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Content;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Media;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Controls;
39 using namespace Tizen::Ui::Scenes;
41 static const int H_VIDEO_ITEM = 160;
42 static const int GAP_W_VIDEO_TITLE = 16+172+16;
43 static const int GAP_H_VIDEO_TITLE = 22;
44 static const int W_VIDEO_TITLE = (16+172+16)+(16+64+16);
45 static const int H_VIDEO_TITLE = 64;
46 static const int FONT_SIZE_TITLE = 36;
47 static const int GAP_W_VIDEO_DURATION = 16+172+16;
48 static const int GAP_H_VIDEO_DURATION = 22+64;
49 static const int W_VIDEO_DURATION = (16+172+16)+(16+64+16);
50 static const int H_VIDEO_DURATION = 48;
51 static const int FONT_SIZE_DURATION = 32;
52 static const int W_CLIENT_REGION = 720;
53 static const Rectangle RECT_INITIAL (0, 0, 10, 10);
54 static const Rectangle RECT_VIDEO_THUMBNAIL (16, 16, 172, 128);
56 VideoListPanel::VideoListPanel(void)
58 , __pContentListView(null)
59 , __pPresentationModel(0)
62 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
65 VideoListPanel::~VideoListPanel(void)
68 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
72 VideoListPanel::Initialize(void)
75 result r = Construct(RECT_INITIAL);
76 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
82 VideoListPanel::OnInitializing(void)
85 const Form* pForm = dynamic_cast<Form*>(GetParent());
86 TryReturn(pForm != null, E_FAILURE, "[%s] fail to get the form.", GetErrorMessage(GetLastResult()));
88 __pPresentationModel = FileListPresentationModel::GetInstance();
89 __pPresentationModel->ClearThumbnailRequests();
90 __pPresentationModel->AddPresentationModelListener(this);
92 Rectangle clientAreaBounds = pForm->GetClientAreaBounds();
93 clientAreaBounds.x = clientAreaBounds.y = 0;
94 SetBounds(clientAreaBounds);
95 __pContentListView = new (std::nothrow) ListView();
96 __pContentListView->Construct(Rectangle(0, 0, W_CLIENT_REGION, clientAreaBounds.height), true, false);
97 Bitmap* pBitmapEmpty = ResourceManager::GetBitmapN(IDB_LISTVIEW_EMPTY);
98 if (pBitmapEmpty != null)
100 __pContentListView->SetBitmapOfEmptyList(pBitmapEmpty);
103 __pContentListView->SetTextOfEmptyList(ResourceManager::GetString(L"IDS_COM_BODY_NO_ITEMS"));
104 __pContentListView->SetItemProvider(*this);
105 __pContentListView->AddListViewItemEventListener(*this);
106 AddControl(__pContentListView);
107 __pContentListView->SetShowState(true);
109 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
115 VideoListPanel::OnTerminating(void)
117 AppLogDebug("ENTER");
118 __pPresentationModel->RemovePresentationModelListener(*this);
119 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
125 VideoListPanel::GetItemCount(void)
127 AppLogDebug("ENTER");
128 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
134 VideoListPanel::CreateItem(int index, int itemWidth)
136 AppLogDebug("ENTER : index(%d)", index);
137 CustomItem* pItem = new (std::nothrow) CustomItem();
138 pItem->Construct(Dimension(itemWidth, H_VIDEO_ITEM), LIST_ANNEX_STYLE_NORMAL);
140 Bitmap* pBitmap = null;
141 String* pItemText = null;
142 String* pTitle = null;
143 String* pDuration = null;
145 result r = __pPresentationModel->GetThumbnailVideoInSyncCacheN(index, pItemText, pBitmap, pDuration);
146 if (pBitmap == null || r == E_FAILURE)
148 __pPresentationModel->RequestThumbnail(index);
149 pBitmap = CommonUtil::GetEmptyThumbnailN();
152 pItem->AddElement(RECT_VIDEO_THUMBNAIL, IDA_FORMAT_THUMBNAIL, *pBitmap);
153 pTitle = new (std::nothrow) String(SINGLE_SPACE);
154 Rectangle titleRect(GAP_W_VIDEO_TITLE, GAP_H_VIDEO_TITLE, itemWidth-W_VIDEO_TITLE, H_VIDEO_TITLE);
155 pItem->AddElement(titleRect, IDA_FORMAT_TITLE, *pTitle, FONT_SIZE_TITLE,
156 Color::GetColor(COLOR_ID_BLACK), null, null, false);
158 Rectangle durationRect(GAP_W_VIDEO_DURATION, GAP_H_VIDEO_DURATION, itemWidth-W_VIDEO_DURATION,
160 pItem->AddElement(durationRect, IDA_FORMAT_DURATION, *pDuration, FONT_SIZE_DURATION,
161 Color::GetColor(COLOR_ID_GREY), null, null, false);
167 if (pItemText != null)
175 if (pDuration != null)
179 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
185 VideoListPanel::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
187 AppLogDebug("ENTER");
189 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
195 VideoListPanel::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
197 AppLogDebug("ENTER");
198 if (status == LIST_ITEM_STATUS_SELECTED)
200 IList* pList = new (std::nothrow) ArrayList();
201 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
203 for (int i = 0; i < loopCount; ++i)
205 pList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
208 listIndex.Format(10, L"%d", index);
210 const String mimeType = APPCONTROL_MIME_IMAGE_ALL;
211 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
212 pDataList->Construct();
213 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_IMAGE));
214 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
215 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_INDEX), new (std::nothrow) String(listIndex));
217 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
218 &mimeType, pDataList, null);
220 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
224 VideoListPanel::OnFileInfoChanged(const ContentType contentType)
226 AppLogDebug("ENTER");
227 if (contentType == CONTENT_TYPE_VIDEO)
229 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
230 __pContentListView->UpdateList();
232 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
236 VideoListPanel::OnThumbnailDecoded(const int index)
238 AppLogDebug("ENTER : index(%d)", index);
241 __pContentListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
243 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
247 VideoListPanel::OnSceneActivatedN(const SceneId& previousSceneId,
248 const SceneId& currentSceneId, IList* pArgs)
250 AppLogDebug("ENTER");
251 __pPresentationModel = FileListPresentationModel::GetInstance();
253 if (currentSceneId == IDSCN_VIDEO_LIST)
255 __pPresentationModel->RefreshCurrentAlbumContentInfoList(CONTENT_TYPE_VIDEO);
256 __itemCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
257 __pContentListView->UpdateList();
260 SceneManager* pSceneManager = SceneManager::GetInstance();
261 AppAssert(pSceneManager);
262 if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST)
264 FileListForm* pFileListForm = dynamic_cast<FileListForm*>(pSceneManager->GetCurrentScene()->GetForm());
265 if (pFileListForm != null)
267 pFileListForm->SetTitleText(__pPresentationModel->GetCurrentAlbumName());
270 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));