47 #include <caf/caferr.h> |
47 #include <caf/caferr.h> |
48 #include <AknUtils.h> |
48 #include <AknUtils.h> |
49 |
49 |
50 #include "glxgridviewmlobserver.h" |
50 #include "glxgridviewmlobserver.h" |
51 |
51 |
52 const TInt KRecreateGridSize(100); //minimum no of items added to trigger recreate grid |
52 const TInt KRecreateGridSize(5); //minimum no of items added to trigger recreate grid |
53 // ======== MEMBER FUNCTIONS ======== |
53 // ======== MEMBER FUNCTIONS ======== |
54 |
54 |
55 // --------------------------------------------------------------------------- |
55 // --------------------------------------------------------------------------- |
56 // Two-phased constructor. |
56 // Two-phased constructor. |
57 // --------------------------------------------------------------------------- |
57 // --------------------------------------------------------------------------- |
94 //Get the HgContextUtility instance |
94 //Get the HgContextUtility instance |
95 // iContextUtility = uiUtility->ContextUtility(); |
95 // iContextUtility = uiUtility->ContextUtility(); |
96 iItemsPerPage = uiUtility->VisibleItemsInPageGranularityL(); |
96 iItemsPerPage = uiUtility->VisibleItemsInPageGranularityL(); |
97 uiUtility->Close() ; |
97 uiUtility->Close() ; |
98 |
98 |
99 iDownloadsPlugin = EFalse; |
|
100 |
|
101 CMPXCollectionPath* path = iMediaList.PathLC( NGlxListDefs::EPathParent ); |
|
102 if (path->Id() == KGlxCollectionPluginDownloadsImplementationUid) |
|
103 { |
|
104 iDownloadsPlugin = ETrue; |
|
105 } |
|
106 CleanupStack::PopAndDestroy(path); |
|
107 |
|
108 iQualityTnAttrib = TMPXAttribute (KGlxMediaIdThumbnail, |
99 iQualityTnAttrib = TMPXAttribute (KGlxMediaIdThumbnail, |
109 GlxFullThumbnailAttributeId( ETrue, iGridIconSize.iWidth, |
100 GlxFullThumbnailAttributeId( ETrue, iGridIconSize.iWidth, |
110 iGridIconSize.iHeight ) ); |
101 iGridIconSize.iHeight ) ); |
111 |
102 |
112 iSpeedTnAttrib = TMPXAttribute (KGlxMediaIdThumbnail, |
103 iSpeedTnAttrib = TMPXAttribute (KGlxMediaIdThumbnail, |
138 { |
129 { |
139 TRACER("CGlxGridViewMLObserver::HandleItemAddedL()"); |
130 TRACER("CGlxGridViewMLObserver::HandleItemAddedL()"); |
140 GLX_DEBUG3("CGlxGridViewMLObserver::HandleItemAddedL() aStartIndex(%d)," |
131 GLX_DEBUG3("CGlxGridViewMLObserver::HandleItemAddedL() aStartIndex(%d)," |
141 " aEndIndex(%d)", aStartIndex, aEndIndex); |
132 " aEndIndex(%d)", aStartIndex, aEndIndex); |
142 |
133 |
143 if (iHgGrid) |
134 if (!iHgGrid) |
144 { |
135 { |
145 if ((aEndIndex - aStartIndex) >= KRecreateGridSize) |
136 return; |
146 { |
137 } |
147 iHgGrid->ResizeL(aList->Count()); |
138 |
148 } |
139 if ((aEndIndex - aStartIndex) > KRecreateGridSize) |
149 else |
140 { |
150 { |
141 iHgGrid->ResizeL(aList->Count()); |
151 for (TInt i = aStartIndex; i<= aEndIndex; i++) |
142 } |
152 { |
143 else |
153 iHgGrid->InsertItem(CHgItem::NewL(), i); |
144 { |
154 } |
145 for (TInt i = aStartIndex; i <= aEndIndex; i++) |
155 } |
146 { |
156 } |
147 iHgGrid->InsertItem(CHgItem::NewL(), i); |
|
148 } |
|
149 } |
|
150 |
157 // Setting the initial focus for all grid views except downloads, |
151 // Setting the initial focus for all grid views except downloads, |
158 // for downloads it is already set. |
152 // for downloads it is already set. |
159 TInt focusIndex = aList->FocusIndex(); |
153 TInt focusIndex = aList->FocusIndex(); |
160 iHgGrid->SetSelectedIndex(focusIndex); |
154 iHgGrid->SetSelectedIndex(focusIndex); |
161 |
|
162 // if the Medialist has any item, set the First index context to Hg Context Utility |
|
163 // TGlxMedia item = aList->Item( focusIndex ); |
|
164 // iContextUtility->PublishPhotoContextL(item.Uri()); |
|
165 } |
155 } |
166 |
156 |
167 // ---------------------------------------------------------------------------- |
157 // ---------------------------------------------------------------------------- |
168 // HandleItemRemoved |
158 // HandleItemRemoved |
169 // ---------------------------------------------------------------------------- |
159 // ---------------------------------------------------------------------------- |
253 bitmap->Duplicate( speedTn->iBitmap->Handle()); |
243 bitmap->Duplicate( speedTn->iBitmap->Handle()); |
254 AknIconUtils::SetSize(bitmap, setSize); |
244 AknIconUtils::SetSize(bitmap, setSize); |
255 iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap)); |
245 iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap)); |
256 GLX_LOG_INFO1("### CGlxGridViewMLObserver::HandleAttributesAvailableL" |
246 GLX_LOG_INFO1("### CGlxGridViewMLObserver::HandleAttributesAvailableL" |
257 " speedTn-Index is %d",aItemIndex); |
247 " speedTn-Index is %d",aItemIndex); |
258 } |
|
259 else if (item.GetIconInfo(icon)) |
|
260 { |
|
261 CFbsBitmap* bitmap = AknIconUtils::CreateIconL(icon.bmpfile, icon.bitmapId); |
|
262 AknIconUtils::SetSize(bitmap, setSize ); |
|
263 iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap)); |
|
264 GLX_LOG_INFO1("### CGlxGridViewMLObserver::HandleAttributesAvailableL " |
|
265 "GetIconInfo-Index is %d",aItemIndex); |
|
266 } |
248 } |
267 else if ( KErrNone != tnError && KErrNotSupported != tnError && |
249 else if ( KErrNone != tnError && KErrNotSupported != tnError && |
268 KErrArgument != tnError ) |
250 KErrArgument != tnError ) |
269 { |
251 { |
270 CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile, |
252 CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile, |
407 StringLoader::LoadLC(R_GRID_EMPTY_VIEW_TEXT); |
389 StringLoader::LoadLC(R_GRID_EMPTY_VIEW_TEXT); |
408 iHgGrid->SetEmptyTextL(*emptyText); |
390 iHgGrid->SetEmptyTextL(*emptyText); |
409 CleanupStack::PopAndDestroy(emptyText); |
391 CleanupStack::PopAndDestroy(emptyText); |
410 GLX_DEBUG2("GridMLObserver::HandlePopulatedL() iMediaList.Count()=%d", |
392 GLX_DEBUG2("GridMLObserver::HandlePopulatedL() iMediaList.Count()=%d", |
411 iMediaList.Count()); |
393 iMediaList.Count()); |
412 |
|
413 |
394 |
414 if (iMediaList.Count() <= 0) |
395 if (iMediaList.Count() <= 0) |
415 { |
396 { |
416 GLX_DEBUG1("GridMLObserver::HandlePopulatedL() - SetEmptyTextL()"); |
397 GLX_DEBUG1("GridMLObserver::HandlePopulatedL() - SetEmptyTextL()"); |
417 iHgGrid->DrawNow(); |
398 iHgGrid->DrawNow(); |
472 if (aItemIndex == firstIndex && HasRelevantThumbnail(firstIndex)) |
453 if (aItemIndex == firstIndex && HasRelevantThumbnail(firstIndex)) |
473 { |
454 { |
474 GLX_DEBUG2("## GridMLObserver::HandleAttributesAvailableL()" |
455 GLX_DEBUG2("## GridMLObserver::HandleAttributesAvailableL()" |
475 " RefreshScreen - firstIndex(%d)", firstIndex); |
456 " RefreshScreen - firstIndex(%d)", firstIndex); |
476 iHgGrid->RefreshScreen(firstIndex); |
457 iHgGrid->RefreshScreen(firstIndex); |
|
458 } |
|
459 else if (aItemIndex > firstIndex && aItemIndex <= lastOnScreen) |
|
460 { |
|
461 if ( HasRelevantThumbnail(lastOnScreen) ) |
|
462 { |
|
463 GLX_DEBUG2("GridMLObserver::HandleAttributesAvailableL()" |
|
464 " RefreshScreen - aItemIndex(%d)", aItemIndex); |
|
465 iHgGrid->RefreshScreen(aItemIndex); |
|
466 } |
477 } |
467 } |
478 } |
468 } |
479 else if (aItemIndex > firstIndex && aItemIndex <= lastOnScreen) |
469 else if (aItemIndex > firstIndex && aItemIndex <= lastOnScreen) |
480 { |
470 { |
481 TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match ); |
471 TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match ); |
580 TTime time(0); |
570 TTime time(0); |
581 if (item.GetDate(time)) |
571 if (item.GetDate(time)) |
582 { |
572 { |
583 iHgGrid->ItemL(aItemIndex).SetTime(time); |
573 iHgGrid->ItemL(aItemIndex).SetTime(time); |
584 } |
574 } |
585 |
|
586 // Sets up TLS, must be done before FeatureManager is used. |
|
587 FeatureManager::InitializeLibL(); |
|
588 |
|
589 if (FeatureManager::FeatureSupported(KFeatureIdSeamlessLinks)) |
|
590 { |
|
591 if (iDownloadsPlugin && mediaCount > iHgGrid->ItemsOnScreen() |
|
592 && aItemIndex == 2) |
|
593 { |
|
594 if (iMediaList.Item(0).IsStatic()) |
|
595 { |
|
596 iHgGrid->ItemL(0).SetTime(time); // Image Downloads link Icon |
|
597 } |
|
598 if (iMediaList.Item(1).IsStatic()) |
|
599 { |
|
600 iHgGrid->ItemL(1).SetTime(time); // Video Downloads link Icon |
|
601 } |
|
602 } |
|
603 } |
|
604 |
|
605 // Frees the TLS. Must be done after FeatureManager is used. |
|
606 FeatureManager::UnInitializeLib(); |
|
607 } |
575 } |
608 |
576 |
609 if (aAttributes.Find(KMPXMediaGeneralCategory, match) != KErrNotFound) |
577 if (aAttributes.Find(KMPXMediaGeneralCategory, match) != KErrNotFound) |
610 { |
578 { |
611 if (item.Category() == EMPXVideo) |
579 if (item.Category() == EMPXVideo) |