29 |
29 |
30 #include <glxuistd.h> // Fetch context priority def'ns |
30 #include <glxuistd.h> // Fetch context priority def'ns |
31 |
31 |
32 const TInt KInitialThumbnailsTimeDelay(100000); |
32 const TInt KInitialThumbnailsTimeDelay(100000); |
33 const TInt KWaitCount(5); |
33 const TInt KWaitCount(5); |
34 const TInt KThumbnailStartTimeDelay(2000000); |
34 const TInt KThumbnailStartTimeDelay(250000); |
35 const TInt KThumbnailIntervalTimeDelay(2000000); |
35 const TInt KThumbnailIntervalTimeDelay(50000); |
36 const TInt KPreviewThumbnailFetchCount(18); |
36 const TInt KPreviewThumbnailFetchCount(1); |
37 |
37 |
38 // ---------------------------------------------------------------------------- |
38 // ---------------------------------------------------------------------------- |
39 // NewL |
39 // NewL |
40 // ---------------------------------------------------------------------------- |
40 // ---------------------------------------------------------------------------- |
41 // |
41 // |
81 TRACER("CGlxPreviewThumbnailBinding::ConstructL"); |
81 TRACER("CGlxPreviewThumbnailBinding::ConstructL"); |
82 iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
82 iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
83 CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL(); |
83 CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL(); |
84 iGridIconSize = uiUtility->GetGridIconSize(); |
84 iGridIconSize = uiUtility->GetGridIconSize(); |
85 uiUtility->Close() ; |
85 uiUtility->Close() ; |
86 } |
86 |
87 |
87 // Filter that filters out any GIF, corrupted images |
|
88 iPreviewFilter = TGlxFilterFactory::CreatePreviewFilterL(); |
|
89 iThumbnailIterator.SetRange(KPreviewThumbnailFetchCount); |
|
90 iThumbnailContext = new (ELeave) CGlxAttributeContext(&iThumbnailIterator); |
|
91 TMPXAttribute tnAttr( KGlxMediaIdThumbnail, |
|
92 GlxFullThumbnailAttributeId(ETrue, |
|
93 iGridIconSize.iWidth,iGridIconSize.iHeight) ); |
|
94 iThumbnailContext->SetDefaultSpec(iGridIconSize.iWidth, |
|
95 iGridIconSize.iHeight); |
|
96 iThumbnailContext->AddAttributeL(tnAttr); |
|
97 } |
88 |
98 |
89 // ---------------------------------------------------------------------------- |
99 // ---------------------------------------------------------------------------- |
90 // Destructor |
100 // Destructor |
91 // ---------------------------------------------------------------------------- |
101 // ---------------------------------------------------------------------------- |
92 // |
102 // |
221 // This function basically closes the old medialist if any for ex. Tags, |
218 // This function basically closes the old medialist if any for ex. Tags, |
222 // Captured.. and then opens a new medialist with teh required filter. |
219 // Captured.. and then opens a new medialist with teh required filter. |
223 // ---------------------------------------------------------------------------- |
220 // ---------------------------------------------------------------------------- |
224 // |
221 // |
225 void CGlxPreviewThumbnailBinding::HandleItemChangedL(const CMPXCollectionPath& aPath, |
222 void CGlxPreviewThumbnailBinding::HandleItemChangedL(const CMPXCollectionPath& aPath, |
226 TBool aPopulateListTNs ) |
223 TBool aPopulateListTNs, TBool aBackwardNavigation) |
227 { |
224 { |
228 TRACER("CGlxPreviewThumbnailBinding::HandleItemChangedL"); |
225 TRACER("CGlxPreviewThumbnailBinding::HandleItemChangedL"); |
229 iTimerTicked = EFalse; |
226 iTimerTicked = EFalse; |
230 iPopulateListTNs = aPopulateListTNs; |
227 iPopulateListTNs = aPopulateListTNs; |
|
228 iBackwardNavigation = aBackwardNavigation; |
231 iProgressIndex = KErrNone; |
229 iProgressIndex = KErrNone; |
232 |
230 |
233 // remove and close old medialist |
231 // remove and close old medialist |
234 if( iMediaList ) |
232 if( iMediaList ) |
235 { |
233 { |
236 // Reset the trial and the trialCount to 0 while deleting the medialist |
234 // Reset the trial and the trialCount to 0 while deleting the medialist |
237 iTrial = 0; |
235 iTrial = 0; |
238 iTrialCount = 0; |
236 iTrialCount = 0; |
239 iMediaList->RemoveMediaListObserver( this ); |
237 iMediaList->RemoveMediaListObserver( this ); |
240 iMediaList->RemoveContext(iThumbnailContext); |
238 iMediaList->RemoveContext(iThumbnailContext); |
241 delete iThumbnailContext; |
|
242 iThumbnailContext = NULL; |
|
243 iMediaList->Close(); |
239 iMediaList->Close(); |
244 iMediaList = NULL; |
240 iMediaList = NULL; |
245 } |
241 } |
246 |
242 |
247 // Filter that filters out any GIF, corrupted images |
243 iMediaList = MGlxMediaList::InstanceL(aPath, KGlxIdNone, iPreviewFilter); |
248 CMPXFilter* filter = NULL; |
244 iMediaList->AddContextL(iThumbnailContext, KGlxFetchContextPriorityNormal); |
249 filter = TGlxFilterFactory::CreatePreviewFilterL(); |
|
250 CleanupStack::PushL( filter ); |
|
251 // create new medialist with the required filter which filters out all DRM, GIFS and corrupt |
|
252 // thumbnial |
|
253 iMediaList = MGlxMediaList::InstanceL( aPath ,KGlxIdNone, filter); |
|
254 iThumbnailContext = CGlxThumbnailContext::NewL( &iThumbnailIterator ); // set the thumbnail context |
|
255 iThumbnailIterator.SetRange( KPreviewThumbnailFetchCount ); // request for fifiteen thumbnails |
|
256 iThumbnailContext->SetDefaultSpec( iGridIconSize.iWidth,iGridIconSize.iHeight ); |
|
257 iMediaList->AddContextL(iThumbnailContext ,KGlxFetchContextPriorityNormal ); |
|
258 // adding the medialist to observ any changes or updates done |
245 // adding the medialist to observ any changes or updates done |
259 iMediaList->AddMediaListObserverL(this); |
246 iMediaList->AddMediaListObserverL(this); |
260 CleanupStack::PopAndDestroy( filter ); |
|
261 |
|
262 //Start the timer |
|
263 StartTimer(iPopulateListTNs); |
|
264 } |
247 } |
265 |
248 |
266 // ---------------------------------------------------------------------------- |
249 // ---------------------------------------------------------------------------- |
267 // StartTimer - Starts the timer based on the flag populateListTN's |
250 // StartTimer - Starts the timer based on the flag populateListTN's |
268 // where the flag will be true, when initially the first thumbnails in the list |
251 // where the flag will be true, when initially the first thumbnails in the list |
280 iTimer->Cancel(); |
263 iTimer->Cancel(); |
281 } |
264 } |
282 |
265 |
283 if (iPopulateListTNs) |
266 if (iPopulateListTNs) |
284 { |
267 { |
285 iTimer->Start(KInitialThumbnailsTimeDelay, KInitialThumbnailsTimeDelay, |
268 if (iBackwardNavigation) |
286 TCallBack(IsTimeL,this)); |
269 { |
|
270 iTimer->Start(KThumbnailIntervalTimeDelay, KThumbnailIntervalTimeDelay/KWaitCount, |
|
271 TCallBack(IsTimeL,this)); |
|
272 } |
|
273 else |
|
274 { |
|
275 iTimer->Start(KThumbnailStartTimeDelay, |
|
276 KInitialThumbnailsTimeDelay, TCallBack(IsTimeL,this)); |
|
277 } |
287 } |
278 } |
288 else |
279 } |
|
280 |
|
281 // ---------------------------------------------------------------------------- |
|
282 // StopTimer - Stop the timer |
|
283 // ---------------------------------------------------------------------------- |
|
284 // |
|
285 void CGlxPreviewThumbnailBinding::StopTimer() |
|
286 { |
|
287 TRACER("CGlxPreviewThumbnailBinding::StopTimer"); |
|
288 |
|
289 if (iTimer && iTimer->IsActive()) |
289 { |
290 { |
290 iTimer->Start(KThumbnailStartTimeDelay, KThumbnailIntervalTimeDelay, |
291 iTimer->Cancel(); |
291 TCallBack(IsTimeL,this)); |
|
292 } |
292 } |
293 } |
293 } |
294 |
294 |
295 // ---------------------------------------------------------------------------- |
|
296 // HasFirstThumbnail |
|
297 // ---------------------------------------------------------------------------- |
|
298 // |
|
299 TBool CGlxPreviewThumbnailBinding::HasFirstThumbnail( const RArray< TMPXAttribute >& aAttributes ) |
|
300 { |
|
301 TRACER("CGlxPreviewThumbnailBinding::HasFirstThumbnail"); |
|
302 TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail, |
|
303 GlxFullThumbnailAttributeId( ETrue, |
|
304 iGridIconSize.iWidth, |
|
305 iGridIconSize.iHeight) ); |
|
306 |
|
307 TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match ); |
|
308 return ( KErrNotFound != aAttributes.Find( thumbnailAttribute, match ) ); |
|
309 } |
|
310 // ---------------------------------------------------------------------------- |
295 // ---------------------------------------------------------------------------- |
311 // HandleItemAddedL |
296 // HandleItemAddedL |
312 // ---------------------------------------------------------------------------- |
297 // ---------------------------------------------------------------------------- |
313 // |
298 // |
314 void CGlxPreviewThumbnailBinding::HandleItemAddedL( TInt /*aStartIndex*/, TInt |
299 void CGlxPreviewThumbnailBinding::HandleItemAddedL( TInt /*aStartIndex*/, TInt |