1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| XMLParser parser = new XMLParser();
new Thread(new Runnable() {
public void run() {
try{
//création de la source
InputSource source = new InputSource(new ByteArrayInputStream(CacheManager.loadCacheByte(DIR_DATA, XML)));
//création du XPath
XPathFactory fabrique = XPathFactory.newInstance();
XPath xpath = fabrique.newXPath();
//évaluation de l'expression XPath
XPathExpression exp = xpath.compile("//"+KEY_ITEM);
liste = (NodeList)exp.evaluate(source,XPathConstants.NODESET);
go = true;
}catch(XPathExpressionException xpee){
xpee.printStackTrace();
}
}
}).start();
LIGNE 201 while(!go){
}
// Boucle dans tout les noeuds
for (int b = 0; b < liste.getLength(); b++) {
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) liste.item(b);
String x = parser.getValue(e, KEY_LAT);
lat = Double.parseDouble(x);
String y = parser.getValue(e, KEY_LON);
lon = Double.parseDouble(y);
Location location2 = new Location("");
location2.setLatitude(lat);
location2.setLongitude(lon);
//on determine la distance entre le restaurant et l'utilisateur que l'on convertit en Km
double dist = Loading.location.distanceTo(location2);
double km = dist/1000;
DecimalFormat df = new DecimalFormat("00.00");
//on ajoute les information récupérer (adresse, distance,etc...) dans une HashList
map.put(KEY_ID, parser.getValue(e, KEY_ID));
map.put(KEY_ADR, parser.getValue(e, KEY_ADR));
map.put(KEY_ZIP, parser.getValue(e, KEY_ZIP));
map.put(KEY_VILLE, parser.getValue(e, KEY_VILLE));
map.put(KEY_TEL, parser.getValue(e, KEY_TEL));
map.put(KEY_NOM, parser.getValue(e, KEY_NOM));
map.put(KEY_LON, parser.getValue(e, KEY_LON));
map.put(KEY_LAT, parser.getValue(e, KEY_LAT));
map.put(KEY_DATE, parser.getValue(e, KEY_DATE));
map.put(KEY_DIS, String.valueOf(df.format(km))+" km");
String day = String.valueOf(parser.getValue(e, KEY_JOUR));
int dday = Integer.parseInt(day); |
Partager