Pre-AlphaV5
This commit is contained in:
parent
59880392f6
commit
b88f45b728
@ -7,6 +7,8 @@ import android.hardware.SensorManager;
|
||||
import android.os.Build;
|
||||
import android.os.CountDownTimer;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
@ -20,10 +22,18 @@ import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.firebase.database.DataSnapshot;
|
||||
import com.google.firebase.database.DatabaseReference;
|
||||
import com.google.firebase.database.FirebaseDatabase;
|
||||
|
||||
import de.edotzlaff.detection.detektion.Detektionssignal;
|
||||
import de.edotzlaff.detection.detektion.Epizentrum;
|
||||
import de.edotzlaff.detection.detektion.Erdbeben;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -31,6 +41,7 @@ public class EarthquakeLocation extends FragmentActivity implements OnMapReadyCa
|
||||
|
||||
private GoogleMap mMap;
|
||||
private static final String TAGEPIZENTRUM = "Epizentrum";
|
||||
private DatabaseReference mDatenbank;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -55,7 +66,7 @@ public class EarthquakeLocation extends FragmentActivity implements OnMapReadyCa
|
||||
//TODO Jan
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
/* public Epizentrum ermittleEpizentrum(DataSnapshot data)
|
||||
public Epizentrum ermittleEpizentrum(DataSnapshot data)
|
||||
{
|
||||
Erdbeben erdbeben = new Erdbeben();
|
||||
erdbeben.addDetektionssignalList(mapToDetektionssignale(data));
|
||||
@ -72,29 +83,68 @@ public class EarthquakeLocation extends FragmentActivity implements OnMapReadyCa
|
||||
Log.i(TAGEPIZENTRUM, "Epizentrum konnte ermittelt werden, Koordinaten: " + epizentrum.getKoordinaten().getX() + " " + epizentrum.getKoordinaten().getY());
|
||||
}
|
||||
return epizentrum;
|
||||
}
|
||||
|
||||
//Aufruf der DB
|
||||
public void getDataBaseValuesNoListener()
|
||||
{
|
||||
mDatenbank = FirebaseDatabase.getInstance().getReference().child("overviewdetection");
|
||||
mDatenbank.get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<DataSnapshot> task) {
|
||||
if (!task.isSuccessful()) {
|
||||
System.out.println("Datenbank Fehler in getDataBaseValuesNoListener");
|
||||
}
|
||||
else {
|
||||
mapToDetektionssignale(task.getResult());
|
||||
doSomething(task.getResult());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void doSomething(DataSnapshot data)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
/* public ArrayList<Detektionssignal> mapToDetektionssignale(DataSnapshot data)
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public ArrayList<Detektionssignal> mapToDetektionssignale(DataSnapshot data)
|
||||
{
|
||||
ArrayList<Detektionssignal> detektionssignale = new ArrayList<>();
|
||||
for(data.child("overviewnodes").getChildernKey)
|
||||
for(int i=1; i<=3; i++)
|
||||
{
|
||||
Detektionssignal detektionssignal = new Detektionssignal();
|
||||
detektionssignal.setAnkunftsZeit();
|
||||
detektionssignal.setDeviceId();
|
||||
detektionssignal.setKoordinaten(data.child("overviewnodes").child("IDG" + f).child("d_breitengrad").getValue().toString(),
|
||||
data.child("overviewnodes").child("IDG" + f).child("e_laengengrad").getValue().toString());
|
||||
detektionssignal.setGeschwErdbeben();
|
||||
|
||||
//LocalDateTime als LocalDateTime
|
||||
String localdatetimeString = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
|
||||
LocalDateTime localdatetime = LocalDateTime.parse(localdatetimeString, formatter);
|
||||
detektionssignal.setAnkunftsZeit(localdatetime);
|
||||
|
||||
//ID als String
|
||||
detektionssignal.setDeviceId(data.child("IDG" + i).child("a_androidid").getValue().toString());
|
||||
|
||||
//Koordinaten als???
|
||||
String breitengradString = data.child("IDG" + i).child("d_breitengrad").getValue().toString();
|
||||
String laengengradString = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
|
||||
double breitengrad = Double.parseDouble(breitengradString);
|
||||
double laengengrad = Double.parseDouble(laengengradString);
|
||||
//TODO @Jan In welchem Datenformat muss ich breitengrad und laengengrad hier einfügen? Außerdem welche Einheit? m/s oder km/s?
|
||||
//detektionssignal.setKoordinaten(breitengrad, laengengrad);
|
||||
|
||||
//Wellengeschwindigkeit als int
|
||||
String welle = data.child("IDG" + i).child("w_wellengeschwindigkeit").getValue().toString();
|
||||
int wellengeschwindigkeit = Integer.parseInt(welle);
|
||||
detektionssignal.setGeschwErdbeben(wellengeschwindigkeit);
|
||||
|
||||
//Detektionssignal
|
||||
detektionssignale.add(detektionssignal);
|
||||
}
|
||||
|
||||
return detektionssignale;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//################################################################## ^^^^ Calculate Epicenter ^^^^ #######################################################################
|
||||
//##########################################################################################################################################################################
|
||||
|
@ -251,6 +251,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
String laengengrad;
|
||||
String timestamp;
|
||||
String ampltiude;
|
||||
String welle;
|
||||
int emptyIDG =0;
|
||||
|
||||
for (int i=1; i<=data.getChildrenCount(); i++)
|
||||
@ -261,8 +262,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
|
||||
timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
|
||||
ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
|
||||
welle = data.child("IDG" + i).child("w_wellengeschwindigkeit").getValue().toString();
|
||||
|
||||
if(androidid.isEmpty() && localedatetime.isEmpty() && breitengrad.isEmpty() && laengengrad.isEmpty() && timestamp.isEmpty() && ampltiude.isEmpty())
|
||||
if(androidid.isEmpty() && localedatetime.isEmpty() && breitengrad.isEmpty() && laengengrad.isEmpty() && timestamp.isEmpty() && ampltiude.isEmpty() && welle.isEmpty())
|
||||
{
|
||||
emptyIDG++;
|
||||
}else{
|
||||
@ -290,6 +292,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
mDatenbank.child("IDG" + k).child("e_laengengrad").setValue("");
|
||||
mDatenbank.child("IDG" + k).child("h_timestamp").setValue("");
|
||||
mDatenbank.child("IDG" + k).child("i_amplitude").setValue("");
|
||||
mDatenbank.child("IDG" + k).child("w_wellengeschwindigkeit").setValue("");
|
||||
}
|
||||
|
||||
//###### Bei Vibration der APP ####
|
||||
@ -327,14 +330,16 @@ public class MainActivity extends AppCompatActivity {
|
||||
String laengengrad;
|
||||
String timestamp;
|
||||
String ampltiude;
|
||||
String welle;
|
||||
androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
|
||||
localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
|
||||
breitengrad = data.child("IDG" + i).child("d_breitengrad").getValue().toString();
|
||||
laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
|
||||
timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
|
||||
ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
|
||||
welle = data.child("IDG" + i).child("w_wellengeschwindigkeit").getValue().toString();
|
||||
|
||||
if(androidid.isEmpty() && localedatetime.isEmpty() && breitengrad.isEmpty() && laengengrad.isEmpty() && timestamp.isEmpty() && ampltiude.isEmpty())
|
||||
if(androidid.isEmpty() && localedatetime.isEmpty() && breitengrad.isEmpty() && laengengrad.isEmpty() && timestamp.isEmpty() && ampltiude.isEmpty() && welle.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}else
|
||||
@ -354,6 +359,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
mDatenbank.child("IDG" + k).child("e_laengengrad").setValue(currentLocation.getLongitude());
|
||||
mDatenbank.child("IDG" + k).child("h_timestamp").setValue(Calendar.getInstance().getTimeInMillis());
|
||||
mDatenbank.child("IDG" + k).child("i_amplitude").setValue(1000);
|
||||
mDatenbank.child("IDG" + k).child("w_wellengeschwindigkeit").setValue(4500);
|
||||
}
|
||||
|
||||
//###### Bei Eintragungen in der DB ####
|
||||
@ -402,10 +408,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
//Bei genau 3 Einträgen:
|
||||
if(takenIDG >= 3 && allowCalculation)
|
||||
{
|
||||
Toast.makeText(MainActivity.this, "Es wurden 3 Geräteeinträge registriert!", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(MainActivity.this, "3 Geräte regisrtiert - Berechnung möglich!", Toast.LENGTH_SHORT).show();
|
||||
allowCalculation = false;
|
||||
System.out.println("Gebe an Berechnung raus");
|
||||
//An Jans Code anknüpfen
|
||||
Button btnEarthquake = (Button) findViewById(R.id.btnEarthquakeLocation);
|
||||
btnEarthquake.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,8 +423,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
String laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
|
||||
String timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
|
||||
String ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
|
||||
String welle = data.child("IDG" + i).child("w_wellengeschwindigkeit").getValue().toString();
|
||||
|
||||
if(!androidid.isEmpty() && !localedatetime.isEmpty() && !breitengrad.isEmpty() && !laengengrad.isEmpty() && !timestamp.isEmpty() && !ampltiude.isEmpty())
|
||||
if(!androidid.isEmpty() && !localedatetime.isEmpty() && !breitengrad.isEmpty() && !laengengrad.isEmpty() && !timestamp.isEmpty() && !ampltiude.isEmpty() && !welle.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}else
|
||||
@ -460,6 +467,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
public void resetDisplayText()
|
||||
{
|
||||
Button btnEarthquake = (Button) findViewById(R.id.btnEarthquakeLocation);
|
||||
btnEarthquake.setEnabled(false);
|
||||
TextView txtDevice1 = (TextView) findViewById(R.id.txtdevice1);
|
||||
TextView txtDevice2 = (TextView) findViewById(R.id.txtdevice2);
|
||||
TextView txtDevice3 = (TextView) findViewById(R.id.txtdevice3);
|
||||
@ -469,6 +478,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
txtDevice3.setText("");
|
||||
txtDevice4.setText("");
|
||||
}
|
||||
|
||||
public String getandroidid ()
|
||||
{
|
||||
return Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
@ -536,6 +546,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
private void init() {
|
||||
|
||||
Button btnEarthquake = (Button) findViewById(R.id.btnEarthquakeLocation);
|
||||
btnEarthquake.setEnabled(false);
|
||||
btnEarthquake.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user