|
|
@@ -170,8 +170,7 @@ public class EarthquakeMapsActivity extends FragmentActivity implements OnMapRea |
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onResume() {
|
|
|
|
mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
|
|
|
|
SensorManager.SENSOR_DELAY_NORMAL);
|
|
|
|
mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
|
|
|
|
super.onResume();
|
|
|
|
}
|
|
|
|
@Override
|
|
|
@@ -231,7 +230,8 @@ public class EarthquakeMapsActivity extends FragmentActivity implements OnMapRea |
|
|
|
mMap.setMyLocationEnabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add a marker in Sydney and move the camera
|
|
|
|
//TODO @ Eddy: Ich denke diesen Code brauchst du auch, oder? :D
|
|
|
|
//Add a marker in Sydney and move the camera
|
|
|
|
//LatLng sydney = new LatLng(-34, 151);
|
|
|
|
//mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
|
|
|
|
//mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
|
|
|
@@ -249,8 +249,6 @@ public class EarthquakeMapsActivity extends FragmentActivity implements OnMapRea |
|
|
|
public void onComplete(@NonNull Task task) {
|
|
|
|
if (task.isSuccessful()){
|
|
|
|
currentLocation = (Location) task.getResult();
|
|
|
|
//currentTime = Calendar.getInstance().getTimeInMillis(); //verschoben in setDataBaseValues
|
|
|
|
//Toast.makeText(EarthquakeMapsActivity.this, currentTime.toString(), Toast.LENGTH_SHORT).show(); //verschoben in setDataBaseValues
|
|
|
|
if(useOwnGPS)
|
|
|
|
{
|
|
|
|
breitengrad = currentLocation.getLatitude();
|
|
|
@@ -259,7 +257,6 @@ public class EarthquakeMapsActivity extends FragmentActivity implements OnMapRea |
|
|
|
currentLocation.setLatitude(breitengrad);
|
|
|
|
currentLocation.setLongitude(laengengrad);
|
|
|
|
moveCamera(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()),15f);
|
|
|
|
//setDataBaseValues(); //Wurde verschoben zu Methode writeEarthquakeToDatabase
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
Toast.makeText(EarthquakeMapsActivity.this, "Current Location unavailable", Toast.LENGTH_SHORT).show();
|
|
|
@@ -286,7 +283,7 @@ public class EarthquakeMapsActivity extends FragmentActivity implements OnMapRea |
|
|
|
public void getDataBaseValuesNoListener()
|
|
|
|
{
|
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
|
mDatenbank.child("overviewAronTestetInDiesemAbschnitt").get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
|
|
|
|
mDatenbank.child("overviewnodes").get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
|
|
|
|
@Override
|
|
|
|
public void onComplete(@NonNull Task<DataSnapshot> task) {
|
|
|
|
if (!task.isSuccessful()) {
|
|
|
@@ -307,11 +304,11 @@ public class EarthquakeMapsActivity extends FragmentActivity implements OnMapRea |
|
|
|
//processMessageDisplay(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void processDeviceIndex(DataSnapshot data)
|
|
|
|
public void processDeviceIndex(DataSnapshot data) //Bestimmt freien IDG Index um Daten einschreiben zu können und legt diesen Index als indexID fest.
|
|
|
|
{
|
|
|
|
for (int i = 1; i<=4; i++)
|
|
|
|
for (int i = 1; i<=5; i++)
|
|
|
|
{
|
|
|
|
String androidid = data.child("IDG" + i).child("androidid").getValue().toString();
|
|
|
|
String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
|
|
|
|
if(androidid.isEmpty())
|
|
|
|
{
|
|
|
|
indexID = i;
|
|
|
@@ -323,12 +320,12 @@ public class EarthquakeMapsActivity extends FragmentActivity implements OnMapRea |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void processLocation(DataSnapshot data)
|
|
|
|
public void processLocation(DataSnapshot data) //Wenn in DB f_nativegps als true hinterlegt ist, werden infolge eigene GPS koordinaten verwendet. Andernfalls wird Breitengrad und Laegengrad mit IDG = indexID als eigene GPS Daten verwendet
|
|
|
|
{
|
|
|
|
String breitengradString = data.child("IDG" + indexID).child("breitengrad").getValue().toString();
|
|
|
|
String laengengradString = data.child("IDG" + indexID).child("laengengrad").getValue().toString();
|
|
|
|
|
|
|
|
if(breitengradString.isEmpty() || laengengradString.isEmpty())
|
|
|
|
String nativegpsString = data.child("IDG" + indexID).child("f_nativegps").getValue().toString();
|
|
|
|
String breitengradString = data.child("IDG" + indexID).child("d_breitengrad").getValue().toString();
|
|
|
|
String laengengradString = data.child("IDG" + indexID).child("e_laengengrad").getValue().toString();
|
|
|
|
if(nativegpsString.equals("true"))
|
|
|
|
{
|
|
|
|
useOwnGPS = true;
|
|
|
|
}else{
|
|
|
@@ -343,10 +340,10 @@ public class EarthquakeMapsActivity extends FragmentActivity implements OnMapRea |
|
|
|
{
|
|
|
|
String vibrationString;
|
|
|
|
String androidid;
|
|
|
|
for (int i = 1; i<=4; i++)
|
|
|
|
for (int i = 1; i<=5; i++)
|
|
|
|
{
|
|
|
|
androidid = data.child("overviewAronTestetInDiesemAbschnitt").child("IDG" + i).child("androidid").getValue().toString();
|
|
|
|
vibrationString = data.child("overviewAronTestetInDiesemAbschnitt").child("IDG" + i).child("vibration").getValue().toString();
|
|
|
|
androidid = data.child("overviewnodes").child("IDG" + i).child("a_androidid").getValue().toString();
|
|
|
|
vibrationString = data.child("overviewnodes").child("IDG" + i).child("g_vibration").getValue().toString();
|
|
|
|
if((!androidid.isEmpty()) && vibrationString.equals("true"))
|
|
|
|
{
|
|
|
|
allowShakeEvent = false;
|
|
|
@@ -370,16 +367,17 @@ public class EarthquakeMapsActivity extends FragmentActivity implements OnMapRea |
|
|
|
public void setDataBaseValues()
|
|
|
|
{
|
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
|
mDatenbank.child("overviewAronTestetInDiesemAbschnitt").child("IDG" + indexID).child("ip").setValue("ProvisorischeIPAdresse");
|
|
|
|
mDatenbank.child("overviewAronTestetInDiesemAbschnitt").child("IDG" + indexID).child("vibration").setValue(true);
|
|
|
|
mDatenbank.child("overviewAronTestetInDiesemAbschnitt").child("IDG" + indexID).child("timestamp").setValue(Calendar.getInstance().getTimeInMillis());
|
|
|
|
mDatenbank.child("overviewAronTestetInDiesemAbschnitt").child("IDG" + indexID).child("breitengrad").setValue(breitengrad);
|
|
|
|
mDatenbank.child("overviewAronTestetInDiesemAbschnitt").child("IDG" + indexID).child("laengengrad").setValue(laengengrad);
|
|
|
|
mDatenbank.child("overviewAronTestetInDiesemAbschnitt").child("IDG" + indexID).child("amplitude").setValue(1001);
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("a_androidid").setValue(getandroidid());
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
mDatenbank.child("overviewAronTestetInDiesemAbschnitt").child("IDG" + indexID).child("localdatetime").setValue(LocalDateTime.now().toString());
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("b_localdatetime").setValue(LocalDateTime.now().toString());
|
|
|
|
}
|
|
|
|
mDatenbank.child("overviewAronTestetInDiesemAbschnitt").child("IDG" + indexID).child("androidid").setValue(getandroidid());
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("c_ip").setValue(getDeviceIpAdress());
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("d_breitengrad").setValue(breitengrad);
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("e_laengengrad").setValue(laengengrad);
|
|
|
|
//mDatenbank.child("overviewnodes").child("IDG" + indexID).child("f_nativegps").setValue(true);
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("g_vibration").setValue(true);
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("h_timestamp").setValue(Calendar.getInstance().getTimeInMillis());
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("i_amplitude").setValue(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
//################################################################## ^^^^ Datenbank Code ^^^^ #############################################################################
|