59 CleanupStack::PushL( self ); |
61 CleanupStack::PushL( self ); |
60 self->ConstructL(); |
62 self->ConstructL(); |
61 return self; |
63 return self; |
62 } |
64 } |
63 |
65 |
64 CPodcastFeedView::CPodcastFeedView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel) |
66 void CPodcastFeedView::SizeChanged() |
65 { |
67 { |
66 iFirstActivateAfterLaunch = ETrue; |
68 DP("CPodcastFeedView::SizeChanged BEGIN"); |
67 } |
69 iListContainer->Listbox()->SetListBoxObserver(this); |
68 #define KAsterisk iEikonEnv->EikAppUi()->Application()->BitmapStoreName() |
70 iFeedIdForIconArray.Reset(); |
69 void CPodcastFeedView::ConstructL() |
71 iItemArray->Reset(); |
70 { |
72 |
71 DP("CPodcastFeedView::ConstructL BEGIN"); |
73 DP("before icons"); |
72 //_LIT(KAsterisk, "*"); |
|
73 BaseConstructL(R_PODCAST_FEEDVIEW); |
|
74 iNeverUpdated = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_NEVER_UPDATED); |
|
75 iFeedsFormat = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_STATUS_FORMAT); |
|
76 CPodcastListView::ConstructL(); |
|
77 iPodcastModel.FeedEngine().AddObserver(this); |
|
78 CArrayPtr< CGulIcon >* icons = new(ELeave) CArrayPtrFlat< CGulIcon >(1); |
|
79 CleanupStack::PushL( icons ); |
|
80 |
|
81 CFbsBitmap* bitmap = NULL; |
74 CFbsBitmap* bitmap = NULL; |
82 CFbsBitmap* mask = NULL; |
75 CFbsBitmap* mask = NULL; |
|
76 _LIT(KAsterisk, "*"); |
83 // Load the bitmap for empty icon |
77 // Load the bitmap for empty icon |
84 TFileName fname = KAsterisk; |
78 TFileName fname; |
|
79 fname.Copy(KAsterisk); |
85 TParsePtr parser(fname); |
80 TParsePtr parser(fname); |
86 |
81 iIconArray= new(ELeave) CArrayPtrFlat< CGulIcon >(1); |
87 SetEmptyTextL(R_PODCAST_NO_FEEDS); |
82 CleanupStack::PushL( iIconArray ); |
88 |
83 |
89 // Load svg.-image and mask with a single call |
84 // Load svg.-image and mask with a single call |
90 AknIconUtils::CreateIconL(bitmap, |
85 AknIconUtils::CreateIconL(bitmap, |
91 mask, |
86 mask, |
92 iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
87 iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
93 EMbmPodcastFeed, |
88 EMbmPodcastFeed, |
98 CleanupStack::PushL( bitmap ); |
93 CleanupStack::PushL( bitmap ); |
99 // Load the mask for feed icon |
94 // Load the mask for feed icon |
100 //mask = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40m ); |
95 //mask = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40m ); |
101 CleanupStack::PushL( mask ); |
96 CleanupStack::PushL( mask ); |
102 // Append the feed icon to icon array |
97 // Append the feed icon to icon array |
103 icons->AppendL( CGulIcon::NewL( bitmap, mask ) ); |
98 iIconArray->AppendL( CGulIcon::NewL( bitmap, mask ) ); |
104 CleanupStack::Pop(2); // bitmap, mask |
99 CleanupStack::Pop(2); // bitmap, mask |
105 iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons ); |
100 iListContainer->SetListboxIcons(iIconArray); |
106 CleanupStack::Pop(icons); // icons |
101 CleanupStack::Pop(iIconArray); // icons |
107 |
102 |
108 iListContainer->Listbox()->SetListBoxObserver(this); |
103 UpdateListboxItemsL(); |
|
104 iListContainer->SetTextArray(iItemArray); |
|
105 iListContainer->SetListboxIcons(iIconArray); |
|
106 iListContainer->Listbox()->DrawNow(); |
|
107 DP("CPodcastFeedView::SizeChanged END"); |
|
108 } |
|
109 |
|
110 CPodcastFeedView::CPodcastFeedView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel) |
|
111 { |
|
112 iFirstActivateAfterLaunch = ETrue; |
|
113 } |
|
114 #define KAsterisk iEikonEnv->EikAppUi()->Application()->BitmapStoreName() |
|
115 void CPodcastFeedView::ConstructL() |
|
116 { |
|
117 DP("CPodcastFeedView::ConstructL BEGIN"); |
|
118 //_LIT(KAsterisk, "*"); |
|
119 BaseConstructL(R_PODCAST_FEEDVIEW); |
|
120 iNeverUpdated = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_NEVER_UPDATED); |
|
121 iFeedsFormat = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_STATUS_FORMAT); |
|
122 CPodcastListView::ConstructL(); |
|
123 iPodcastModel.FeedEngine().AddObserver(this); |
|
124 SetEmptyTextL(R_PODCAST_NO_FEEDS); |
|
125 SizeChanged(); |
|
126 // CFbsBitmap* bitmap = NULL; |
|
127 // CFbsBitmap* mask = NULL; |
|
128 // // Load the bitmap for empty icon |
|
129 // TFileName fname = KAsterisk; |
|
130 // TParsePtr parser(fname); |
|
131 |
|
132 // |
|
133 // // Load svg.-image and mask with a single call |
|
134 // AknIconUtils::CreateIconL(bitmap, |
|
135 // mask, |
|
136 // iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
|
137 // EMbmPodcastFeed, |
|
138 // EMbmPodcastFeed_mask); |
|
139 // |
|
140 // /*bitmap = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40); |
|
141 // * */ |
|
142 // CleanupStack::PushL( bitmap ); |
|
143 // // Load the mask for feed icon |
|
144 // //mask = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40m ); |
|
145 // CleanupStack::PushL( mask ); |
|
146 // // Append the feed icon to icon array |
|
147 // iIconArray->AppendL( CGulIcon::NewL( bitmap, mask ) ); |
|
148 // CleanupStack::Pop(2); // bitmap, mask |
|
149 // iListContainer->SetListboxIcons(iIconArray); |
|
150 // CleanupStack::Pop(iIconArray); // icons |
|
151 // |
|
152 // iListContainer->Listbox()->SetListBoxObserver(this); |
109 |
153 |
110 iUpdater = CPodcastFeedViewUpdater::NewL(*this); |
154 iUpdater = CPodcastFeedViewUpdater::NewL(*this); |
111 DP("CPodcastFeedView::ConstructL END"); |
155 DP("CPodcastFeedView::ConstructL END"); |
112 } |
156 } |
113 |
157 |
369 { |
414 { |
370 GetFeedErrorText(unplayedShows, aFeedInfo.LastError()); |
415 GetFeedErrorText(unplayedShows, aFeedInfo.LastError()); |
371 updatedDate.Zero(); |
416 updatedDate.Zero(); |
372 } |
417 } |
373 } |
418 } |
374 CArrayPtr<CGulIcon>* icons = iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->IconArray(); |
419 |
375 iconIndex = iFeedIdForIconArray.Find(aFeedInfo.Uid()); |
420 iconIndex = iFeedIdForIconArray.Find(aFeedInfo.Uid()); |
376 if(iconIndex == KErrNotFound && aFeedInfo.FeedIcon() != NULL && aFeedInfo.ImageFileName().Length() > 0 && |
421 if(iconIndex == KErrNotFound && aFeedInfo.FeedIcon() != NULL && aFeedInfo.ImageFileName().Length() > 0 && |
377 aFeedInfo.FeedIcon()->SizeInPixels().iHeight > 0 && |
422 aFeedInfo.FeedIcon()->SizeInPixels().iHeight > 0 && |
378 aFeedInfo.FeedIcon()->SizeInPixels().iWidth > 0) |
423 aFeedInfo.FeedIcon()->SizeInPixels().iWidth > 0) |
379 { |
424 { |
380 // Hopefully temporary haxx to prevent double delete. I would prefer if |
425 // Hopefully temporary haxx to prevent double delete. I would prefer if |
381 // this could be solved with a little better design. |
426 // this could be solved with a little better design. |
382 CFbsBitmap* bmpCopy = new (ELeave) CFbsBitmap; |
427 CFbsBitmap* bmpCopy = new (ELeave) CFbsBitmap; |
383 CleanupStack::PushL(bmpCopy); |
428 CleanupStack::PushL(bmpCopy); |
384 bmpCopy->Duplicate(aFeedInfo.FeedIcon()->Handle()); |
429 bmpCopy->Duplicate(aFeedInfo.FeedIcon()->Handle()); |
385 icons->AppendL( CGulIcon::NewL(AknIconUtils::CreateIconL(bmpCopy), NULL)); |
430 iIconArray->AppendL( CGulIcon::NewL(AknIconUtils::CreateIconL(bmpCopy), NULL)); |
386 |
431 |
387 iFeedIdForIconArray.Append(aFeedInfo.Uid()); |
432 iFeedIdForIconArray.Append(aFeedInfo.Uid()); |
388 CleanupStack::Pop(bmpCopy); |
433 CleanupStack::Pop(bmpCopy); |
389 iconIndex = icons->Count()-1; |
434 iconIndex = iIconArray->Count()-1; |
390 } |
435 } |
391 else |
436 else |
392 { |
437 { |
393 iconIndex++; |
438 iconIndex++; |
394 } |
439 } |
395 |
440 |
396 if (unplayedShows.Length() > 0 && updatedDate.Length() > 0) { |
441 if (unplayedShows.Length() > 0 && updatedDate.Length() > 0) { |
397 unplayedShows.Insert(0,_L(", ")); |
442 unplayedShows.Insert(0,_L(", ")); |
398 } |
443 } |
399 |
444 |
400 iListboxFormatbuffer.Format(KFeedFormat(), iconIndex, &(aFeedInfo.Title()), &updatedDate, &unplayedShows); |
445 if (iListContainer->IsLandscape()) |
|
446 { |
|
447 iListboxFormatbuffer.Format(KFeedFormatLandscape(), iconIndex, &(aFeedInfo.Title())); |
|
448 } |
|
449 else |
|
450 { |
|
451 iListboxFormatbuffer.Format(KFeedFormatPortrait(), iconIndex, &(aFeedInfo.Title()), &updatedDate, &unplayedShows); |
|
452 } |
401 } |
453 } |
402 |
454 |
403 void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle, CPodcastModel& /*aPodcastModel*/) |
455 void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle, CPodcastModel& /*aPodcastModel*/) |
404 { |
456 { |
405 if (aError == KErrNone) { |
457 if (aError == KErrNone) { |