40,13 → 40,6 |
*/ |
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$ |
|
56,11 → 49,8 |
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) |
79,7 → 69,6 |
|
/** |
* @param updateThread |
* the thread that this updater is running in |
*/ |
public void setUpdateThread(ConverterThread updateThread) |
{ |
144,13 → 133,12 |
|
try |
{ |
updated = |
df.parse(parentCube.getAttribute(RatesUpdater.ATTR_TIME)); |
updated = df.parse(parentCube.getAttribute("time")); |
} |
catch (ParseException e) |
{ |
Log.e(this.getClass().toString(), |
"Could not parse the `time' attribute into a Date", e); //$NON-NLS-1$ |
"Could not parse the `time' attribute into a Date", e); |
} |
|
expr = |
167,12 → 155,12 |
for (int i = 0; i < len; ++i) |
{ |
Element item = (Element) childCubes.item(i); |
String currency = item.getAttribute(RatesUpdater.ATTR_CURRENCY); |
String currency = item.getAttribute("currency"); |
|
try |
{ |
Double rate = |
Double.parseDouble(item.getAttribute(RatesUpdater.ATTR_RATE)); |
Double.parseDouble(item.getAttribute("rate")); //$NON-NLS-1$ |
conversionRates |
.put(currency, new ConversionData(rate, updated)); |
} |
183,27 → 171,28 |
} |
|
this.activityContext.getDatabase().writeConversionsToDatabase(null); |
this.activityContext.fillTableRates(); |
} |
catch (XPathExpressionException e) |
{ |
Log.e(this.getClass().toString(), "Error in XPath expression", e); //$NON-NLS-1$ |
Log.e(this.getClass().toString(), "Error in XPath expression", e); |
} |
} |
catch (SAXException e) |
{ |
Log.e(this.getClass().toString(), |
"Exception while parsing external XML resource", e); //$NON-NLS-1$ |
"Exception while parsing external XML resource", e); |
} |
catch (IOException e) |
{ |
Log.e(this.getClass().toString(), |
"I/O exception while parsing external XML resource", e); //$NON-NLS-1$ |
"I/O exception while parsing external XML resource", e); |
} |
} |
catch (ParserConfigurationException e) |
{ |
Log.e(this.getClass().toString(), |
"Document builder cannot be created", e); //$NON-NLS-1$ |
"Document builder cannot be created", e); |
} |
|
if (len > 0) |