873835c519f59bc41bcc5bb08d4919fdb19894cd
[apps/osp/MyFiles.git] / src / MfSubFolderSelection.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file: MfSubFolderSelection.cpp
19  * @brief: This file contains the implementation of SubFolderSelection class,
20  *  which acts an AppControl for the SubDirectories.
21  */
22
23 #include "MfMyFilesApp.h"
24 #include "MfSubFolderSelection.h"
25 #include "MfSceneRegister.h"
26 #include "MfUtility.h"
27
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Base::Utility;
32 using namespace Tizen::Content;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Io;
35 using namespace Tizen::Locales;
36 using namespace Tizen::Media;
37 using namespace Tizen::System;
38 using namespace Tizen::Telephony;
39 using namespace Tizen::Ui;
40 using namespace Tizen::Ui::Controls;
41 using namespace Tizen::Ui::Scenes;
42
43
44 SubFolderSelection::SubFolderSelection(void)
45         : __pReceivedFilename(null)
46         , __pHomeButton(null)
47         , __pUpButton(null)
48         , __pMoreContextMenu(null)
49         , __pLabelDisplayPath(null)
50         , __pFileEventManager(null)
51 {
52         //Do Nothing
53 }
54
55 SubFolderSelection::~SubFolderSelection(void)
56 {
57         if (__pHomeButton != null)
58         {
59                 delete __pHomeButton;
60         }
61
62         if (__pUpButton != null)
63         {
64                 delete __pUpButton;
65         }
66         if (__pMoreContextMenu != null)
67         {
68                 delete __pMoreContextMenu;
69         }
70         if (__pFileEventManager != null)
71         {
72                 delete __pFileEventManager;
73         }
74 }
75
76 SubFolderSelection&
77 SubFolderSelection::operator =(const SubFolderSelection& pSubFolderSelection)
78 {
79         return *this;
80 }
81
82 SubFolderSelection::SubFolderSelection(const SubFolderSelection& pSubFolderSelection)
83 {
84         //Do Nothing
85 }
86
87
88 bool
89 SubFolderSelection::Initialize(void)
90 {
91         AppLogDebug("Entry");
92         Form::Construct(L"IDL_SUB_FOLDER_FILE_SELECTION");
93         AppLogDebug("Exit");
94         return true;
95 }
96
97 result
98 SubFolderSelection::OnInitializing(void)
99 {
100         AppLogDebug("Entry");
101         result r = E_SUCCESS;
102         String buttonCancel;
103         String buttonAttach;
104         String buttonCreate;
105         String buttonFolder;
106         String buttonHome;
107         String buttonUp;
108         String buttonExport;
109         String buttonHere;
110         String buttonExportHere;
111         String displayPath;
112         ButtonItem footerItemMenu;
113         int xPos = 0, yPos = 0;
114
115         CreateItemSource createitemsource = CREATE_ITEM_SOURCE_SUB_FOLDER_SELECTION;
116
117         AppResource* pAppResource = null;
118         Bitmap* pBitmapHomeButton = null;
119         Bitmap* pBitmapUpButton = null;
120         Bitmap* pBitmapHomeButtonPress = null;
121         Bitmap* pBitmapUpButtonPress = null;
122         Bitmap* pBitmap = null;
123         Bitmap* pBitmapPress = null;
124         Bitmap* pBitmapDisabled = null;
125
126         __pReceivedFilename = new (std::nothrow) String();
127
128         _pListView = static_cast< ListView* >(GetControl("IDC_SUB_FOLDER_SELECTION_LISTVIEW"));
129         TryCatch(_pListView != null, , "Failed to get list view control");
130
131         _pListView->AddListViewItemEventListener(*this);
132         _pListView->SetItemProvider(*this);
133         _pListView->SetShowState(false);
134
135         _selectionMode = ((MyFilesApp*) Application::GetInstance())->GetCurrentSelectionMode();
136         _currentFileType = ((MyFilesApp*) Application::GetInstance())->GetCurrentFileType();
137         _currentViewStyle = ((MyFilesApp*) Application::GetInstance())->GetCurrentView();
138         _currentExportFileType = ((MyFilesApp*) Application::GetInstance())->GetCurrentExportFileType();
139
140         __pLabelDisplayPath = static_cast< Label* >(GetControl("IDC_SUB_FOLDER_SELECTION_LABEL_DISPLAY_PATH"));
141         TryCatch(__pLabelDisplayPath != null, , "Label is Null");
142
143         pAppResource = UiApp::GetInstance()->GetAppResource();
144         TryCatch(pAppResource != null, , "Resource manager not found!");
145
146         displayPath = defaultPhoneBody;
147         displayPath.Append("/");
148
149         //pAppResource->GetString(L"IDS_MF_BUTTON_HOME", buttonHome);
150         pAppResource->GetString(L"IDS_COM_POP_ATTACH", buttonAttach);
151         pAppResource->GetString(L"IDS_COM_POP_CANCEL", buttonCancel);
152         pAppResource->GetString(L"IDS_EXPORT_HERE", buttonExportHere);
153         //pAppResource->GetString(L"IDS_MF_TAB_UP", buttonUp);
154         pBitmap = pAppResource->GetBitmapN(IDB_MORE, BITMAP_PIXEL_FORMAT_ARGB8888);
155         pBitmapPress = pAppResource->GetBitmapN(IDB_MORE_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
156         pBitmapDisabled = pAppResource->GetBitmapN(IDB_MORE_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888);
157         pBitmapHomeButton = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
158         pBitmapUpButton = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
159         pBitmapHomeButtonPress = pAppResource->GetBitmapN(IDB_HOME_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
160         pBitmapUpButtonPress = pAppResource->GetBitmapN(IDB_UP_BUTTON_ICON_PRESS, BITMAP_PIXEL_FORMAT_ARGB8888);
161
162         __displayPath = displayPath;
163
164         _pFolderBitmap = pAppResource->GetBitmapN(IDB_FOLDER, BITMAP_PIXEL_FORMAT_ARGB8888);
165         _pDummyImage = pAppResource->GetBitmapN(IDB_DUMMY_IMG, BITMAP_PIXEL_FORMAT_ARGB8888);
166
167         _pAudioPlay = MfUtility::MergeBitmapN(IDB_PLAY_OUTER_CIRCLE, IDB_PLAY, 64, 64);
168         _pAudioPause = MfUtility::MergeBitmapN(IDB_PLAY_OUTER_CIRCLE, IDB_PAUSE, 64, 64);
169
170         _pFooter = GetFooter();
171
172         if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
173         {
174                 pAppResource->GetString(L"IDS_EXPORT", buttonExport);
175
176                 footerItemMenu.Construct(BUTTON_ITEM_STYLE_ICON, IDA_BTN_MORE);
177                 if (pBitmap != null)
178                 {
179                         pBitmap->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
180                         footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmap);
181                 }
182                 if (pBitmapPress != null)
183                 {
184                         pBitmapPress->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
185                         footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapPress);
186                 }
187                 if (pBitmapDisabled != null)
188                 {
189                         pBitmapDisabled->Scale(Dimension(H_FOOTER_BUTTON_MORE, W_FOOTER_BUTTON_MORE));
190                         footerItemMenu.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapDisabled);
191                 }
192                 if (_pFooter != null)
193                 {
194                         _pFooter->GetPosition(xPos, yPos);
195                 }
196                 __pMoreContextMenu = new (std::nothrow) ContextMenu();
197             __pMoreContextMenu->Construct(Point(0 , yPos), CONTEXT_MENU_STYLE_LIST);
198                 __pMoreContextMenu->AddActionEventListener(*this);
199                 __pMoreContextMenu->SetShowState(true);
200         }
201
202         _pHeader = GetHeader();
203         TryCatch(_pHeader != null, , "Header is Null");
204
205         __pHomeButton = new (std::nothrow) ButtonItem();
206         __pHomeButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_HOME);
207         __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapHomeButton);
208         __pHomeButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapHomeButtonPress);
209
210         __pUpButton = new (std::nothrow) ButtonItem();
211         __pUpButton->Construct(BUTTON_ITEM_STYLE_TEXT, IDA_BTN_UP);
212         __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmapUpButton);
213         __pUpButton->SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmapUpButtonPress);
214
215         _pHeader->SetButton(BUTTON_POSITION_LEFT, *__pHomeButton);
216         _pHeader->SetButton(BUTTON_POSITION_RIGHT, *__pUpButton);
217         _pHeader->AddActionEventListener(*this);
218
219         if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
220         {
221                 _pExport = new (std::nothrow) FooterItem();
222                 r = _pExport->Construct(IDA_BTN_EXPORT);
223                 _pExport->SetText(buttonExportHere);
224
225         }
226         else
227         {
228                 _pAttach = new (std::nothrow) FooterItem();
229                 r = _pAttach->Construct(IDA_BTN_ATTACH);
230                 _pAttach->SetText(buttonAttach);
231         }
232
233         TryCatch(_pFooter != null, , "Footer is Null");
234
235         if (_pFooter != null)
236         {
237                 _pFooter->RemoveAllButtons();
238                 _pFooter->RemoveAllItems();
239                 _pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
240
241                 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
242                 {
243                         _pFooter->AddItem(*_pExport);
244                         _pFooter->SetButton(BUTTON_POSITION_LEFT, footerItemMenu);
245                         //_pFooter->AddItem(*_pCreateFolder);
246                 }
247                 else
248                 {
249                         _pFooter->AddItem(*_pAttach);
250                 }
251
252                 //_pFooter->AddItem(*_pCancel);
253                 _pFooter->AddActionEventListener(*this);
254                 _pFooter->SetBackButton();
255                 SetFormBackEventListener(this);
256                 if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
257                 {
258                         _pFooter->SetItemEnabled(0, false);
259                 }
260                 _pFooter->Invalidate(true);
261         }
262
263         CreateLabelControl();
264
265         _defaultListViewBounds = _pListView->GetBounds();
266
267         _pFolderEntryPM = new (std::nothrow) FolderEntryPresentationModel();
268         TryCatch(_pFolderEntryPM != null, , "Failed to allocate memory");
269         _pFolderEntryPM->Construct();
270         _pFolderEntryPM->SetSourceForm(createitemsource);
271
272         _rootMediaPath = FolderNavigationPresentationModel::GetCurrentPath();
273         _rootStoragePath = BasePresentationModel::GetSdCardPath();
274
275         if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
276         {
277         _pFolderEntryPM->SetFolderEntryType(_currentFileType);
278         _pFolderEntryPM->SetFolderEntryPath(_rootMediaPath);
279         _pFilenames = _pFolderEntryPM->GetFolderEntryList();
280         TryCatch(_pFilenames != null, , "MfMyFilesApp::Failed to allocate Memory to Filenames ArrayList");
281         }
282
283         _pThumbnailManager = ThumbnailManager::GetInstance();
284         TryCatch(_pThumbnailManager != null, , "Thumbnail Manager not found!");
285
286         _pFileManager = FolderEntryEditorPresentationModel::GetInstance();
287         TryCatch(_pFileManager != null, , "File Manager not found!");
288
289         InitializeAppRegistry();
290
291         if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
292         {
293                 __pLabelDisplayPath->SetShowState(true);
294                 _pLabelNumberOfItems->SetShowState(false);
295         }
296
297         _pCallManager = new (std::nothrow) CallManager();
298
299     r = _pCallManager->Construct(*this);
300     TryCatch(r == E_SUCCESS, , "Failed to Construct CallManager");
301
302         AppLogDebug("Exit %s", GetErrorMessage(r));
303
304 #if 0
305         DataBindingContext* pContext = null;
306
307         pContext = GetDataBindingContextN();
308         TryCatch(pContext != null, , "Failed to Fetch the DataBinding Context");
309
310         pContext->Bind(L"ID_APPCONTROL_DISPLAY_PATH", L"IDC_SUB_FOLDER_SELECTION_LABEL_DISPLAY_PATH", L"text", __displayPath, DATA_BINDING_DATA_TYPE_STRING, DATA_BINDING_FLOW_TWO_WAY, DATA_BINDING_TRIGGER_EXPLICIT, null, null, null);
311
312         delete pContext;
313
314 #endif
315
316         delete pBitmapHomeButton;
317         delete pBitmapUpButton;
318         delete pBitmapHomeButtonPress;
319         delete pBitmapUpButtonPress;
320         delete pBitmapDisabled;
321         delete pBitmap;
322         delete pBitmapPress;
323         AppLogDebug("Exit: %s", GetErrorMessage(r));
324         return r;
325
326 CATCH:
327         if (pBitmapHomeButton != null)
328         {
329                 delete pBitmapHomeButton;
330                 pBitmapHomeButton = null;
331         }
332
333         if (pBitmapUpButton != null)
334         {
335                 delete pBitmapUpButton;
336                 pBitmapUpButton = null;
337         }
338         if (pBitmapHomeButtonPress != null)
339         {
340                 delete pBitmapHomeButtonPress;
341                 pBitmapHomeButtonPress = null;
342         }
343         if (pBitmapUpButtonPress != null)
344         {
345                 delete pBitmapUpButtonPress;
346                 pBitmapUpButtonPress = null;
347         }
348         r = E_FAILURE;
349         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
350         return r;
351 }
352
353 result
354 SubFolderSelection::OnTerminating(void)
355 {
356         result r = E_SUCCESS;
357
358         _pHeader = GetHeader();
359         if (_pHeader != null)
360         {
361                 _pHeader->RemoveAllButtons();
362                 _pHeader->RemoveAllItems();
363         }
364
365         _pFooter = GetFooter();
366         if (_pFooter != null)
367         {
368                 _pFooter->RemoveAllButtons();
369                 _pFooter->RemoveAllItems();
370         }
371
372         return r;
373 }
374
375 void
376 SubFolderSelection::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
377 {
378         //empty implementation
379 }
380
381 void
382 SubFolderSelection::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
383 {
384         //empty implementation
385 }
386
387 void
388 SubFolderSelection::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
389 {
390         AppLogDebug("Entry");
391         result r = E_SUCCESS;
392         String selectFiles;
393         String selectedCount;
394         String selectedRootMediaPath;
395         DirectoryEntry* pDirStr = null;
396         String nextFilename;
397         int selectedItemsCount = 0;
398         int itemcount = 0;
399         AppResource* pAppResource = null;
400         SceneManager* pSceneManager = null;
401         ArrayList* pArgs = null;
402         bool itemStatus = false;
403         Integer currentIndex = index;
404         RelativeLayout* pLayout = null;
405
406         pArgs = new (std::nothrow) ArrayList();
407         pArgs->Construct();
408
409         pSceneManager = SceneManager::GetInstance();
410         pAppResource = Application::GetInstance()->GetAppResource();
411         TryCatch(pAppResource != null, , "Resource manager not found!");
412
413         pAppResource->GetString(L"IDS_SELECT_FILES", selectFiles);
414         pAppResource->GetString(L"IDS_COM_BODY_SELECTED", selectedCount);
415
416         itemStatus = _pFileManager->GetCheckedList()->ContainsKey(currentIndex /*,itemStatus*/);
417
418         if (elementId == CONTENT_LIST_ITEM_TYPE_PLAY || elementId == CONTENT_LIST_ITEM_TYPE_PAUSE)
419         {
420                 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
421                 TryCatch(pDirStr != null, , "pDirStr is null");
422
423                 if (!itemStatus)
424                 {
425                         listView.SetItemChecked(index, false);
426                 }
427                 else
428                 {
429                         listView.SetItemChecked(index, true);
430                 }
431
432                 if (_pAudioPlayer == null)
433                 {
434                         InitializePlayer();
435                         LoadMusicPlayer(pDirStr->GetFullFilePath(), PLAYER_STATE_INITIALIZED);
436                         _previousAudioSelected = index;
437                         _currentAudioPlayIndex = index;
438                         _pListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
439
440                         return;
441                 }
442
443                 if (_previousAudioSelected == index)
444                 {
445                         if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING)
446                         {
447                                 _pAudioPlayer->Pause();
448                         }
449                         else
450                         {
451                                 LoadMusicPlayer(pDirStr->GetFullFilePath(), PLAYER_STATE_INITIALIZED);
452                         }
453                 }
454                 else
455                 {
456                         _pAudioPlayer->Stop();
457                         _pAudioPlayer->Close();
458                         _pListView->RefreshList(_previousAudioSelected, LIST_REFRESH_TYPE_ITEM_MODIFY);
459                         _previousAudioSelected = index;
460
461                         LoadMusicPlayer(pDirStr->GetFullFilePath(), PLAYER_STATE_STOPPED);
462                 }
463                 _currentAudioPlayIndex = index;
464                 _pListView->RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY);
465                 //listView.SetItemChecked(index, false);
466                 return;
467         }
468
469         if (_pFilenames != null) //start of FILENAME check if
470         {
471                 pDirStr = static_cast< DirectoryEntry* >(_pFilenames->GetAt(index));
472
473                 if (pDirStr != null) //start of NULL check if
474                 {
475                         if (pDirStr->IsDirectory()) // start of DIRECTORY CHECK if
476                         {
477                                 selectedRootMediaPath = pDirStr->GetFullFilePath();
478                                 nextFilename = pDirStr->GetFileName();
479
480                                 if (_rootMediaPath != null)
481                                 {
482                                         _rootMediaPath.Clear();
483                                         _rootMediaPath.Append(selectedRootMediaPath);
484                                 }
485
486                                 if (_pAudioPlayer != null)
487                                 {
488                                         if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING || _pAudioPlayer->GetState() == PLAYER_STATE_PAUSED)
489                                         {
490                                                 _pAudioPlayer->Stop();
491                                                 _pAudioPlayer->Close();
492                                         }
493                                 }
494                                 FolderNavigationPresentationModel::SetCurrentFilePath(_rootMediaPath);
495
496                                 pArgs->Add(&nextFilename);
497                                 pArgs->Add(&_rootMediaPath);
498                                 ClearSelectedItems(listView);
499                                 pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
500                         } // end of DIRECTORY CHECK if
501                         else //start of FILE CHECK else
502                         {
503                                 if (listView.IsItemChecked(index) == true)
504                                 {
505                                         _pFileManager->AddCheckedListEntry(index, pDirStr);
506                                 }
507                                 else
508                                 {
509                                         _pFileManager->RemoveCheckedListEntry(index);
510                                 }
511
512                                 if (_selectionMode == SELECTION_MODE_SINGE)
513                                 {
514                                         if (listView.IsItemChecked(_storePreviousIndex) == true && _storePreviousIndex != index)
515                                         {
516                                                 listView.SetItemChecked(_storePreviousIndex, false);
517                                                 _pListView->RefreshList(_storePreviousIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
518                                                 _pFileManager->RemoveCheckedListEntry(_storePreviousIndex);
519                                         }
520                                         _storePreviousIndex = index;
521                                 }
522                         } //end of FILE CHECK else
523                 } //end of NULL check if
524
525                 for (itemcount = 0; itemcount <= GetItemCount(); itemcount++)
526                 {
527                         if (listView.IsItemChecked(itemcount) == true)
528                         {
529                                 selectedItemsCount++;
530                         }
531                 }
532
533                 if (selectedItemsCount != 0)
534                 {
535                         r = _pFooter->SetItemEnabled(0, true);
536                 }
537                 else
538                 {
539                         if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
540                         {
541                         _pFooter->SetItemEnabled(0, false);
542                         }
543                 }
544
545                 if (_selectionMode == SELECTION_MODE_MULTIPLE) // start of MULTIPLE_MODE_SELECTION if
546                 {
547
548                         pLayout = dynamic_cast <RelativeLayout*> (Form::GetLayoutN());
549                         if (pLayout != null)
550                         {
551                                 pLayout->SetRelation(*_pListView, _pLabelNumberOfItems,RECT_EDGE_RELATION_BOTTOM_TO_TOP);
552                         }
553
554                         if (selectedItemsCount > 0)
555                         {
556                                 _itemSelectedCount.Clear();
557                                 _itemSelectedCount.Append(selectedCount);
558                                 _itemSelectedCount.Append(L"\x200E");
559                                 _itemSelectedCount.Append(L"(");
560                                 _itemSelectedCount.Append(selectedItemsCount);
561                                 _itemSelectedCount.Append(L")");
562                                 _itemSelectedCount.Append(L"\x200E");
563                                 _pLabelNumberOfItems->SetText(_itemSelectedCount);
564                         }
565                         else
566                         {
567                                 _itemSelectedCount.Clear();
568                                 _itemSelectedCount.Append(selectFiles);
569                                 _pLabelNumberOfItems->SetText(_itemSelectedCount);
570                         }
571
572                         _pLabelNumberOfItems->Invalidate(true);
573
574                         delete pLayout;
575                 }
576         } //end of FILENAME check if
577
578         _pFooter->Invalidate(true);
579
580         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
581         return;
582 CATCH:
583         r = GetLastResult();
584         if (_pFolderEntryPM != null)
585         {
586                 delete _pFolderEntryPM;
587                 _pFolderEntryPM = null;
588         }
589         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
590 }
591
592 void
593 SubFolderSelection::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
594 {
595         //empty implementation
596 }
597
598 void
599 SubFolderSelection::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
600                                                                           const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
601 {
602
603         RelativeLayout* pLayout = null;
604
605         SceneManager::GetInstance()->AddSceneManagerEventListener(*this);
606
607         ((MyFilesApp*) Application::GetInstance())->SetAudioNotificationListener(this);
608         _itemSelectedCount.Clear();
609
610         if (_pFileManager != null)
611         {
612                 if (!_pFileManager->IsCheckedListNull())
613                 {
614                         _pFileManager->ClearCheckedList();
615                 }
616         }
617         if (_selectionMode == SELECTION_MODE_SINGE) // start of MULTIPLE_MODE_SELECTION if
618         {
619                 pLayout  = dynamic_cast <RelativeLayout*> (Form::GetLayoutN());
620                 if (pLayout != null)
621                 {
622                         pLayout->SetRelation(*_pListView, this ,RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
623                 }
624
625                 delete pLayout;
626
627         }
628         if (pArgs != null)
629         {
630                 __pReceivedFilename->Clear();
631                 __pReceivedFilename->Append(*static_cast<String*>(pArgs->GetAt(0)));
632         }
633         else
634         {
635                 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT)
636                 {
637                         String headerDisplayPath = FolderNavigationPresentationModel::GetCurrentPath();
638                         SetHeaderTitleText(headerDisplayPath);
639                         __pReceivedFilename->Clear();
640                 }
641         }
642
643         ((MyFilesApp*) Application::GetInstance())->SetCurrentView(this);
644
645         if (pArgs != null)
646         {
647                 pArgs->RemoveAll(false);
648                 delete pArgs;
649         }
650 }
651
652 void
653 SubFolderSelection::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
654                                                                            const Tizen::Ui::Scenes::SceneId& nextSceneId)
655 {
656         DeviceManager::RemoveAllDeviceEventListeners();
657         ((MyFilesApp*)Application::GetInstance())->SetCurrentView(null);
658         ((MyFilesApp*) Application::GetInstance())->SetAudioNotificationListener(null);
659         _pFolderEntryPM->StopThumbnailManager(true);
660
661         if(__pFileEventManager != null)
662         {
663                 __pFileEventManager->RemovePath(_rootMediaPath);
664         }
665 }
666
667 void
668 SubFolderSelection::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
669 {
670         AppLogDebug("Entry");
671
672         String createFolder;
673         Bitmap* pBitmapCreateFolder = null;
674         AppResource* pAppResource = null;
675         pAppResource = UiApp::GetInstance()->GetAppResource();
676         if (pAppResource != null)
677         {
678                 pAppResource->GetString(L"IDS_COM_BODY_CREATE_FOLDER", createFolder);
679                 pBitmapCreateFolder = pAppResource->GetBitmapN(IDB_POPUP_CREATE_FOLDER_ICON, BITMAP_PIXEL_FORMAT_ARGB8888);
680         }
681
682         switch (actionId)
683         {
684         case IDA_BTN_HOME:
685         {
686                 ShowHomeView();
687                 _pFolderEntryPM->InitThumbnailManager();
688         }
689         break;
690
691         case IDA_BTN_UP:
692         {
693                 ShowParentDirectoryView();
694                 _pFolderEntryPM->InitThumbnailManager();
695         }
696         break;
697
698         case IDA_BTN_MORE:
699         {
700                 __pMoreContextMenu->RemoveAllItems();
701                 __pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
702                 __pMoreContextMenu->SetItemTextColor(CONTEXT_MENU_ITEM_STATUS_PRESSED, Color::GetColor(COLOR_ID_WHITE));
703                 __pMoreContextMenu->AddItem(createFolder, IDA_BTN_CREATE_FOLDER, *pBitmapCreateFolder, null, null);
704                 __pMoreContextMenu->SetShowState(true);
705                 __pMoreContextMenu->Show();
706         }
707         break;
708
709         default:
710         {
711                 SubBaseOnActionPerformed(source, actionId);
712         }
713         break;
714         }
715         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
716 }
717
718 void
719 SubFolderSelection::ShowParentDirectoryView(void)
720 {
721         AppLogDebug("Entry");
722         result r = E_SUCCESS;
723         String displayPath;
724         String ParentPath;
725
726         displayPath = defaultPhoneBody;
727         displayPath.Append("/");
728
729         ParentPath = FolderNavigationPresentationModel::GetParentPath();
730         //_pFileManager->ClearCheckedList();
731
732         if (FolderNavigationPresentationModel::GetCurrentPath() == BasePresentationModel::GetMediaPath() || FolderNavigationPresentationModel::GetCurrentPath() == BasePresentationModel::GetSdCardPath())
733         {
734                 _pFileManager->ClearCheckedList();
735                 ShowHomeView();
736         }
737         else
738         {
739                 if (_currentViewStyle != APPCONTROL_VIEW_EXPORT)
740                 {
741                         ResetFooter();
742                 }
743
744                 if (_pAudioPlayer != null)
745                 {
746                         if (_pAudioPlayer->GetState() == PLAYER_STATE_PLAYING || _pAudioPlayer->GetState() == PLAYER_STATE_PAUSED)
747                         {
748                                 _pAudioPlayer->Stop();
749                                 _pAudioPlayer->Close();
750                         }
751                 }
752                 _rootMediaPath.Clear();
753                 _rootMediaPath.Append(ParentPath);
754
755                 FolderNavigationPresentationModel::SetCurrentFilePath(_rootMediaPath);
756
757                 SetParentDisplayPath();
758                 SetHeaderTitleText(ParentPath);
759
760                 //Remove the current files from the filenames list
761                 if (_pFolderEntryPM != null)
762                 {
763                         _pFolderEntryPM->SetFolderEntryPath(ParentPath);
764                         //Get the files in the parent path of the current view
765                         _pFilenames = _pFolderEntryPM->GetFolderEntryList();
766                         TryCatch(_pFilenames != null, , "Failed to fetch ArrayList from the ContentBrowser!");
767                 }
768
769                 if (_pListView != null)
770                 {
771                         _pListView->UpdateList();
772                         _storePreviousIndex = 0;
773                         }
774         }
775
776         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
777         return;
778 CATCH:
779         r = E_FAILURE;
780         if (_pFolderEntryPM != null)
781         {
782                 delete _pFolderEntryPM;
783                 _pFolderEntryPM = null;
784         }
785         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
786 }
787
788 void
789 SubFolderSelection::SetParentDisplayPath(void)
790 {
791         String dislayPath;
792         String delim(L"/");
793         String parentDisplayPath;
794         String token;
795
796 #if 0
797         DataBindingContext* pContext = null;
798         pContext = GetDataBindingContextN();
799
800         if (pContext != null)
801         {
802                 //Update binding on the source to fetch the current display path.
803                 pContext->UpdateBinding(L"ID_APPCONTROL_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_SOURCE);
804         }
805 #endif
806
807         StringTokenizer tokenizer(__displayPath, delim);
808
809         //Use a string tokenizer to get the filepath until it's the last token, break the loop when
810         //it is the last token
811         while (tokenizer.HasMoreTokens())
812         {
813                 int tokenCount = tokenizer.GetTokenCount();
814
815                 if (tokenCount != 1)
816                 {
817                         tokenizer.GetNextToken(token);
818                         parentDisplayPath.Append(token);
819                         parentDisplayPath.Append(L"/");
820                 }
821                 else
822                 {
823                         break;
824                 }
825         }
826
827         //Set the display path to that of the generated filepath from the tokenizer
828         __displayPath = parentDisplayPath;
829
830 #if 0
831         if (pContext != null)
832         {
833                 //Update Binding on the Target control to display the currently constructed path.
834                 pContext->UpdateBinding(L"ID_APPCONTROL_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
835         }
836
837         if (pContext != null)
838         {
839                 delete pContext;
840         }
841 #endif
842
843         if (__pLabelDisplayPath != null)
844         {
845                 __pLabelDisplayPath->SetText(__displayPath);
846                 __pLabelDisplayPath->Invalidate(true);
847         }
848 }
849
850 void
851 SubFolderSelection::SetHeaderTitleText(Tizen::Base::String& filePath)
852 {
853         String token;
854         String parentFileName;
855         String delimiter(L"/");
856         StringTokenizer tokenizer(filePath, delimiter);
857
858         AppResource* pAppResource = null;
859
860         pAppResource = UiApp::App::GetInstance()->GetAppResource();
861
862         if (filePath == BasePresentationModel::GetMediaPath())
863         {
864                 if (pAppResource != null)
865                 {
866                         pAppResource->GetString(L"IDS_MF_TAB_PHONE", parentFileName);
867                 }
868         }
869         else if (filePath == BasePresentationModel::GetSdCardPath())
870         {
871                 if (pAppResource != null)
872                 {
873                         pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", parentFileName);
874                 }
875         }
876         else
877         {
878                 while (tokenizer.HasMoreTokens())
879                 {
880                         int tokenCount = tokenizer.GetTokenCount();
881
882                         if (tokenCount == 1)
883                         {
884                                 tokenizer.GetNextToken(parentFileName);
885                         }
886                         else
887                         {
888                                 tokenizer.GetNextToken(token);
889                         }
890                 }
891         }
892
893         if (_pHeader != null)
894         {
895                 if (!parentFileName.IsEmpty())
896                 {
897                         _pHeader->SetTitleText(parentFileName);
898                         _pHeader->Invalidate(true);
899                 }
900         }
901 }
902
903 void
904 SubFolderSelection::SetNextDisplayPath(void)
905 {
906         String displayPath;
907         String delim(L"/");
908         String token;
909         String fullPath;
910 #if 0
911         DataBindingContext* pContext = null;
912         pContext = GetDataBindingContextN();
913 #endif
914
915         fullPath = FolderNavigationPresentationModel::GetCurrentPath();
916         //fullPath = __rootMediaPath;
917
918         StringTokenizer tokenizer(fullPath, delim);
919
920         int Counter = 0;
921         switch (_storageType)
922         {
923         case MEMORY_TYPE_PHONE:
924         {
925                 Counter = 3;
926         }
927         break;
928
929         case MEMORY_TYPE_SD_CARD:
930         {
931                 Counter = 3;
932         }
933         break;
934
935         default:
936                 //Do Nothing.
937                 break;
938         }
939
940         //Use a string tokenizer to get the filepath until it's the last token, break the loop when
941         //it is the last token
942         while (tokenizer.HasMoreTokens())
943         {
944                 if (Counter > 0)
945                 {
946                         Counter--;
947                         tokenizer.GetNextToken(token);
948                 }
949                 else
950                 {
951                         tokenizer.GetNextToken(token);
952                         //dislayPath.Append(L"/");
953                         displayPath.Append(token);
954                         displayPath.Append(L"/");
955                 }
956         }
957
958         if (__pLabelDisplayPath != null)
959         {
960                 __displayPath.Append(displayPath);
961                 __pLabelDisplayPath->SetText(__displayPath);
962                 __pLabelDisplayPath->Invalidate(true);
963         }
964
965
966 #if 0
967         if (pContext != null)
968         {
969                 //UpdateBinding on the target label control.
970                 pContext->UpdateBinding(L"ID_APPCONTROL_DISPLAY_PATH", DATA_BINDING_DESTINATION_TYPE_TARGET);
971         }
972
973         if (pContext != null)
974         {
975                 delete pContext;
976         }
977 #endif
978 }
979
980 void
981 SubFolderSelection::OnDataBindingSourceUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
982 {
983         //Empty Implementation.
984 }
985
986 void
987 SubFolderSelection::OnDataBindingTargetUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName)
988 {
989         //Empty Implementation.
990 }
991
992 void
993 SubFolderSelection::OnDataBindingValidationFailed(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName, Tizen::Ui::DataBindingDestinationType destType)
994 {
995         //Empty Implementation.
996 }
997
998 void
999 SubFolderSelection::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)
1000 {
1001         bool setMediaPath = false;
1002         MemoryType currentMemoryType = MEMORY_TYPE_PHONE;
1003         String unmounted = sdCardStatusUnmounted;
1004         String removed = usbDeviceStatusRemoved;
1005         String currentPath;
1006         IList* pArgs = null;
1007
1008         SceneManager* pSceneManager = null;
1009
1010         if (state == unmounted || state == removed)
1011         {
1012                 currentPath = FolderNavigationPresentationModel::GetCurrentPath();
1013                 if (state == unmounted)
1014                 {
1015                         if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))
1016                         {
1017                                 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1018                                 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1019                                 setMediaPath = true;
1020                         }
1021                 }
1022
1023                 if (state == removed)
1024                 {
1025                         if (currentPath.Contains(BasePresentationModel::GetUsbPath()))
1026                         {
1027                                 FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());
1028                                 FolderNavigationPresentationModel::SetStorageType(currentMemoryType);
1029                                 setMediaPath = true;
1030                         }
1031                 }
1032
1033                 if (setMediaPath)
1034                 {
1035                         pSceneManager = SceneManager::GetInstance();
1036                         pArgs = new (std::nothrow) ArrayList();
1037                         pArgs->Add(new (std::nothrow) Integer(APPCONTROL_STATE_SELECTED));
1038
1039                         if (pSceneManager != null)
1040                         {
1041                                 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_TOP_LEVEL_DIRECTORY_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, SCENE_DESTROY_OPTION_DESTROY), pArgs);
1042                         }
1043                 }
1044         }
1045 }
1046
1047 void
1048 SubFolderSelection::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)
1049 {
1050
1051         ComponentType currentDeviceType;
1052         switch (deviceType)
1053         {
1054         case StorageCard:
1055         {
1056                 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;
1057         }
1058         break;
1059
1060         case UsbClient:
1061         {
1062                 currentDeviceType = COMPONENT_TYPE_USB;
1063         }
1064         break;
1065
1066         default:
1067         {
1068                 //Do Nothing.
1069         }
1070         break;
1071         }
1072         OnDeviceChange(currentDeviceType, state);
1073 }
1074
1075 void
1076 SubFolderSelection::OnPlayerEndOfClip(void)
1077 {
1078         if (_pListView != null)
1079         {
1080                 _pListView->RefreshList(_currentAudioPlayIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1081         }
1082 }
1083
1084
1085 void
1086 SubFolderSelection::OnSceneTransitionCompleted (const Tizen::Ui::Scenes::SceneId &previousSceneId, const Tizen::Ui::Scenes::SceneId &currentSceneId)
1087 {
1088         AppLogDebug("ENTER");
1089         SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);
1090         AppResource* pAppResource = null;
1091         String importText;
1092         String displayPath;
1093         String phone;
1094         String sdCard;
1095         String external;
1096         String received_Filepath;
1097         int receivedStorageType = -1;
1098         Tizen::Base::String parentPath;
1099         result r = E_SUCCESS;
1100         pAppResource = Application::GetInstance()->GetAppResource();
1101         TryCatch(pAppResource != null, , "Resource manager not found!");
1102
1103                 pAppResource->GetString(L"IDS_COM_OPT_IMPORT", importText);
1104                 pAppResource->GetString(L"IDS_MF_TAB_PHONE", phone);
1105                 pAppResource->GetString(L"IDS_MF_TAB_MEMORY_CARD", sdCard);
1106                 pAppResource->GetString(L"IDS_MF_TAB_EXTERNAL_STORAGE", external);
1107                 phone.Append(L"/");
1108                 sdCard.Append(L"/");
1109                 external.Append(L"/");
1110
1111         if (_pListView != null)
1112         {
1113                 _pListView->SetShowState(true);
1114         }
1115
1116         if (__pFileEventManager != null)
1117         {
1118                 delete __pFileEventManager;
1119                 __pFileEventManager = null;
1120
1121         }
1122         __pFileEventManager = new (std::nothrow)FileEventManager();
1123         __pFileEventManager->Construct(*this);
1124
1125         r = __pFileEventManager->AddPath(_rootMediaPath, FILE_EVENT_TYPE_ATTRIBUTE | FILE_EVENT_TYPE_MOVED_TO | FILE_EVENT_TYPE_DELETE );
1126         AppLogDebug("Result is %s",GetErrorMessage(r));
1127
1128 #if 0
1129                 if (_currentViewStyle == APPCONTROL_VIEW_EXPORT || _currentViewStyle == APPCONTROL_VIEW_IMPORT)
1130         {
1131                 AppLogDebug("inside view check");
1132                 String backupPath;
1133                 String backupCalendarpath;
1134                 String backupContactpath;
1135                 backupPath = BasePresentationModel::GetMediaPath();
1136                 backupPath.Append("Backup");
1137                 if (!File::IsFileExist(backupPath))
1138                 {
1139                         Directory::Create(backupPath, true);
1140                 }
1141
1142                 if ((_currentViewStyle == APPCONTROL_VIEW_IMPORT && _currentFileType == FILE_TYPE_CALENDER_TYPE)
1143                                 || (_currentViewStyle == APPCONTROL_VIEW_EXPORT && _currentExportFileType == EXPORT_TYPE_CALENDAR))
1144                 {
1145                         backupCalendarpath.Append(backupPath);
1146                         backupCalendarpath.Append("/");
1147                         backupCalendarpath.Append("Calendar");
1148                         if (!File::IsFileExist(backupCalendarpath))
1149                         {
1150                                 r = Directory::Create(backupCalendarpath, true);
1151                                 AppLogDebug("Result is %s",GetErrorMessage(r));
1152                         }
1153                 }
1154                 if ((_currentViewStyle == APPCONTROL_VIEW_IMPORT && _currentFileType == FILE_TYPE_CONTACTS_TYPE)
1155                                 || (_currentViewStyle == APPCONTROL_VIEW_EXPORT && _currentExportFileType == EXPORT_TYPE_CONTACTS))
1156                 {
1157                         backupContactpath.Append(backupPath);
1158                         backupContactpath.Append("/");
1159                         backupContactpath.Append("Contacts");
1160                         if (!File::IsFileExist(backupContactpath))
1161                         {
1162                                 r = Directory::Create(backupContactpath, true);
1163                                 AppLogDebug("Result is %s",GetErrorMessage(r));
1164                         }
1165                 }
1166
1167                 /*_pFolderEntryPM->SetFolderEntryType(_currentFileType);
1168                                 _pFolderEntryPM->SetFolderEntryPath(_rootMediaPath);
1169                                 _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1170                  */
1171         }
1172 #endif
1173         if (__pReceivedFilename != null)
1174         {
1175                 //pReceived_Filename = static_cast< String* >(pArgs->GetAt(0));
1176                 received_Filepath = FolderNavigationPresentationModel::GetCurrentPath();
1177                 receivedStorageType = FolderNavigationPresentationModel::GetStorageType();
1178
1179                 if (__pReceivedFilename != null && !__pReceivedFilename->IsEmpty())
1180                 {
1181                         _pHeader = GetHeader();
1182                         if (_pHeader != null)
1183                         {
1184                                 _pHeader->SetTitleText(*__pReceivedFilename);
1185                                 _pHeader->Invalidate(true);
1186                         }
1187                 }
1188                 if (received_Filepath != null)
1189                 {
1190
1191                         //Clear the rootMediaPath and set it to the received filepath.
1192                         //if (_rootMediaPath != null)
1193                         {
1194                                 _rootMediaPath.Clear();
1195                                 _rootMediaPath.Append(received_Filepath);
1196                         }
1197
1198                                 if (__pLabelDisplayPath != null)
1199                                 {
1200                                         switch (receivedStorageType)
1201                                         {
1202                                         case MEMORY_TYPE_PHONE:
1203                                         {
1204                                                 __displayPath = phone;
1205                                                 _storageType = MEMORY_TYPE_PHONE;
1206                                                 //AppResource::GetInstance()->GetString(L"IDS_MF_TAB_PHONE", __tabSelected);
1207                                         }
1208                                         break;
1209
1210                                         case MEMORY_TYPE_SD_CARD:
1211                                         {
1212                                                 __displayPath = sdCard;
1213                                                 _storageType = MEMORY_TYPE_SD_CARD;
1214                                                 //AppResource::GetInstance()->GetString(L"IDS_SD_CARD", __tabSelected);
1215                                         }
1216                                         break;
1217
1218                                         case MEMORY_TYPE_EXTERNAL:
1219                                         {
1220                                                 __displayPath = external;
1221                                                 _storageType = MEMORY_TYPE_EXTERNAL;
1222                                         }
1223                                         break;
1224
1225                                         default:
1226                                         {
1227                                                 //Empty Implementation.
1228                                         }
1229                                         break;
1230                                         }
1231
1232                                         //Call the function to set the DisplayPath of the label.
1233                                         SetNextDisplayPath();
1234                                 }
1235
1236                         }
1237                 }
1238                 else
1239                 {
1240                         _rootMediaPath = FolderNavigationPresentationModel::GetCurrentPath();
1241                 }
1242
1243                 parentPath.Append(_rootMediaPath);
1244
1245                 if (_pFolderEntryPM != null)
1246                 {
1247                         _pFolderEntryPM->SetFolderEntryPath(parentPath);
1248                         _pFilenames = _pFolderEntryPM->GetFolderEntryList();
1249                         TryCatch(_pFilenames != null, , "Failed to allocate Memory to Filenames ArrayList");
1250                         _pFolderEntryPM->InitThumbnailManager();
1251                 }
1252
1253         if (_pListView != null)
1254         {
1255                 _pListView->UpdateList();
1256         }
1257
1258         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
1259         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
1260         return;
1261 CATCH:
1262         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));
1263 }
1264
1265 void
1266 SubFolderSelection::OnSceneTransitionStarted (const Tizen::Ui::Scenes::SceneId &currentSceneId, const Tizen::Ui::Scenes::SceneId &nextSceneId)
1267 {
1268
1269 }
1270 void SubFolderSelection::OnPlayerAudioFocusChanged (void)
1271 {
1272         int AudioPlayerState = _pAudioPlayer->GetState();
1273
1274         AppLogDebug("SubFolderSelectionForm %d ++", AudioPlayerState);
1275         if (AudioPlayerState == PLAYER_STATE_PAUSED)
1276         {
1277                 AppLogDebug("Pause");
1278                 AppLogDebug("Refreshing  %d", _currentAudioPlayIndex);
1279                 _pListView->RefreshList(_currentAudioPlayIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1280         }
1281
1282         AppLogDebug("SubFolderSelectionForm--");
1283 }
1284
1285 void
1286 SubFolderSelection::OnFileEventOccured(const unsigned long events,const Tizen::Base::String &  path, const unsigned int eventId)
1287 {
1288         AppLogDebug("SubFolderSelection::OnFileEventOccured:%S", path.GetPointer());
1289
1290         if ((events & FILE_EVENT_TYPE_ATTRIBUTE) || (events & FILE_EVENT_TYPE_DELETE) || (events & FILE_EVENT_TYPE_MOVED_TO ))
1291         {
1292                 if (_pFolderEntryPM!=null)
1293                 {
1294                         _pFolderEntryPM->RefreshFolderEntries();
1295                 }
1296
1297                 if (_pListView != null && _pListView->IsVisible())
1298                 {
1299                         _pListView->UpdateList();
1300                 }
1301
1302                 if (_pFolderEntryPM!=null)
1303                 {
1304                         AppLogDebug("inside file event");
1305                         _pFolderEntryPM->InitThumbnailManager();
1306                 }
1307         }
1308 }
1309
1310 void
1311 SubFolderSelection::OnAudioNotificationReceived(void)
1312 {
1313         int AudioPlayerState;
1314
1315         if (_pAudioPlayer != null)
1316         {
1317                 AudioPlayerState = _pAudioPlayer->GetState();
1318                 if (AudioPlayerState == PLAYER_STATE_PLAYING)
1319                 {
1320                         _pAudioPlayer->Pause();
1321                         _pListView->RefreshList(_currentAudioPlayIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1322                 }
1323         }
1324 }