Subversion Repositories ES

Compare Revisions

Last modification

Ignore whitespace Rev 17 → Rev 18

/trunk/src/de/pointedears/converter/app/CurrenciesActivity.java
102,6 → 102,8
{
if (intent.getAction().equals(UpdateService.ACTION_UPDATE))
{
CurrenciesActivity.this.fillTableRates();
 
Bundle extras = intent.getExtras();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
Notifier.sendMessage(CurrenciesActivity.this,
/trunk/src/de/pointedears/converter/helpers/UpdateService.java
29,6 → 29,7
"de.pointedears.converter.extra_num_rates"; //$NON-NLS-1$
public static final String EXTRA_DATE = "de.pointedears.converter.extra_date"; //$NON-NLS-1$
 
/* NOTE: Don't remove; may be used later for automated updates */
// private sendTimerTask sendTime = null;
 
// /** inner class implements the broadcast timer */
100,7 → 101,7
if (this.updateThread == null)
{
this.ratesUpdater =
new RatesUpdater(UpdateService.getActivityContext(), this);
new RatesUpdater(UpdateService.activityContext, this);
this.updateThread =
new ConverterThread(this.ratesUpdater, this.handler);
this.ratesUpdater.setUpdateThread(this.updateThread);
139,14 → 140,6
}
 
/**
* @return the activityContext
*/
public static CurrenciesActivity getActivityContext()
{
return UpdateService.activityContext;
}
 
/**
* @param activityContext
* the activityContext to set
*/
/trunk/src/de/pointedears/converter/net/RatesUpdater.java
40,6 → 40,13
*/
public class RatesUpdater implements Runnable
{
/*
* XML markup attributes
*/
private static final String ATTR_RATE = "rate"; //$NON-NLS-1$
private static final String ATTR_CURRENCY = "currency"; //$NON-NLS-1$
private static final String ATTR_TIME = "time"; //$NON-NLS-1$
 
private static final String URL_ECB =
"http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"; //$NON-NLS-1$
 
49,8 → 56,11
private final UpdateService service;
 
/**
* @param activityContext
* The activityContext for this updater.
* FIXME: Required only for database access
* @param updateService
*
* The service that started this updater
*/
public RatesUpdater(CurrenciesActivity activityContext,
UpdateService updateService)
69,6 → 79,7
 
/**
* @param updateThread
* the thread that this updater is running in
*/
public void setUpdateThread(ConverterThread updateThread)
{
133,12 → 144,13
 
try
{
updated = df.parse(parentCube.getAttribute("time"));
updated =
df.parse(parentCube.getAttribute(RatesUpdater.ATTR_TIME));
}
catch (ParseException e)
{
Log.e(this.getClass().toString(),
"Could not parse the `time' attribute into a Date", e);
"Could not parse the `time' attribute into a Date", e); //$NON-NLS-1$
}
 
expr =
155,12 → 167,12
for (int i = 0; i < len; ++i)
{
Element item = (Element) childCubes.item(i);
String currency = item.getAttribute("currency");
String currency = item.getAttribute(RatesUpdater.ATTR_CURRENCY);
 
try
{
Double rate =
Double.parseDouble(item.getAttribute("rate")); //$NON-NLS-1$
Double.parseDouble(item.getAttribute(RatesUpdater.ATTR_RATE));
conversionRates
.put(currency, new ConversionData(rate, updated));
}
171,28 → 183,27
}
 
this.activityContext.getDatabase().writeConversionsToDatabase(null);
this.activityContext.fillTableRates();
}
catch (XPathExpressionException e)
{
Log.e(this.getClass().toString(), "Error in XPath expression", e);
Log.e(this.getClass().toString(), "Error in XPath expression", e); //$NON-NLS-1$
}
}
catch (SAXException e)
{
Log.e(this.getClass().toString(),
"Exception while parsing external XML resource", e);
"Exception while parsing external XML resource", e); //$NON-NLS-1$
}
catch (IOException e)
{
Log.e(this.getClass().toString(),
"I/O exception while parsing external XML resource", e);
"I/O exception while parsing external XML resource", e); //$NON-NLS-1$
}
}
catch (ParserConfigurationException e)
{
Log.e(this.getClass().toString(),
"Document builder cannot be created", e);
"Document builder cannot be created", e); //$NON-NLS-1$
}
 
if (len > 0)