Fix Bug cursor empty and map not initialized

This commit is contained in:
Schoumi 2017-08-23 16:35:14 +02:00
bovenliggende 3a205aa183
commit 43e288ea63
2 gewijzigde bestanden met toevoegingen van 5 en 2 verwijderingen

Bestand weergeven

@ -477,8 +477,9 @@ public class Database extends SQLiteOpenHelper {
columns[0] = "latitude";
columns[1] = "longitude";
Cursor cursor = getReadableDatabase().query("user",columns,null,null,null,null,null);
cursor.moveToFirst();
LatLng loc = new LatLng(cursor.getDouble(0),cursor.getDouble(1));
LatLng loc = new LatLng(0,0);
if(cursor.moveToFirst())
loc = new LatLng(cursor.getDouble(0),cursor.getDouble(1));
cursor.close();
return loc;
}

Bestand weergeven

@ -419,6 +419,8 @@ public class MapsFragment extends Fragment implements OnMapReadyCallback {
}
private LatLng getCorner(CORNER corner) {
if(map == null)
return new LatLng(0,0);
com.car2go.maps.Projection pr = map.getProjection();
LatLngBounds bounds = pr.getVisibleRegion().latLngBounds;
if(corner == CORNER.TOP_RIGHT)