application/src/PodcastFeedView.cpp
changeset 96 a8538f50e2ba
parent 52 15f885e4eb92
parent 94 8d36b7608232
child 102 04c6ccce8e7e
equal deleted inserted replaced
95:c06c2a75bb57 96:a8538f50e2ba
   103 	//mask = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40m );	
   103 	//mask = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40m );	
   104 	CleanupStack::PushL( mask );
   104 	CleanupStack::PushL( mask );
   105 	// Append the feed icon to icon array
   105 	// Append the feed icon to icon array
   106 	icons->AppendL( CGulIcon::NewL( bitmap, mask ) );
   106 	icons->AppendL( CGulIcon::NewL( bitmap, mask ) );
   107 	CleanupStack::Pop(2); // bitmap, mask
   107 	CleanupStack::Pop(2); // bitmap, mask
   108 	
       
   109 	iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons );
   108 	iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons );
   110 	CleanupStack::Pop(icons); // icons
   109 	CleanupStack::Pop(icons); // icons
   111 
   110 
   112 	iListContainer->Listbox()->SetListBoxObserver(this);
   111 	iListContainer->Listbox()->SetListBoxObserver(this);
   113 	
   112 	
   126 	iPodcastModel.FeedEngine().RemoveObserver(this);
   125 	iPodcastModel.FeedEngine().RemoveObserver(this);
   127 	delete iFeedsFormat;
   126 	delete iFeedsFormat;
   128 	delete iNeverUpdated;
   127 	delete iNeverUpdated;
   129 	delete iStylusPopupMenu;
   128 	delete iStylusPopupMenu;
   130 	delete iUpdater;
   129 	delete iUpdater;
       
   130 	iFeedIdForIconArray.Close();
   131     }
   131     }
   132 
   132 
   133 void CPodcastFeedView::UpdateItemL(TInt aIndex)
   133 void CPodcastFeedView::UpdateItemL(TInt aIndex)
   134 	{
   134 	{
   135 	_LIT(KPanicCategory, "CPodcastFeedView::UpdateItemL");
   135 	_LIT(KPanicCategory, "CPodcastFeedView::UpdateItemL");
   367 			{
   367 			{
   368 			GetFeedErrorText(unplayedShows, aFeedInfo.LastError());
   368 			GetFeedErrorText(unplayedShows, aFeedInfo.LastError());
   369 			}
   369 			}
   370 		}
   370 		}
   371 	CArrayPtr<CGulIcon>* icons = iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->IconArray();
   371 	CArrayPtr<CGulIcon>* icons = iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->IconArray();
   372 	
   372 	iconIndex = iFeedIdForIconArray.Find(aFeedInfo.Uid());
   373 	if (aFeedInfo.FeedIconIndex() != -1) {
   373 	if(iconIndex == KErrNotFound && aFeedInfo.FeedIcon() != NULL && 
   374 		iconIndex = aFeedInfo.FeedIconIndex();
   374 			aFeedInfo.FeedIcon()->SizeInPixels().iHeight > 0 &&
   375 	} else {
   375 			aFeedInfo.FeedIcon()->SizeInPixels().iWidth > 0)
   376 		if(aFeedInfo.FeedIcon() != NULL && 
   376 		{
   377 				aFeedInfo.FeedIcon()->SizeInPixels().iHeight > 0 &&
   377 		// Hopefully temporary haxx to prevent double delete. I would prefer if
   378 				aFeedInfo.FeedIcon()->SizeInPixels().iWidth > 0)
   378 		// this could be solved with a little better design.
   379 			{
   379 		CFbsBitmap* bmpCopy = new (ELeave) CFbsBitmap;
   380 			// Hopefully temporary haxx to prevent double delete. I would prefer if
   380 		CleanupStack::PushL(bmpCopy);
   381 			// this could be solved with a little better design.
   381 		bmpCopy->Duplicate(aFeedInfo.FeedIcon()->Handle());
   382 			CFbsBitmap* bmpCopy = new (ELeave) CFbsBitmap;
   382 		icons->AppendL( CGulIcon::NewL(bmpCopy, NULL));
   383 			CleanupStack::PushL(bmpCopy);
   383 		iFeedIdForIconArray.Append(aFeedInfo.Uid());
   384 			bmpCopy->Duplicate(aFeedInfo.FeedIcon()->Handle());
   384 		CleanupStack::Pop(bmpCopy);			
   385 			icons->AppendL( CGulIcon::NewL(bmpCopy, NULL));
   385 		iconIndex = icons->Count()-1;
   386 			CleanupStack::Pop(bmpCopy);
   386 		}	
   387 			iconIndex = icons->Count()-1;
   387 	else 
   388 			aFeedInfo.SetFeedIconIndex(iconIndex);
   388 		{
   389 			}
   389 		iconIndex++;
   390 		else {
   390 		}	
   391 			if(BaflUtils::FileExists(iPodcastModel.FsSession(), aFeedInfo.ImageFileName()))
   391 
   392 			{
       
   393 			// If this fails, no reason to worry
       
   394 			TRAP_IGNORE(iPodcastModel.ImageHandler().LoadFileAndScaleL(aFeedInfo.FeedIcon(), aFeedInfo.ImageFileName(), TSize(64,56), *this, aFeedInfo.Uid()));
       
   395 			}
       
   396 		}
       
   397 	}
       
   398 	
       
   399 	if (unplayedShows.Length() > 0) {
   392 	if (unplayedShows.Length() > 0) {
   400 		unplayedShows.Insert(0,_L(", "));
   393 		unplayedShows.Insert(0,_L(", "));
   401 	}
   394 	}
   402 	
   395 	
   403 	iListboxFormatbuffer.Format(KFeedFormat(), iconIndex, &(aFeedInfo.Title()), &updatedDate,  &unplayedShows);
   396 	iListboxFormatbuffer.Format(KFeedFormat(), iconIndex, &(aFeedInfo.Title()), &updatedDate,  &unplayedShows);
   404 	}
   397 	}
   405 
   398 
   406 void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle)
   399 void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle, CPodcastModel& /*aPodcastModel*/)
   407 	{
   400 	{
   408 	if (aError == KErrNone) {
   401 	if (aError == KErrNone) {
   409 	UpdateFeedInfoStatusL(aHandle, EFalse);
   402 		UpdateFeedInfoStatusL(aHandle, EFalse);
   410 	}
   403 		}
   411 	}
   404 	}
   412 
   405 
   413 void CPodcastFeedView::UpdateFeedInfoDataL(CFeedInfo* aFeedInfo, TInt aIndex, TBool aIsUpdating )
   406 void CPodcastFeedView::UpdateFeedInfoDataL(CFeedInfo* aFeedInfo, TInt aIndex, TBool aIsUpdating )
   414 	{			
   407 	{			
   415 	TListItemProperties itemProps;			
   408 	TListItemProperties itemProps;