photosgallery/viewframework/medialists/src/glxmedialistiterator.cpp
branchRCL_3
changeset 32 78ad99c24f08
parent 18 bcb43dc84c44
equal deleted inserted replaced
30:a60acebbbd9d 32:78ad99c24f08
   485     // front and rear. 
   485     // front and rear. 
   486     
   486     
   487     // |-------F----------------------|
   487     // |-------F----------------------|
   488     // |< jumping zone>|
   488     // |< jumping zone>|
   489 
   489 
   490     TInt index = iIndexFunctor.Index();
   490     TInt index = iIndexFunctor.Index();    
   491     __ASSERT_ALWAYS( index >= 0 && index < iList->Count(), Panic( EGlxPanicIllegalState ) );
   491     __ASSERT_DEBUG( index >= 0 && index < count, Panic( EGlxPanicIllegalState ) );
       
   492     if (index < 0 || index >= count)
       
   493         {
       
   494 		// Invalid index, out of bounds
       
   495         return KErrNotFound;
       
   496         }
       
   497     
   492     index -= index % KGlxBlockyIteratorDefaultGranularity;
   498     index -= index % KGlxBlockyIteratorDefaultGranularity;
   493 
   499 
   494     TInt min = Min(iFrontOffset, iRearOffset);
   500     TInt min = Min(iFrontOffset, iRearOffset);
   495     TInt jumpingZoneLength = min * 2;
   501     TInt jumpingZoneLength = min * 2;
   496     if (iCurrentItem <= jumpingZoneLength) 
   502     if (iCurrentItem <= jumpingZoneLength) 
   547         // Range is longer than count, must be in range
   553         // Range is longer than count, must be in range
   548         return ETrue;
   554         return ETrue;
   549         }
   555         }
   550   
   556   
   551     TInt index = iIndexFunctor.Index();
   557     TInt index = iIndexFunctor.Index();
   552     __ASSERT_ALWAYS( index >= 0 && index < iList->Count(), Panic( EGlxPanicIllegalState ) );
   558     __ASSERT_DEBUG( index >= 0 && index < count, Panic( EGlxPanicIllegalState ) );
       
   559     if (index < 0 || index >= count)
       
   560         {
       
   561 		// Invalid index, must be out of range
       
   562         return EFalse;
       
   563         }	
   553     index -= index % KGlxBlockyIteratorDefaultGranularity;
   564     index -= index % KGlxBlockyIteratorDefaultGranularity;
   554     TInt firstInRange = GlxListUtils::NormalizedIndex(index - iRearOffset, count);
   565     TInt firstInRange = GlxListUtils::NormalizedIndex(index - iRearOffset, count);
   555     TInt lastInRange = GlxListUtils::NormalizedIndex(index + iFrontOffset, count);
   566     TInt lastInRange = GlxListUtils::NormalizedIndex(index + iFrontOffset, count);
   556   
   567   
   557     if (firstInRange <= lastInRange)
   568     if (firstInRange <= lastInRange)
   972     // |< jumping zone>|
   983     // |< jumping zone>|
   973 
   984 
   974     TInt visIndex = iList->VisibleWindowIndex();
   985     TInt visIndex = iList->VisibleWindowIndex();
   975     TInt index = visIndex;
   986     TInt index = visIndex;
   976     TInt listCount = iList->Count();
   987     TInt listCount = iList->Count();
   977     __ASSERT_ALWAYS( index >= 0 && index <= listCount, Panic( EGlxPanicIllegalState ) );
   988     __ASSERT_DEBUG( index >= 0 && index <= listCount, Panic( EGlxPanicIllegalState ) );
       
   989     if (index < 0 || index >= listCount)
       
   990         {
       
   991 		// Invalid index, out of bounds
       
   992         return KErrNotFound;
       
   993         }
       
   994     
   978     //Inorder to ensure that the start of refresh of thumbnails is contained in
   995     //Inorder to ensure that the start of refresh of thumbnails is contained in
   979     //in the current visible window. We set the startIndex to center element of 
   996     //in the current visible window. We set the startIndex to center element of 
   980     //the current visible window.
   997     //the current visible window.
   981     TInt startIndex = index + iDefaultVisItems/2;
   998     TInt startIndex = index + iDefaultVisItems/2;
   982     if (listCount < iDefaultVisItems)
   999     if (listCount < iDefaultVisItems)
  1051         // Range is longer than count, must be in range
  1068         // Range is longer than count, must be in range
  1052         return ETrue;
  1069         return ETrue;
  1053         }
  1070         }
  1054   
  1071   
  1055     TInt index = iList->VisibleWindowIndex();
  1072     TInt index = iList->VisibleWindowIndex();
  1056     __ASSERT_ALWAYS( index >= 0 && index < iList->Count(), Panic( EGlxPanicIllegalState ) );
  1073     __ASSERT_DEBUG( index >= 0 && index < count, Panic( EGlxPanicIllegalState ) );
       
  1074     if (index < 0 || index >= count)
       
  1075         {
       
  1076 		// Invalid index, must be out of range
       
  1077         return EFalse;
       
  1078         }    
  1057     
  1079     
  1058     TInt firstInRange = GlxListUtils::NormalizedIndex(index - iRearOffset, count);
  1080     TInt firstInRange = GlxListUtils::NormalizedIndex(index - iRearOffset, count);
  1059     TInt lastInRange = GlxListUtils::NormalizedIndex(index + iFrontOffset, count);
  1081     TInt lastInRange = GlxListUtils::NormalizedIndex(index + iFrontOffset, count);
  1060   
  1082   
  1061     if (firstInRange <= lastInRange)
  1083     if (firstInRange <= lastInRange)