Browse Source

Fix duplication of Pharmacies.

Version Bump
master
Carlos Mogas da Silva 10 years ago
parent
commit
5c60655906
  1. 2
      AndroidManifest.xml
  2. BIN
      res/drawable/dialog.9.png
  3. BIN
      res/drawable/droid.png
  4. BIN
      res/drawable/list_location.9.png
  5. 9
      src/org/r3pek/pharmacies/Pharmacy.java
  6. 40
      src/org/r3pek/pharmacies/ViewOnMap.java
  7. 5
      src/org/r3pek/pharmacies/XMLParserHandler.java

2
AndroidManifest.xml

@ -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

After

Width: 96  |  Height: 75  |  Size: 1.8 KiB

BIN
res/drawable/droid.png

Before

Width: 20  |  Height: 24  |  Size: 1.1 KiB

BIN
res/drawable/list_location.9.png

After

Width: 98  |  Height: 77  |  Size: 466 B

9
src/org/r3pek/pharmacies/Pharmacy.java

@ -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));
}

40
src/org/r3pek/pharmacies/ViewOnMap.java

@ -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);

5
src/org/r3pek/pharmacies/XMLParserHandler.java

@ -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;
}

Loading…
Cancel
Save