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 MpArtistContentListForm.cpp
19 * @brief This is the implementation file for ArtistContentListForm class.
23 #include "MpArtistContentListForm.h"
24 #include "MpArtistListPresentationModel.h"
25 #include "MpMusicPlayerApp.h"
26 #include "MpPlaylistPickerPopup.h"
27 #include "MpSharePopup.h"
28 #include "MpThumbnailInfo.h"
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Content;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Controls;
36 using namespace Tizen::Ui::Scenes;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Io;
39 using namespace Tizen::System;
40 using namespace Tizen::Social;
43 #define ALL_SONG_INDEX_COUNT_PLUS(n) (n + 1)
44 #define ALL_SONG_INDEX_COUNT_MINUS(n) (n - 1)
46 ArtistContentListForm::ArtistContentListForm(void)
47 : ContentListForm::ContentListForm()
48 , ThumbnailBase::ThumbnailBase()
49 , __pContentGroupedTableView(null)
50 , __pTableViewContextItem(null)
51 , __pCheckedItemCountMultiHashMap(null)
53 , __activatedStateContextItem(0)
54 , __pPresentationModel(null)
60 ArtistContentListForm::~ArtistContentListForm(void)
67 ArtistContentListForm::Initialize(void)
70 if (IsFailed(Form::Construct(IDL_CONTENT_LIST_ARTIST_FORM)))
72 AppLogDebug("Form::Construct(IDL_CONTENT_LIST_ARTIST_FORM) failed(%s)", GetErrorMessage(GetLastResult()));
73 return GetLastResult();
81 ArtistContentListForm::Construct(void)
84 __pContentGroupedTableView = static_cast<GroupedTableView*>(GetControl(IDC_GROUPEDTABLEVIEW_CONTENT_LIST));
85 __pContentGroupedTableView->AddGroupedTableViewItemEventListener(*this);
86 __pContentGroupedTableView->SetItemProvider(this);
88 SetContentList(__pContentGroupedTableView);
90 result r = InitCheckedItemMultiHashMap();
93 AppLogDebug("InitCheckedItemMultiHashMap failed(%s)", GetErrorMessage(r));
98 return ContentListForm::Construct();
102 ArtistContentListForm::OnInitializing(void)
104 AppLogDebug("ENTER");
105 __fontSizeValue = CommonUtil::GetFontSizeValue();
106 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
107 __pPresentationModel = ArtistListPresentationModel::GetInstance();
108 __pTableViewContextItem = CommonUtil::CreateTableViewContextItemN(*this, GetWidth(), FLICK_MENU_STYLE_TYPE_01);
110 return ThumbnailBase::Construct();
114 ArtistContentListForm::OnTerminating(void)
116 AppLogDebug("ENTER");
117 ThumbnailBase::Stop();
118 RemoveCheckedItemMultiHashMap();
120 delete __pTableViewContextItem;
121 __pTableViewContextItem = null;
123 __pContentGroupedTableView = null;
124 __pPresentationModel = null;
126 return ContentListForm::OnTerminating();
130 ArtistContentListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
131 const Tizen::Ui::Scenes::SceneId& currentSceneId,
132 Tizen::Base::Collection::IList* pArgs)
134 AppLogDebug("ENTER");
137 if (previousSceneId.Equals(IDSCN_PLAYLIST_CREATOR, false))
139 SetItemCheckedAll(false);
143 __prevSceneId.Clear();
144 __headerTitle.Clear();
145 __prevSceneId.Append(*static_cast<String*>(pArgs->GetAt(DATA_ITEM_SCENE_NAME)));
146 __headerTitle.Append(*static_cast<String*>(pArgs->GetAt(DATA_ITEM_CONTENT_NAME)));
147 __artistName = __headerTitle;
148 __pPresentationModel->UpdateArtistList();
149 __pPresentationModel->InitializeArtistAlbumList(__artistName);
150 __pPresentationModel->InitializeContentList(INIT_VALUE);
156 pArgs->RemoveAll(true);
163 ArtistContentListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
164 const Tizen::Ui::Scenes::SceneId& nextSceneId)
166 AppLogDebug("ENTER");
167 CancelAllThumbnailRequest();
172 ArtistContentListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
174 AppLogDebug("ENTER");
175 SceneManager* pSceneManager = SceneManager::GetInstance();
176 AppAssert(pSceneManager);
180 case IDA_HEADER_BUTTON_SELECTE_ALL:
182 bool isChecked = true;
183 if (GetCheckedItemCount() == GetTotalItemCount())
187 SetItemCheckedAll(isChecked);
191 case IDA_FOOTER_BUTTON_SHARE:
193 LanucherPicker(PICKER_TYPE_SHARE_PICKER);
197 case IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST:
199 LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER);
203 case IDA_CONTEXT_MENU_ITEM_SEARCH:
205 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SEARCH, SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY));
209 case IDA_CONTEXT_MENU_ITEM_EDIT:
211 ToggleScreenState(SCREEN_STATE_EDITOR);
215 case IDA_CONTEXT_MENU_ITEM_SHARE_VIA:
217 ToggleScreenState(SCREEN_STATE_SHARE_VIA);
221 case IDA_FOOTER_BUTTON_MORE:
223 CreateOptionMenuN(source);
224 SetOptionMenuItem(CONTEXT_MENU_ITEM_STYLE_SHARE_VIA | CONTEXT_MENU_ITEM_STYLE_EDIT);
228 case IDA_FLICK_MENU_ITEM_ADDTO:
230 LanucherPicker(PICKER_TYPE_PLAY_LIST_PICKER, PICKER_ARGUMENT_TYPE_ACTIVATED_STATE_CONTEXT_ITEM);
232 if (__pContentGroupedTableView->IsContextItemOpened(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex))
234 __pContentGroupedTableView->CloseContextItem(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex);
239 case IDA_FLICK_MENU_ITEM_SHARE:
241 CreateContextMenuN(source);
242 SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_EMAIL | CONTEXT_MENU_ITEM_STYLE_MESSAGE);
246 case IDA_FLICK_MENU_ITEM_SET_AS:
248 CreateContextMenuN(source);
249 SetContextMenuItem(CONTEXT_MENU_ITEM_STYLE_CALL | CONTEXT_MENU_ITEM_STYLE_CALLER);
253 case IDA_FLICK_MENU_ITEM_DELETE:
255 SetCommonPopup(CommonUtil::CreateContentDeletePopup(*this, IDA_COMMON_POPUP_DELETE, IDA_COMMON_POPUP_CANCEL));
257 if (__pContentGroupedTableView->IsContextItemOpened(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex))
259 __pContentGroupedTableView->CloseContextItem(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex);
264 case IDA_COMMON_POPUP_DELETE:
266 ContentInformation* pContentInfo = GetContentInformationActivatedStateContextItem();
267 if (pContentInfo != null)
269 RemoveContentAt(pContentInfo->contentId);
270 __pPresentationModel->InitializeArtistAlbumList(__artistName);
271 __pPresentationModel->InitializeContentList(INIT_VALUE);
273 SetItemCheckedAll(false);
274 __pContentGroupedTableView->RefreshItem(__activatedStateContextItem.__groupIndex, __activatedStateContextItem.__itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);;
280 case IDA_CONTEXT_MENU_ITEM_EMAIL:
282 ContentInformation* pContentInfo = GetContentInformationActivatedStateContextItem();
283 if (pContentInfo != null)
285 EventHandlerContextMenuItemMessageEmail(*pContentInfo, PROVIDER_ID_EMAIL);
289 if (__pContentGroupedTableView->IsContextItemOpened(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex))
291 __pContentGroupedTableView->CloseContextItem(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex);
296 case IDA_CONTEXT_MENU_ITEM_MESSAGE:
298 ContentInformation* pContentInfo = GetContentInformationActivatedStateContextItem();
299 if (pContentInfo != null)
301 EventHandlerContextMenuItemMessageEmail(*pContentInfo, PROVIDER_ID_MESSAGE);
305 SetItemCheckedAll(false);
307 if (__pContentGroupedTableView->IsContextItemOpened(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex))
309 __pContentGroupedTableView->CloseContextItem(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex);
314 case IDA_CONTEXT_MENU_ITEM_CALL:
316 ContentInformation* pContentInfo = GetContentInformationActivatedStateContextItem();
317 if (pContentInfo != null)
319 EventHandlerContextMenuItemCall(*pContentInfo);
323 if (__pContentGroupedTableView->IsContextItemOpened(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex))
325 __pContentGroupedTableView->CloseContextItem(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex);
330 case IDA_CONTEXT_MENU_ITEM_CALLER:
332 EventHandlerContextMenuItemCaller();
334 if (__pContentGroupedTableView->IsContextItemOpened(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex))
336 __pContentGroupedTableView->CloseContextItem(__activatedStateContextItem.__groupIndex,__activatedStateContextItem.__itemIndex);
341 case IDA_FOOTER_BUTTON_DELETE:
343 RemoveConentCheckedAll();
351 TryRemoveCommonPopup(actionId);
352 TryRemoveContextMenu(actionId);
357 ArtistContentListForm::OnFormMenuRequested(Tizen::Ui::Controls::Form& source)
359 if (GetScreenState() == SCREEN_STATE_NORMAL && IsEmptyContentList() == false)
361 CreateOptionMenuN(source);
362 SetOptionMenuItem(CONTEXT_MENU_ITEM_STYLE_SHARE_VIA | CONTEXT_MENU_ITEM_STYLE_EDIT);
366 ArtistContentListForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex,
367 Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
369 AppLogDebug("ENTER");
370 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED && GetScreenState() != SCREEN_STATE_NORMAL)
373 if (tableView.GetItemCountAt(groupIndex) == GetCheckedItemCountAt(groupIndex))
378 SetItemCheckedAt(groupIndex, ischeck);
379 SetCheckedCountBallonTooltip(GetCheckedItemCount());
380 tableView.Invalidate(true);
382 if (GetFooter() != null)
384 CommonUtil::SetFooterItemEnabled(*GetFooter(), ischeck);
391 ArtistContentListForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex,
392 Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
394 AppLogDebug("ENTER");
395 if (GetScreenState() != SCREEN_STATE_NORMAL)
397 SetItemCheckedStateChanged(status, groupIndex, itemIndex);
402 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
404 SceneManager* pSceneManager = SceneManager::GetInstance();
405 AppAssert(pSceneManager);
407 ArrayList* pSceneArg = MakePlayerSceneParam(groupIndex, itemIndex);
408 if (pSceneArg != null)
410 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_PLAYER), pSceneArg);
417 ArtistContentListForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex,
418 int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
420 AppLogDebug("ENTER");
421 if (activated == true)
423 __activatedStateContextItem.__groupIndex = groupIndex;
424 __activatedStateContextItem.__itemIndex = itemIndex;
430 ArtistContentListForm::GetGroupCount(void)
432 AppLogDebug("ENTER");
433 if (__pPresentationModel == null)
439 return __pPresentationModel->GetArtistAlbumListCount();
443 ArtistContentListForm::GetItemCount(int groupIndex)
445 AppLogDebug("ENTER");
446 if (__pPresentationModel == null)
451 return __pPresentationModel->GetArtistAlbumContentCount(groupIndex);
454 Tizen::Ui::Controls::TableViewGroupItem*
455 ArtistContentListForm::CreateGroupItem(int groupIndex, int itemWidth)
457 AppLogDebug("ENTER");
458 RelativeLayout layout;
460 FloatDimension size = CoordinateSystem::AlignToDevice(FloatDimension(itemWidth,H_TABLEVIEW_GROUP_ITEM));
461 TableViewGroupItem* pGroupItem = new (std::nothrow) TableViewGroupItem();
462 if (IsFailed(pGroupItem->Construct(layout, FloatDimension(size.width, size.height))))
464 AppLogDebug("TableViewGroupItem.Construct() failed(%s)", GetErrorMessage(GetLastResult()));
469 ContentInformation* pContentInfo = __pPresentationModel->GetArtistAlbumInfoN(groupIndex);
470 if (pContentInfo != null)
472 CreateTableViewGroupItem(*pGroupItem, *pContentInfo);
473 RequestThumbnail(pContentInfo->contentId, (new (std::nothrow) TableviewItemTag(groupIndex, -1)));
482 ArtistContentListForm::DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
484 AppLogDebug("ENTER");
490 ArtistContentListForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
492 AppLogDebug("ENTER");
493 Panel* pItemPanel = static_cast<Panel*>(pItem->GetControl(IDL_CONTENT_LIST_ARTIST_GROUPITEM_PANEL));
494 if (pItemPanel == null)
496 AppLogDebug("pItemPanel is null");
502 Label* pThumbnailLabel = static_cast<Label*>(pItemPanel->GetControl(IDC_LABEL_CONTENT_THUMBNAIL));
503 if (__pThumbnail == null || pThumbnailLabel == null)
505 AppLogDebug("__pThumbnail or pThumbnailLabel is null");
510 pThumbnailLabel->SetBackgroundBitmap(*__pThumbnail);
513 pThumbnailLabel->Invalidate(true);
517 Tizen::Ui::Controls::TableViewItem*
518 ArtistContentListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
520 AppLogDebug("ENTER");
521 RelativeLayout layout;
524 TableViewAnnexStyle tableViewAnnexStyle = TABLE_VIEW_ANNEX_STYLE_NORMAL;
525 if (GetScreenState() != SCREEN_STATE_NORMAL)
527 tableViewAnnexStyle = TABLE_VIEW_ANNEX_STYLE_MARK;
530 if (__pPresentationModel->GetCurrentArtistAlbumIndex() != groupIndex)
532 __pPresentationModel->InitializeContentList(groupIndex);
535 TableViewItem* pItem = new (std::nothrow) TableViewItem();
536 ContentInformation* pContentInfo = __pPresentationModel->GetArtistAlbumContentInfoN(itemIndex);
538 result r = pItem->Construct(layout, Dimension(itemWidth, __itemHeight), tableViewAnnexStyle);
539 TryCatch(r == E_SUCCESS, delete pItem, "pItem->Construct(%s)", GetErrorMessage(r));
540 TryCatch(pContentInfo != null, delete pItem, "pContentInfo is null", GetErrorMessage(GetLastResult()));
542 r = CreateTableViewItem(*pItem, *pContentInfo);
543 TryCatch(r == E_SUCCESS, delete pItem, "CreateTableViewItem failed(%s)", GetErrorMessage(r));
550 AppLogDebug("EXIT(%ls)", GetErrorMessage(GetLastResult()));
556 ArtistContentListForm::DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
558 AppLogDebug("ENTER");
564 ArtistContentListForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
566 AppLogDebug("ENTER");
571 ArtistContentListForm::GetDefaultItemHeight(void)
573 AppLogDebug("ENTER");
575 return H_TABLEVIEW_IITEM;
579 ArtistContentListForm::GetDefaultGroupItemHeight(void)
581 AppLogDebug("ENTER");
583 return H_TABLEVIEW_GROUP_ITEM;
587 ArtistContentListForm::OnThumbnailInfoReveivedN(ThumbnailInfo* pThumbnailInfo)
589 AppLogDebug("ENTER");
590 __pThumbnail = pThumbnailInfo->GetBitmapN();
591 Object* pParam = pThumbnailInfo->GetUserParamN();
594 TableviewItemTag* pTableviewItemTag = static_cast<TableviewItemTag*>(pParam);
595 __pContentGroupedTableView->RefreshItem(pTableviewItemTag->__groupIndex, pTableviewItemTag->__itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
599 delete pThumbnailInfo;
604 ArtistContentListForm::IsEmptyContentList(void)
606 AppLogDebug("ENTER");
607 if (__pPresentationModel != null && __pPresentationModel->GetArtistContentListCount() != INIT_VALUE)
618 ArtistContentListForm::SetHeader(void)
620 AppLogDebug("ENTER");
621 CommonUtil::SetSimpleTitleStyle(*GetHeader(), __headerTitle);
627 ArtistContentListForm::CreateTableViewGroupItem(Tizen::Ui::Controls::TableViewGroupItem& parent, const ContentInformation& contentInfo)
629 AppLogDebug("ENTER");
630 RelativeLayout* pLayOutPortrait = null;
631 Label* pTitleLabel = null;
632 Label* pInnerThumbStroke = null;
633 RelativeLayout* pLayOutLandscape = null;
634 Panel* pItem = new (std::nothrow) Panel();
635 result r = pItem->Construct(IDL_CONTENT_LIST_ARTIST_GROUPITEM_PANEL);
638 AppLogDebug("pItem->Construct() failed(%s)", GetErrorMessage(r));
643 pLayOutPortrait = dynamic_cast<RelativeLayout*>(pItem->GetPortraitLayoutN());
644 pTitleLabel = static_cast<Label*>(pItem->GetControl(IDC_LABEL_CONTENT_TITLE_NAME));
645 pInnerThumbStroke = static_cast<Label*>(pItem->GetControl(IDC_LABEL_THUMBNAIL_INNER_STROKE));
647 if (pLayOutPortrait != null)
649 pLayOutPortrait->SetMargin(*pInnerThumbStroke,CoordinateSystem::ConvertToLogicalX(MARGIN_LEFT_THUMBNAIL_INNER_STROKE),0.0f,CoordinateSystem::ConvertToPhysicalY(MARGIN_TOP_THUMBNAIL_INNER_STROKE),0.0f);
650 pLayOutPortrait->Update();
651 delete pLayOutPortrait;
654 pLayOutLandscape = dynamic_cast<RelativeLayout*>(pItem->GetLandscapeLayoutN());
655 if (pLayOutLandscape != null)
657 pLayOutLandscape->SetMargin(*pInnerThumbStroke,CoordinateSystem::ConvertToLogicalX(MARGIN_LEFT_THUMBNAIL_INNER_STROKE),0.0f,CoordinateSystem::ConvertToPhysicalY(MARGIN_TOP_THUMBNAIL_INNER_STROKE),0.0f);
658 pLayOutLandscape->Update();
659 delete pLayOutLandscape;
661 if (CoordinateSystem::GetPhysicalResolution().width == W_WVGA_RESOLUTION)
663 FloatRectangle rect = CoordinateSystem::AlignToDevice(pTitleLabel->GetBoundsF());
664 pTitleLabel->SetPosition(pTitleLabel->GetXF(),pTitleLabel->GetYF()-Y_GAP_THUMBNAIL);
665 pTitleLabel->SetSize(CoordinateSystem::AlignToDevice(FloatDimension(pTitleLabel->GetWidthF(),pTitleLabel->GetHeightF())));
668 (static_cast<Label*>(pItem->GetControl(IDC_LABEL_CONTENT_THUMBNAIL)))->SetBackgroundBitmap(*GetDefaultThumbnail());
669 pTitleLabel->SetText(contentInfo.AlbumName);
671 parent.AddControl(pItem);
672 parent.SetEnabled(false);
674 CommonUtil::SetLayoutFitToContainer(parent, *pItem);
681 ArtistContentListForm::CreateTableViewItem(Tizen::Ui::Controls::TableViewItem& parent, const ContentInformation& contentInfo)
683 AppLogDebug("ENTER");
684 Panel* pItem = new (std::nothrow) Panel();
686 if (GetScreenState() != SCREEN_STATE_NORMAL)
688 if (__fontSizeValue.Equals(STRING_FONT_SIZE_GIANT, false))
690 if (IsFailed(pItem->Construct(IDL_CONTENT_NOTHUMBNAIL_EDITOR_ITEM_PANEL_FONT_SIZE_GIANT)))
692 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
696 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_HUGE, false))
698 if (IsFailed(pItem->Construct(IDL_CONTENT_NOTHUMBNAIL_EDITOR_ITEM_PANEL_FONT_SIZE_HUGE)))
700 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
704 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_LARGE, false))
706 if (IsFailed(pItem->Construct(IDL_CONTENT_NOTHUMBNAIL_EDITOR_ITEM_PANEL_FONT_SIZE_LARGE)))
708 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
712 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_SMALL, false))
714 if (IsFailed(pItem->Construct(IDL_CONTENT_NOTHUMBNAIL_EDITOR_ITEM_PANEL_FONT_SIZE_SMALL)))
716 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
722 if (IsFailed(pItem->Construct(IDL_CONTENT_NOTHUMBNAIL_EDITOR_ITEM_PANEL_DEFAULT)))
724 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
731 if (__fontSizeValue.Equals(STRING_FONT_SIZE_GIANT, false))
733 if (IsFailed(pItem->Construct(IDL_CONTENT_NOTHUMBNAIL_ITEM_PANEL_FONT_SIZE_GIANT)))
735 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
739 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_HUGE, false))
741 if (IsFailed(pItem->Construct(IDL_CONTENT_NOTHUMBNAIL_ITEM_PANEL_FONT_SIZE_HUGE)))
743 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
747 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_LARGE, false))
749 if (IsFailed(pItem->Construct(IDL_CONTENT_NOTHUMBNAIL_ITEM_PANEL_FONT_SIZE_LARGE)))
751 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
755 else if (__fontSizeValue.Equals(STRING_FONT_SIZE_SMALL, false))
757 if (IsFailed(pItem->Construct(IDL_CONTENT_NOTHUMBNAIL_ITEM_PANEL_FONT_SIZE_SMALL)))
759 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
765 if (IsFailed(pItem->Construct(IDL_CONTENT_NOTHUMBNAIL_ITEM_PANEL_DEFAULT)))
767 AppLogDebug("Construct(IDL_CONTENTS_LIBARY_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
773 (static_cast<Label*>(pItem->GetControl(IDC_LABEL_CONTENT_TITLE_NAME)))->SetText(contentInfo.TitleName);
774 (static_cast<Label*>(pItem->GetControl(IDC_LABEL_CONTENT_ADDITIONAL_INFO)))->SetText(CommonUtil::GetFormatDate(contentInfo.Duration));
776 parent.AddControl(pItem);
777 parent.SetIndividualSelectionEnabled(pItem, true);
779 CommonUtil::SetLayoutFitToContainer(parent, *pItem);
786 ArtistContentListForm::InitCheckedItemMultiHashMap(void)
788 AppLogDebug("ENTER");
789 __pCheckedItemCountMultiHashMap = new (std::nothrow) MultiHashMapT<int, int>();
790 result r = __pCheckedItemCountMultiHashMap->Construct();
793 delete __pCheckedItemCountMultiHashMap;
794 __pCheckedItemCountMultiHashMap = null;
802 ArtistContentListForm::RemoveCheckedItemMultiHashMap(void)
804 AppLogDebug("ENTER");
805 if (__pCheckedItemCountMultiHashMap != null)
807 __pCheckedItemCountMultiHashMap->RemoveAll();
808 delete __pCheckedItemCountMultiHashMap;
809 __pCheckedItemCountMultiHashMap = null;
814 Tizen::Base::Collection::ArrayList*
815 ArtistContentListForm::MakePlayerSceneParam(int albumIndex, int startIndex)
817 AppLogDebug("ENTER");
819 ArrayList* pSelectedMusicContent = __pPresentationModel->GetContentPathListN(albumIndex, SEARCH_MODE_ARTIST_ALBUM);
821 ArrayList* pRetList = new (std::nothrow) ArrayList();
822 pRetList->Construct();
824 for (int i = 0; i < __pPresentationModel->GetArtistAlbumListCount(); i++)
826 if (__pPresentationModel->GetCurrentArtistAlbumIndex() != i)
828 __pPresentationModel->InitializeContentList(i);
831 for (int j = 0; j < __pPresentationModel->GetArtistAlbumContentCount(i); j++ )
833 ContentInformation* pContentInfo = __pPresentationModel->GetArtistAlbumContentInfoN(j);
834 pRetList->Add(new String(pContentInfo->ContentFilePath));
838 //ArrayList* pSelectedMusicContent = __pPresentationModel->GetAllContentPathListN();
839 startIndex = startIndex + GetOffsetContentIndex(albumIndex);
841 if (pRetList->GetCount() == 0)
848 ArrayList* pTempList = new (std::nothrow) ArrayList();
849 if (IsFailed(pTempList->Construct()))
851 AppLogDebug("Construct failed(%s)", GetErrorMessage(GetLastResult()));
854 pRetList->RemoveAll();
859 pTempList->Add(*(new (std::nothrow) String(MUSIC)));
860 pTempList->Add(*(new (std::nothrow) Integer(startIndex)));
861 pTempList->Add(*(pRetList));
868 ArtistContentListForm::OnAppControlCompleteResponseReceived(const AppId& appId,
869 const String& operationId, AppCtrlResult appControlResult,
870 const IMap* pExtraData)
872 AppLogDebug("ENTER");
873 if (pExtraData == null)
879 AppLogDebug("%ls, %ls", appId.GetPointer(), operationId.GetPointer());
880 if (appId.Equals(String(PROVIDER_ID_CONTACT)))
882 if (appControlResult == APP_CTRL_RESULT_SUCCEEDED)
886 ArrayList* pArrayListValue = null;
887 String* pResultString = null;
888 if (pExtraData != null)
890 IMapEnumerator* pEnum = pExtraData->GetMapEnumeratorN();
891 while (pEnum->MoveNext() == E_SUCCESS)
893 pKey = static_cast<String*>(pEnum->GetKey());
894 if (pKey->Equals(APPCONTROL_KEY_SOCIAL_ITEM_ID, true))
896 pArrayListValue = static_cast<ArrayList*>(pEnum->GetValue());
897 pResultString = static_cast<String*>(pArrayListValue->GetAt(0));
898 AppLogDebug("extraData : %ls:%ls", pKey->GetPointer(), pResultString->GetPointer());
899 Integer::Parse(*pResultString, contactId);
907 AppLogDebug("pKey is invaild");
913 AppLogDebug("pExtraData is null");
917 AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
918 Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);
920 ContentInformation* pCcontentInfo = GetContentInformationActivatedStateContextItem();
921 if (pCcontentInfo == null)
928 Contact* pContact = pAddressbook->GetContactN(contactId);
929 pContact->SetValue(CONTACT_PROPERTY_ID_RINGTONE, pCcontentInfo->ContentFilePath);
930 result r = pAddressbook->UpdateContact(*pContact);
934 ShowDelayedMessageBox(ResourceManager::GetString(L"IDS_COM_POP_SUCCESS"));
937 delete pCcontentInfo;
938 pCcontentInfo = null;
951 ArtistContentListForm::AddCheckedItem(int groupIndex, int itemIndex)
953 AppLogDebug("ENTER");
955 __pCheckedItemCountMultiHashMap->Contains(groupIndex, itemIndex, isFind);
958 AppLogDebug("This item Already Set (groupIndex:%d, itemIndex:%d)", groupIndex, itemIndex);
959 return E_ALREADY_SET;
962 return __pCheckedItemCountMultiHashMap->Add(groupIndex, itemIndex);
966 ArtistContentListForm::RemoveCheckedItem(int groupIndex, int itemIndex)
968 AppLogDebug("ENTER");
970 __pCheckedItemCountMultiHashMap->Contains(groupIndex, itemIndex, isFind);
973 AppLogDebug("This item not found(groupIndex:%d, itemIndex:%d)", groupIndex, itemIndex);
974 return E_DATA_NOT_FOUND;
977 return __pCheckedItemCountMultiHashMap->Remove(groupIndex, itemIndex);
981 ArtistContentListForm::SetItemChecked(int groupIndex, int itemIndex, bool check)
983 AppLogDebug("ENTER");
984 result r = E_FAILURE;
987 r = AddCheckedItem(groupIndex, itemIndex);
991 r = RemoveCheckedItem(groupIndex, itemIndex);
998 ArtistContentListForm::GetCheckedItemCountAt(int groupIndex)
1000 AppLogDebug("ENTER");
1002 __pCheckedItemCountMultiHashMap->GetCount(groupIndex, itemCount);
1003 AppLogDebug("EXIT");
1008 ArtistContentListForm::GetTotalItemCount(void)
1010 AppLogDebug("ENTER");
1011 int totalItemCount = 0;
1012 int groupCount = __pContentGroupedTableView->GetGroupCount();
1013 for (int iCount = 0; iCount < groupCount; iCount++)
1015 totalItemCount = totalItemCount + __pContentGroupedTableView->GetItemCountAt(iCount);
1017 AppLogDebug("EXIT");
1018 return totalItemCount;
1022 ArtistContentListForm::GetCheckedItemCount(void)
1024 AppLogDebug("ENTER");
1025 AppLogDebug("EXIT");
1026 return __pCheckedItemCountMultiHashMap->GetCount();
1030 ArtistContentListForm::SetItemCheckedAt(int groupIndex, bool check)
1032 AppLogDebug("ENTER");
1033 int groupItemCount = __pContentGroupedTableView->GetItemCountAt(groupIndex);
1036 groupItemCount = __pContentGroupedTableView->GetItemCountAt(groupIndex);
1037 for (int iCount= 0; iCount < groupItemCount; iCount++)
1039 __pContentGroupedTableView->SetItemChecked(groupIndex, iCount, check);
1040 SetItemChecked(groupIndex, iCount, check);
1045 __pCheckedItemCountMultiHashMap->Remove(groupIndex);
1046 for (int iCount= 0; iCount < groupItemCount; iCount++)
1048 __pContentGroupedTableView->SetItemChecked(groupIndex, iCount, check);
1051 AppLogDebug("EXIT");
1055 ArtistContentListForm::SetItemCheckedAll(bool isChecked)
1057 AppLogDebug("ENTER");
1058 int groupCount = __pContentGroupedTableView->GetGroupCount();
1059 for (int iCount= 0; iCount < groupCount; iCount++)
1061 SetItemCheckedAt(iCount, isChecked);
1064 if (GetFooter() != null)
1066 CommonUtil::SetFooterItemEnabled(*GetFooter(), isChecked);
1069 SetCheckedCountBallonTooltip(GetCheckedItemCount());
1070 __pContentGroupedTableView->Invalidate(true);
1071 AppLogDebug("EXIT");
1075 ArtistContentListForm::UpdateTableView(void)
1077 AppLogDebug("ENTER");
1078 __pContentGroupedTableView->UpdateTableView();
1079 AppLogDebug("EXIT");
1083 ArtistContentListForm::UpdateContentList(void)
1085 AppLogDebug("ENTER");
1086 __pPresentationModel->UpdateArtistList();
1087 __pPresentationModel->InitializeArtistAlbumList(__artistName);
1088 __pPresentationModel->InitializeContentList(INIT_VALUE);
1090 if (__pPresentationModel->GetArtistAlbumListCount() == 0)
1092 __headerTitle = L"";
1093 SceneManager* pSceneManager = SceneManager::GetInstance();
1094 AppAssert(pSceneManager);
1095 SetScreenState(SCREEN_STATE_NORMAL);
1096 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_DESTROY_OPTION_KEEP));
1101 __headerTitle = __artistName;
1104 if (GetScreenState() == SCREEN_STATE_NORMAL)
1111 AppLogDebug("EXIT");
1115 ArtistContentListForm::GetContentInformationActivatedStateContextItem(void)
1117 AppLogDebug("ENTER");
1118 if (__pPresentationModel->GetCurrentArtistAlbumIndex() != __activatedStateContextItem.__groupIndex)
1120 __pPresentationModel->InitializeContentList(__activatedStateContextItem.__groupIndex);
1123 AppLogDebug("EXIT");
1124 return __pPresentationModel->GetArtistAlbumContentInfoN(__activatedStateContextItem.__itemIndex);
1128 ArtistContentListForm::EventHandlerContextMenuItemCaller(void)
1130 AppLogDebug("ENTER");
1131 AppControl* pAppControl = AppManager::FindAppControlN(PROVIDER_ID_CONTACT, OPERATION_ID_SOCIAL_PICK);
1132 if (pAppControl == null)
1134 AppLogDebug("AppManager::FindAppControlN is null");
1138 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1139 result r = pDataList->Construct();
1142 AppLogDebug("pDataList->Construct() failed(%s)", GetErrorMessage(r));
1146 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE), new (std::nothrow) String(APPCONTROL_OPTION_SINGLE));
1147 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE), new (std::nothrow) String(APPCONTROL_OPTION_PERSON));
1148 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE), new (std::nothrow) String(APPCONTROL_OPTION_ITEM_ID));
1150 r = pAppControl->Start(null, null, pDataList, this);
1153 Frame* pFrame = MusicPlayerApp::GetInstance()->GetFrameAt(0);
1155 pFrame->SetEnabled(false);
1159 AppLogDebug("AppControl Start fail");
1162 pDataList->RemoveAll(true);
1169 AppLogDebug("EXIT");
1174 ArtistContentListForm::EventHandlerContextMenuItemCall(ContentInformation& contentInfo)
1176 AppLogDebug("ENTER");
1177 result r = SettingInfo::SetValue(CALL_RINGTONE_KEY, contentInfo.ContentFilePath);
1180 AppLogDebug("SettingInfo::SetValue failed(%s)", GetErrorMessage(r));
1184 MessageBox messageBox;
1185 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_SUCCESS"),
1187 COUNT_MESSAGE_BOX_TIMEOUT);
1188 int modalResult = 0;
1189 messageBox.ShowAndWait(modalResult);
1191 AppLogDebug("EXIT");
1196 ArtistContentListForm::EventHandlerContextMenuItemMessageEmail(ContentInformation& contentInfo, Tizen::Base::String providerId)
1198 AppLogDebug("ENTER");
1199 result r = E_FAILURE;
1200 if (!providerId.Equals(PROVIDER_ID_EMAIL, false) && !providerId.Equals(PROVIDER_ID_MESSAGE, false))
1202 AppLogDebug("worng providerId(%s)", providerId.GetPointer());
1206 AppControl* pAppControl = AppManager::FindAppControlN(providerId, OPERATION_ID_COMPOSE);
1207 if (pAppControl == null)
1209 AppLogDebug("AppManager::FindAppControlN is null");
1213 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1214 pDataList->Construct();
1216 Tizen::Base::Collection::ArrayList* pValueList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1217 pValueList->Construct();
1218 pValueList->Add(*(new (std::nothrow) String(contentInfo.ContentFilePath)));
1220 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), pValueList);
1222 r = pAppControl->Start(null, null, pDataList, this);
1225 Frame* pFrame = MusicPlayerApp::GetInstance()->GetFrameAt(0);
1227 pFrame->SetEnabled(false);
1231 AppLogDebug("AppControl Start fail");
1234 pDataList->RemoveAll(true);
1241 AppLogDebug("EXIT");
1246 ArtistContentListForm::RemoveConentCheckedAll(void)
1248 AppLogDebug("ENTER");
1249 IMapEnumeratorT< int, int >* pMapEnum = __pCheckedItemCountMultiHashMap->GetMapEnumeratorN();
1250 while (pMapEnum->MoveNext() == E_SUCCESS)
1254 pMapEnum->GetKey(key);
1255 pMapEnum->GetValue(value);
1257 if (__pPresentationModel->GetCurrentArtistAlbumIndex() != key)
1259 __pPresentationModel->InitializeContentList(key);
1262 ContentInformation* pContentInfo = __pPresentationModel->GetArtistAlbumContentInfoN(value);
1263 if (pContentInfo != null)
1265 RemoveContentAt(pContentInfo->contentId);
1266 delete pContentInfo;
1271 // SetItemCheckedAll(false);
1273 // __pPresentationModel->InitializeArtistAlbumList(__headerTitle);
1274 // __pPresentationModel->InitializeContentList(INIT_VALUE);
1276 AppLogDebug("EXIT");
1280 Tizen::Base::Collection::IList*
1281 ArtistContentListForm::GetPickerArgumentListN(PickerType pickerType, PickerArgumentType argumentType)
1283 AppLogDebug("ENTER");
1284 ArrayList* pContentFilePathList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1285 if (IsFailed(pContentFilePathList->Construct()))
1287 AppLogDebug("pContentFilePathList->Construct() failed(%s)", GetErrorMessage(GetLastResult()));
1291 if (argumentType == PICKER_ARGUMENT_TYPE_ACTIVATED_STATE_CONTEXT_ITEM)
1293 ContentInformation* pContentInfo = GetContentInformationActivatedStateContextItem();
1294 if (pContentInfo != null)
1296 pContentFilePathList->Add(*(new (std::nothrow) String(pContentInfo->ContentFilePath)));
1297 delete pContentInfo;
1299 AppLogDebug("EXIT");
1300 return pContentFilePathList;
1306 IMapEnumeratorT<int, int>* pMapEnum = __pCheckedItemCountMultiHashMap->GetMapEnumeratorN();
1307 while (pMapEnum->MoveNext() == E_SUCCESS)
1309 pMapEnum->GetKey(key);
1310 pMapEnum->GetValue(value);
1313 if (__pPresentationModel->GetCurrentArtistAlbumIndex() != key)
1315 __pPresentationModel->InitializeContentList(key);
1318 ContentInformation* pContentInfo = __pPresentationModel->GetArtistAlbumContentInfoN(value);
1320 int offset = GetOffsetContentIndex(iCount);
1321 ContentInformation* pContentInfo = __pPresentationModel->GetArtistContentInfoN(offset + value);
1323 if (pContentInfo == null)
1325 AppLogDebug("__pPresentationModel->GetArtistAlbumContentInfoN(%d) is null", value);
1326 delete pContentFilePathList;
1330 if (pickerType == PICKER_TYPE_SHARE_PICKER)
1332 pContentFilePathList->Add(*(new (std::nothrow) String(pContentInfo->ContentFilePath)));
1334 else if (pickerType == PICKER_TYPE_PLAY_LIST_PICKER)
1336 pContentFilePathList->Add(new (std::nothrow) String(pContentInfo->ContentFilePath));
1338 delete pContentInfo;
1342 AppLogDebug("EXIT");
1343 return pContentFilePathList;
1347 ArtistContentListForm::SetItemCheckedStateChanged(Tizen::Ui::Controls::TableViewItemStatus status, int groupIndex, int itemIndex)
1349 AppLogDebug("ENTER");
1350 if (status == TABLE_VIEW_ITEM_STATUS_CHECKED)
1352 SetItemChecked(groupIndex, itemIndex, true);
1353 if (GetCheckedItemCount() == 1)
1355 if (GetFooter() != null)
1357 CommonUtil::SetFooterItemEnabled(*GetFooter(), true);
1361 else if (status == TABLE_VIEW_ITEM_STATUS_UNCHECKED)
1363 SetItemChecked(groupIndex, itemIndex, false);
1364 if (GetCheckedItemCount() == 0)
1366 if (GetFooter() != null)
1368 CommonUtil::SetFooterItemEnabled(*GetFooter(), false);
1372 SetCheckedCountBallonTooltip(GetCheckedItemCount());
1373 AppLogDebug("EXIT");
1377 ArtistContentListForm::GetOffsetContentIndex(const int groupIndex)
1379 AppLogDebug("ENTER");
1380 if (__pContentGroupedTableView == null)
1382 AppLogDebug("__pContentGroupedTableView is null");
1386 int contentIndex = INIT_VALUE;
1387 for (int iCount = 0; iCount < groupIndex; iCount++)
1389 contentIndex = contentIndex + __pContentGroupedTableView->GetItemCountAt(iCount);
1392 AppLogDebug("EXIT");
1393 return contentIndex;
1397 ArtistContentListForm::OnFontSizeChanged(void)
1399 __fontSizeValue = CommonUtil::GetFontSizeValue();
1400 __itemHeight = CommonUtil::GetItemHeight(__fontSizeValue);
1401 __pContentGroupedTableView->UpdateTableView();