2
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Anders Fridlund, EmbedDev AB
|
|
3 |
*
|
|
4 |
* All rights reserved.
|
|
5 |
* This component and the accompanying materials are made available
|
|
6 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
7 |
* which accompanies this distribution, and is available
|
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
9 |
*
|
|
10 |
* Initial Contributors:
|
|
11 |
* EmbedDev AB - initial contribution.
|
|
12 |
*
|
|
13 |
* Contributors:
|
|
14 |
*
|
|
15 |
* Description:
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include "PodcastFeedViewUpdater.h"
|
|
20 |
#include "PodcastFeedView.h"
|
|
21 |
|
|
22 |
CPodcastFeedViewUpdater* CPodcastFeedViewUpdater::NewL(CPodcastFeedView& aPodcastFeedView)
|
|
23 |
{
|
|
24 |
CPodcastFeedViewUpdater* self = new (ELeave) CPodcastFeedViewUpdater(aPodcastFeedView);
|
|
25 |
CleanupStack::PushL(self);
|
|
26 |
self->ConstructL();
|
|
27 |
CleanupStack::Pop(self);
|
|
28 |
return self;
|
|
29 |
}
|
|
30 |
|
|
31 |
void CPodcastFeedViewUpdater::StartUpdate(TInt aNbrItems)
|
|
32 |
{
|
|
33 |
// If there is an update in progress, stop it.
|
|
34 |
StopUpdate();
|
|
35 |
// Reset values to start an update from the beginning
|
|
36 |
iNbrItems = aNbrItems;
|
|
37 |
iNextItem = 0;
|
|
38 |
// Queue this active object to be run once
|
|
39 |
Call();
|
|
40 |
}
|
|
41 |
|
|
42 |
void CPodcastFeedViewUpdater::StopUpdate()
|
|
43 |
{
|
|
44 |
// Cancel any outstanding request
|
|
45 |
Cancel();
|
|
46 |
// Reset values to zero. Not really necessary, but made for robustness
|
|
47 |
iNbrItems = 0;
|
|
48 |
iNextItem = 0;
|
|
49 |
}
|
|
50 |
|
|
51 |
CPodcastFeedViewUpdater::~CPodcastFeedViewUpdater()
|
|
52 |
{
|
|
53 |
StopUpdate();
|
|
54 |
Deque();
|
|
55 |
}
|
|
56 |
|
|
57 |
CPodcastFeedViewUpdater::CPodcastFeedViewUpdater(CPodcastFeedView& aPodcastFeedView)
|
|
58 |
: CAsyncOneShot(EPriorityNormal), iPodcastFeedView(aPodcastFeedView)
|
|
59 |
{
|
|
60 |
}
|
|
61 |
|
|
62 |
void CPodcastFeedViewUpdater::ConstructL()
|
|
63 |
{
|
|
64 |
}
|
|
65 |
|
|
66 |
void CPodcastFeedViewUpdater::RunL()
|
|
67 |
{
|
|
68 |
iPodcastFeedView.UpdateItemL(iNextItem++);
|
|
69 |
if (iNextItem < iNbrItems)
|
|
70 |
{
|
|
71 |
Call();
|
|
72 |
}
|
|
73 |
else
|
|
74 |
{
|
|
75 |
StopUpdate();
|
|
76 |
}
|
|
77 |
}
|
|
78 |
|
|
79 |
TInt CPodcastFeedViewUpdater::RunError(TInt aError)
|
|
80 |
{
|
|
81 |
return aError;
|
|
82 |
}
|
|
83 |
|