Fix some crash
This commit is contained in:
parent
8359aa27fb
commit
ba66d074ba
|
@ -151,6 +151,8 @@ public class Database extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSitesToDb(List<BloodSite> sites) {
|
public void addSitesToDb(List<BloodSite> sites) {
|
||||||
|
if(sites == null)
|
||||||
|
return;
|
||||||
//remove existing site in the list
|
//remove existing site in the list
|
||||||
List<BloodSite> oldList = getBloodSites(-1);
|
List<BloodSite> oldList = getBloodSites(-1);
|
||||||
List<BloodSite> removeList = new ArrayList<>();
|
List<BloodSite> removeList = new ArrayList<>();
|
||||||
|
|
|
@ -169,7 +169,7 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
|
||||||
userCenter.remove();
|
userCenter.remove();
|
||||||
|
|
||||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(location.getLatitude(),location.getLongitude()))
|
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(location.getLatitude(),location.getLongitude()))
|
||||||
.icon(BitmapDescriptorFactory.getInstance().fromResource(R.drawable.userlocation));
|
.icon(BitmapDescriptorFactory.getInstance().fromResource(R.drawable.userlocation)).anchor(0.5f,0.5f);
|
||||||
userCenter = map.addMarker(markerOptions);
|
userCenter = map.addMarker(markerOptions);
|
||||||
}
|
}
|
||||||
Database.getInstance(getActivity()).updateUserLoc(location.getLatitude(), location.getLongitude());
|
Database.getInstance(getActivity()).updateUserLoc(location.getLatitude(), location.getLongitude());
|
||||||
|
@ -177,7 +177,12 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
|
||||||
List<Address> addrList = coder.getFromLocation(location.getLatitude(), location.getLongitude(), 5);
|
List<Address> addrList = coder.getFromLocation(location.getLatitude(), location.getLongitude(), 5);
|
||||||
for (Address addr : addrList) {
|
for (Address addr : addrList) {
|
||||||
if (addr != null && addr.getPostalCode() != null) {
|
if (addr != null && addr.getPostalCode() != null) {
|
||||||
Integer code = Integer.valueOf(addr.getPostalCode());
|
Integer code;
|
||||||
|
try {
|
||||||
|
code = Integer.valueOf(addr.getPostalCode());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int original = (code - (code % 1000)) / 1000;
|
int original = (code - (code % 1000)) / 1000;
|
||||||
if (original == 97) {
|
if (original == 97) {
|
||||||
postCode = (code - (code % 100)) / 100;
|
postCode = (code - (code % 100)) / 100;
|
||||||
|
@ -512,6 +517,7 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
|
||||||
else
|
else
|
||||||
res = R.drawable.mixed;
|
res = R.drawable.mixed;
|
||||||
options.icon(BitmapDescriptorFactory.getInstance().fromResource(res));
|
options.icon(BitmapDescriptorFactory.getInstance().fromResource(res));
|
||||||
|
options.anchor(0.5f,0.5f);
|
||||||
}
|
}
|
||||||
markerList.put(site.getDbId(),map.addMarker(options));
|
markerList.put(site.getDbId(),map.addMarker(options));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue