ui/uiengine/medialists/src/glxmedialist.cpp
changeset 52 a3a4c0de738e
parent 42 5e1df1b52eb3
equal deleted inserted replaced
50:a0f57508af73 52:a3a4c0de738e
    37 #include "glxnavigablelist.h"
    37 #include "glxnavigablelist.h"
    38 #include "mglxfetchcontext.h"
    38 #include "mglxfetchcontext.h"
    39 #include "mglxmedialistobserver.h"
    39 #include "mglxmedialistobserver.h"
    40 #include "glxmediastaticitemdefs.h"
    40 #include "glxmediastaticitemdefs.h"
    41 
    41 
       
    42 /**
       
    43  * Min & Max wait interval for a modify event, in microseconds
       
    44  * This is to allow thumbnail manager to procees the event first.
       
    45  */
       
    46 const TInt KModifyEventMinWaitInterval = 2000000;
       
    47 const TInt KModifyEventMaxWaitInterval = 3000000;
       
    48 /**
       
    49  * Maximum items count for minimum wait interval.
       
    50  */
       
    51 const TInt KMaxItemsCount = 500;
    42 namespace NGlxMediaList
    52 namespace NGlxMediaList
    43     {
    53     {
    44     /**
    54     /**
    45      * Interface to notify observers. Allows different notifications to use
    55      * Interface to notify observers. Allows different notifications to use
    46      * the same (complicated) iteration loop
    56      * the same (complicated) iteration loop
  1325 
  1335 
  1326     iPath.ReserveL(levels);
  1336     iPath.ReserveL(levels);
  1327     for (TInt level = 0; level < levels; level++) 
  1337     for (TInt level = 0; level < levels; level++) 
  1328         {
  1338         {
  1329         TGlxMediaId id(aPath.Id(level));
  1339         TGlxMediaId id(aPath.Id(level));
  1330         iPath.Append(id); 
  1340         iPath.AppendL(id); 
  1331         }
  1341         }
  1332 
  1342 
  1333     
  1343     
  1334 	// Id space ids will no longer be retrieved from the collection framework
  1344 	// Id space ids will no longer be retrieved from the collection framework
  1335 	// See ID:  ESLU-7C8CVN Inc9 MP: Error "Program closed: Music player" occurs if 
  1345 	// See ID:  ESLU-7C8CVN Inc9 MP: Error "Program closed: Music player" occurs if 
  1528             MGlxMediaListObserver* obs = iItemListObservers[obsIdx];
  1538             MGlxMediaListObserver* obs = iItemListObservers[obsIdx];
  1529             obs->HandleItemModifiedL(itemIndices, this);
  1539             obs->HandleItemModifiedL(itemIndices, this);
  1530             }
  1540             }
  1531 
  1541 
  1532         CleanupStack::PopAndDestroy(&itemIndices);
  1542         CleanupStack::PopAndDestroy(&itemIndices);
       
  1543         RPointerArray<CGlxMediaList>& mediaLists = iMediaListArray->Array();
       
  1544         TInt listCount = mediaLists.Count();
       
  1545         GLX_DEBUG2("ML:HandleItemModifiedL listCount=%d", listCount);
       
  1546         if (listCount > 0)
       
  1547             {
       
  1548             CGlxMediaList* mediaList = mediaLists[listCount-1];
       
  1549             if (mediaList == this)
       
  1550                 {
       
  1551                 GLX_DEBUG3("ML:HandleItemModifiedL(wait) listCount=%d, Id=%d",
       
  1552                                                   listCount, id.Value());
       
  1553                 TTimeIntervalMicroSeconds32 timeout;
       
  1554                 timeout = (mediaList->Count() > KMaxItemsCount ?
       
  1555                   KModifyEventMaxWaitInterval : KModifyEventMinWaitInterval );
       
  1556                 RTimer timer;
       
  1557                 CleanupClosePushL(timer);
       
  1558                 TRequestStatus status;
       
  1559                 timer.CreateLocal();
       
  1560                 timer.After(status, timeout);
       
  1561                 User::WaitForRequest(status);
       
  1562                 CleanupStack::PopAndDestroy(&timer);
       
  1563                 }
       
  1564             }
  1533         }
  1565         }
  1534     }
  1566     }
  1535 
  1567 
  1536 // -----------------------------------------------------------------------------
  1568 // -----------------------------------------------------------------------------
  1537 // NotifyObserversOfMediaL
  1569 // NotifyObserversOfMediaL
  1755 inline void CGlxMediaList::UpdateMedia()
  1787 inline void CGlxMediaList::UpdateMedia()
  1756     {
  1788     {
  1757     TRACER("CGlxMediaList::UpdateMedia");
  1789     TRACER("CGlxMediaList::UpdateMedia");
  1758     
  1790     
  1759     TInt count = iItemList->Count();
  1791     TInt count = iItemList->Count();
       
  1792     GLX_DEBUG2("CGlxMediaList::UpdateMedia() count=%d", count);    
  1760     for (TInt i = 0; i < count; ++i)
  1793     for (TInt i = 0; i < count; ++i)
  1761         {
  1794         {
  1762         TGlxMedia& item = iItemList->Item( i );
  1795         TGlxMedia& item = iItemList->Item( i );
  1763 
  1796 
  1764         // static items should not be updated
  1797         // static items should not be updated
  1857 
  1890 
  1858 void CGlxMediaList::CancelPreviousRequests()
  1891 void CGlxMediaList::CancelPreviousRequests()
  1859 	{
  1892 	{
  1860 	TRACER("CGlxMediaList::CancelPreviousRequests");	
  1893 	TRACER("CGlxMediaList::CancelPreviousRequests");	
  1861 	
  1894 	
  1862 	TInt focusIndex = FocusIndex();
       
  1863 	
  1895 	
  1864 	if(focusIndex >= KErrNone)
       
  1865 		{	
       
  1866 		if(!Item(focusIndex).Properties())
       
  1867 			{
       
  1868 			// If media is NULL, cancel the previous pending request.
  1896 			// If media is NULL, cancel the previous pending request.
  1869 			// Place a new request for the item in focus, to fetch the media attributes
  1897 			// Place a new request for the item in focus, to fetch the media attributes
  1870 			iManager->CancelPreviousRequest();		
  1898 			iManager->CancelPreviousRequest();		
  1871 			}
  1899 			}
  1872 		}
       
  1873 	}