1
0
Fork 0

Fix duplication of Pharmacies.

Version Bump
This commit is contained in:
Carlos Mogas da Silva 2010-11-21 01:55:48 +00:00
parent 711d82559f
commit 5c60655906
7 changed files with 43 additions and 13 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.r3pek.pharmacies" android:installLocation="auto" android:versionCode="12" android:versionName="2.1">
package="org.r3pek.pharmacies" android:installLocation="auto" android:versionCode="13" android:versionName="2.1.1">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="false" android:backupAgent=".backup.MyBackupAgent">
<activity android:name="MyPreferences"/>
<activity android:name="PharmacyList"/>

BIN
res/drawable/dialog.9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

View file

@ -16,6 +16,7 @@ public class Pharmacy implements Serializable {
private String distance;
private Boolean atService;
private String parish;
private String lastUpdate;
public Pharmacy() {
}
@ -84,6 +85,14 @@ public class Pharmacy implements Serializable {
this.parish = parish;
}
public String getLastupdate() {
return lastUpdate == null ? "" : lastUpdate;
}
public void setLastUpdate(String lastUpdate) {
this.lastUpdate = lastUpdate;
}
public GeoPoint getGeoPoint() {
return new GeoPoint((int)(Double.parseDouble(latitude) * 1E6), (int)(Double.parseDouble(longitude) * 1E6));
}

View file

@ -1,10 +1,10 @@
package org.r3pek.pharmacies;
import java.net.URL;
import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import org.r3pek.pharmacies.utils.GlobalVars;
import org.r3pek.pharmacies.utils.OnPositionChangeListener;
@ -30,11 +30,15 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
public class ViewOnMap extends MapActivity implements OnPositionChangeListener {
private static final int MENU_REFRESH = 0;
@ -276,8 +280,20 @@ public class ViewOnMap extends MapActivity implements OnPositionChangeListener {
}
/* Our XMLParserHandler now provides the parsed data to us. */
for (Pharmacy p : handler.getPharmacies())
GlobalVars.getPharmacies().add(p);
for (Pharmacy p : handler.getPharmacies()) {
/* Only add the Pharmacy if it was recently updated */
DateFormat format;
if (p.getLastupdate().endsWith("Z"))
format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
else
format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
Date lastupdate = format.parse(p.getLastupdate());
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -2);
if (!lastupdate.before(cal.getTime()))
GlobalVars.getPharmacies().add(p);
}
pharmaciesOverlay.refresh();
endThreadHandler.sendEmptyMessage(0);

View file

@ -16,6 +16,7 @@ public class XMLParserHandler extends DefaultHandler {
private boolean inDistance = false;
private boolean inIsAtService = false;
private boolean inParish = false;
private boolean inLastUpdate = false;
private boolean error = false;
private boolean inErrorMessage;
private String errorMessage;
@ -57,6 +58,8 @@ public class XMLParserHandler extends DefaultHandler {
inIsAtService = newValue;
else if (tag.equals("Parish"))
inParish = newValue;
else if (tag.equals("LastUpdate"))
inLastUpdate = newValue;
else if (tag.equals("Fault"))
error = true;
else if (tag.equals("FaultString"))
@ -94,6 +97,8 @@ public class XMLParserHandler extends DefaultHandler {
currentPharmacy.setAtService(Boolean.parseBoolean(chars));
else if (inParish)
currentPharmacy.setParish(currentPharmacy.getParish() + chars);
else if (inLastUpdate)
currentPharmacy.setLastUpdate(currentPharmacy.getLastupdate() + chars);
else if (inErrorMessage)
errorMessage += chars;
}