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