|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@Override
|
|
|
protected void onResume() {
|
|
|
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();
|
|
|
super.onResume();
|
|
|
}
|
|
|
}
|
|
|
@Override
|
|
|
@Override
|
|
|
|
|
|
|
|
|
mMap.setMyLocationEnabled(true);
|
|
|
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);
|
|
|
//LatLng sydney = new LatLng(-34, 151);
|
|
|
//mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
|
|
|
//mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
|
|
|
//mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
|
|
|
//mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
|
|
|
|
|
|
|
|
|
public void onComplete(@NonNull Task task) {
|
|
|
public void onComplete(@NonNull Task task) {
|
|
|
if (task.isSuccessful()){
|
|
|
if (task.isSuccessful()){
|
|
|
currentLocation = (Location) task.getResult();
|
|
|
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)
|
|
|
if(useOwnGPS)
|
|
|
{
|
|
|
{
|
|
|
breitengrad = currentLocation.getLatitude();
|
|
|
breitengrad = currentLocation.getLatitude();
|
|
|
|
|
|
|
|
|
currentLocation.setLatitude(breitengrad);
|
|
|
currentLocation.setLatitude(breitengrad);
|
|
|
currentLocation.setLongitude(laengengrad);
|
|
|
currentLocation.setLongitude(laengengrad);
|
|
|
moveCamera(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()),15f);
|
|
|
moveCamera(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()),15f);
|
|
|
//setDataBaseValues(); //Wurde verschoben zu Methode writeEarthquakeToDatabase
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
else{
|
|
|
Toast.makeText(EarthquakeMapsActivity.this, "Current Location unavailable", Toast.LENGTH_SHORT).show();
|
|
|
Toast.makeText(EarthquakeMapsActivity.this, "Current Location unavailable", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
|
public void getDataBaseValuesNoListener()
|
|
|
public void getDataBaseValuesNoListener()
|
|
|
{
|
|
|
{
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
mDatenbank.child("overviewAronTestetInDiesemAbschnitt").get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
|
|
|
|
|
|
|
|
|
mDatenbank.child("overviewnodes").get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
|
|
|
@Override
|
|
|
@Override
|
|
|
public void onComplete(@NonNull Task<DataSnapshot> task) {
|
|
|
public void onComplete(@NonNull Task<DataSnapshot> task) {
|
|
|
if (!task.isSuccessful()) {
|
|
|
if (!task.isSuccessful()) {
|
|
|
|
|
|
|
|
|
//processMessageDisplay(data);
|
|
|
//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())
|
|
|
if(androidid.isEmpty())
|
|
|
{
|
|
|
{
|
|
|
indexID = i;
|
|
|
indexID = i;
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
useOwnGPS = true;
|
|
|
}else{
|
|
|
}else{
|
|
|
|
|
|
|
|
|
{
|
|
|
{
|
|
|
String vibrationString;
|
|
|
String vibrationString;
|
|
|
String androidid;
|
|
|
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"))
|
|
|
if((!androidid.isEmpty()) && vibrationString.equals("true"))
|
|
|
{
|
|
|
{
|
|
|
allowShakeEvent = false;
|
|
|
allowShakeEvent = false;
|
|
|
|
|
|
|
|
|
public void setDataBaseValues()
|
|
|
public void setDataBaseValues()
|
|
|
{
|
|
|
{
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
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) {
|
|
|
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 ^^^^ #############################################################################
|
|
|
//################################################################## ^^^^ Datenbank Code ^^^^ #############################################################################
|