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 MpArtistAllSongListForm.cpp
19 * @brief This is the implementation file for ArtistAllSongListForm class.
22 #include "MpArtistAllSongListForm.h"
23 #include "MpArtistListPresentationModel.h"
24 #include "MpNowPlayContentPanel.h"
25 #include "MpPlaylistPickerPopup.h"
26 #include "MpThumbnailInfo.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Content;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Social;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
36 static const int W_SONG_TIME = 120;
37 static const int Y_GAP_LABEL = 10;
39 ArtistAllSongListForm::ArtistAllSongListForm(void)
40 : ThumbnailBase::ThumbnailBase()
41 , __pContentTableView(null)
43 , __pPlayListPickerPopup(null)
44 , __fontSize(FONT_MAIN_TEXT_SIZE_NORMAL)
45 , __itemHeight(ITEM_HEIGHT_MAIN_TEXT_NORMAL)
51 ArtistAllSongListForm::~ArtistAllSongListForm(void)
58 ArtistAllSongListForm::Initialize(void)
62 result r = Form::Construct(FORM_STYLE_NORMAL | FORM_STYLE_PORTRAIT_INDICATOR | FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
73 ArtistAllSongListForm::OnInitializing(void)
77 // Header* pHeader = GetHeader();
78 // pHeader->SetStyle(HEADER_STYLE_TITLE);
79 // pHeader->SetTitleText(ResourceManager::GetString("IDS_MUSIC_BODY_ALL_SONGS"));
81 __pContentTableView = new (std::nothrow) TableView();
82 __pContentTableView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height),
84 TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
85 __pContentTableView->AddTableViewItemEventListener(*this);
86 __pContentTableView->SetItemProvider(this);
87 AddControl(__pContentTableView);
89 __pPresentationModel = ArtistListPresentationModel::GetInstance();
90 __fontSizeValue = CommonUtil::GetFontSizeValue();
91 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
92 __fontSize = CommonUtil::GetFontSize(__fontSizeValue);
95 return ThumbnailBase::Construct();
99 ArtistAllSongListForm::OnTerminating(void)
101 AppLogDebug("ENTER");
102 ThumbnailBase::Stop();
103 delete __pPlayListPickerPopup;
104 __pPlayListPickerPopup = null;
110 ArtistAllSongListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
112 AppLogDebug("ENTER");
113 SceneManager* pSceneManager = SceneManager::GetInstance();
114 AppAssert(pSceneManager);
118 case IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST:
120 Tizen::Base::Collection::IList* pDataList = null;
121 pDataList = __pPresentationModel->GetAllContentPathListN();
123 if (pDataList == null)
128 __pPlayListPickerPopup = new (std::nothrow) PlayListPickerPopup();
129 __pPlayListPickerPopup->Initialize(this, pDataList);
131 __pPlayListPickerPopup->SetShowState(true);
132 __pPlayListPickerPopup->Show();
133 //__pPlayListPickerPopup->SetCollectedContent(pDataList);
137 /*case IDA_FOOTER_BUTTON_SEARCH:
139 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SEARCH));
150 ArtistAllSongListForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
152 AppLogDebug("ENTER");
153 SceneManager* pSceneManager = SceneManager::GetInstance();
154 AppAssert(pSceneManager);
156 pSceneManager->GoBackward(BackwardSceneTransition());
161 ArtistAllSongListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
162 const Tizen::Ui::Scenes::SceneId& currentSceneId,
163 Tizen::Base::Collection::IList* pArgs)
165 AppLogDebug("ENTER");
166 Footer* pFooter = CommonUtil::CreateAddtoPlaylistFooter(*this);
167 pFooter->AddActionEventListener(*this);
168 pFooter->SetBackButton();
170 SetFormBackEventListener(this);
172 Header* pHeader = GetHeader();
173 pHeader->SetStyle(HEADER_STYLE_TITLE);
174 pHeader->SetTitleText(ResourceManager::GetString("IDS_MUSIC_BODY_ALL_SONGS"));
179 ArtistAllSongListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
180 const Tizen::Ui::Scenes::SceneId& nextSceneId)
182 AppLogDebug("ENTER");
183 Header* pHeader = GetHeader();
184 pHeader->RemoveAllButtons();
185 pHeader->RemoveAllItems();
187 Footer* pFooter = GetFooter();
190 pFooter->RemoveAllButtons();
191 pFooter->RemoveAllItems();
192 pFooter->RemoveActionEventListener(*this);
195 CancelAllThumbnailRequest();
200 ArtistAllSongListForm::GetItemCount(void)
202 AppLogDebug("ENTER");
203 if (__pPresentationModel == null)
209 return __pPresentationModel->GetArtistContentListCount();
212 Tizen::Ui::Controls::TableViewItem*
213 ArtistAllSongListForm::CreateItem(const int itemIndex, int itemWidth)
215 AppLogDebug("ENTER");
216 ContentInformation* pContentInfo = __pPresentationModel->GetArtistContentInfoN(itemIndex);
217 if (pContentInfo == null)
223 TableViewItem* pItem = new (std::nothrow) TableViewItem();
224 pItem->Construct(Dimension(itemWidth, __itemHeight), TABLE_VIEW_ANNEX_STYLE_NORMAL);
225 CreateTableViewItem(*pItem, *pContentInfo);
227 RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) Integer(itemIndex)));
235 ArtistAllSongListForm::DeleteItem(const int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
237 AppLogDebug("ENTER");
243 ArtistAllSongListForm::GetDefaultItemHeight(void)
245 AppLogDebug("ENTER");
251 ArtistAllSongListForm::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView,
253 Tizen::Ui::Controls::TableViewItem* pItem,
254 Tizen::Ui::Controls::TableViewItemStatus status)
256 AppLogDebug("ENTER");
257 SceneManager* pSceneManager = SceneManager::GetInstance();
258 AppAssert(pSceneManager);
260 ArrayList* pTempList = new (std::nothrow) ArrayList();
261 pTempList->Construct();
263 pTempList->Add(*(new (std::nothrow) String(MUSIC)));
264 pTempList->Add(*(new (std::nothrow) Integer(itemIndex)));
265 pTempList->Add(*(__pPresentationModel->GetAllContentPathListN()));
267 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_PLAYER),pTempList);
272 ArtistAllSongListForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView,
274 Tizen::Ui::Controls::TableViewContextItem* pContextItem,
277 AppLogDebug("ENTER");
282 ArtistAllSongListForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView,
286 AppLogDebug("ENTER");
291 ArtistAllSongListForm::CreateTableViewItem(Tizen::Ui::Container& parent,
292 const ContentInformation& contentInfoStruct)
294 AppLogDebug("ENTER");
295 result r = E_SUCCESS;
297 Label* pSongThumbnailBGLabel = new (std::nothrow) Label();
298 pSongThumbnailBGLabel->Construct(Rectangle(X_GAP_THUMBNAIL - 1, Y_GAP_THUMBNAIL - 1, W_THUMBNAIL + 1, W_THUMBNAIL + 1), L"");
300 Label* pSongThumbnailLabel = new (std::nothrow) Label();
301 pSongThumbnailLabel->Construct(Rectangle(X_GAP_THUMBNAIL, Y_GAP_THUMBNAIL, W_THUMBNAIL, H_THUMBNAIL), L"");
302 pSongThumbnailLabel->SetBackgroundBitmap(*GetDefaultThumbnail());
303 pSongThumbnailLabel->SetName(L"pSongThumbnailLabel");
305 int X_Gap = W_THUMBNAIL + (X_GAP_THUMBNAIL * 2);
306 int W_Label = W_CLIENT_AREA - X_Gap;
308 Label* pSongTitleLabel = new (std::nothrow) Label();
309 pSongTitleLabel->Construct(Rectangle(X_Gap,Y_GAP_LABEL, W_Label - W_SONG_TIME, (ITEM_HEIGHT - (Y_GAP_LABEL * 2)) / 2), L"");
310 pSongTitleLabel->SetTextColor(COLOR_MAIN_TEXT);
311 pSongTitleLabel->SetTextConfig(MAIN_TEXT_SIZE, LABEL_TEXT_STYLE_NORMAL);
312 pSongTitleLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
313 pSongTitleLabel->SetText(contentInfoStruct.TitleName);
315 Label* pSongTimeLabel = new (std::nothrow) Label();
316 pSongTimeLabel->Construct(Rectangle(pSongTitleLabel->GetWidth() + X_Gap, pSongTitleLabel->GetY(), W_SONG_TIME, pSongTitleLabel->GetHeight()) , L"");
317 pSongTimeLabel->SetTextColor(COLOR_SUB_TEXT);
318 pSongTimeLabel->SetTextConfig(SUB_TEXT_SIZE, LABEL_TEXT_STYLE_NORMAL);
319 pSongTimeLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
320 pSongTimeLabel->SetText(CommonUtil::GetFormatDate(contentInfoStruct.Duration));
322 Label* pSongArtistLabel = new (std::nothrow) Label();
323 pSongArtistLabel->Construct(Rectangle(X_Gap, pSongTimeLabel->GetHeight() + Y_GAP_LABEL, W_Label, pSongTitleLabel->GetHeight()), L"");
324 pSongArtistLabel->SetTextColor(COLOR_SUB_TEXT);
325 pSongArtistLabel->SetTextConfig(SUB_TEXT_SIZE, LABEL_TEXT_STYLE_NORMAL);
326 pSongArtistLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
327 pSongArtistLabel->SetText(contentInfoStruct.ArtistName);
329 parent.AddControl(pSongThumbnailBGLabel);
330 parent.AddControl(pSongThumbnailLabel);
331 parent.AddControl(pSongTitleLabel);
332 parent.AddControl(pSongTimeLabel);
333 parent.AddControl(pSongArtistLabel);
340 ArtistAllSongListForm::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
342 AppLogDebug("ENTER");
343 __pThumbnail = pThumbnailInfo->GetBitmapN();
344 Object* pParam = pThumbnailInfo->GetUserParamN();
347 __pContentTableView->RefreshItem((static_cast<Integer*>(pParam))->ToInt(), TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
351 delete pThumbnailInfo;
356 ArtistAllSongListForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
358 AppLogDebug("ENTER");
359 AppLogDebug("OnUserEventReceivedN %d", requestId);
360 if (requestId == ID_DESTORY_PLAY_LIST_PICKER_POPUP)
362 if (__pPlayListPickerPopup != null)
364 delete __pPlayListPickerPopup;
365 __pPlayListPickerPopup = null;
372 ArtistAllSongListForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
374 AppLogDebug("ENTER");
375 Label* pThumbnailLabel = static_cast<Label*>(pItem->GetControl(L"pSongThumbnailLabel"));
376 if (__pThumbnail == null || pThumbnailLabel == null)
378 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
383 pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
386 pThumbnailLabel->Invalidate(true);