Browse Source

Fix Bug cursor empty and map not initialized

tags/release-v3.0
Schoumi 2 years ago
parent
commit
43e288ea63
2 changed files with 5 additions and 2 deletions
  1. +3
    -2
      app/src/main/java/fr/mobdev/blooddonation/Database.java
  2. +2
    -0
      app/src/main/java/fr/mobdev/blooddonation/fragment/MapsFragment.java

+ 3
- 2
app/src/main/java/fr/mobdev/blooddonation/Database.java View File

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

+ 2
- 0
app/src/main/java/fr/mobdev/blooddonation/fragment/MapsFragment.java View File

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

Loading…
Cancel
Save