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.Build;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
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.BitmapDescriptorFactory;
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
import com.google.android.gms.maps.model.MarkerOptions;
|
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.Detektionssignal;
|
||||||
import de.edotzlaff.detection.detektion.Epizentrum;
|
import de.edotzlaff.detection.detektion.Epizentrum;
|
||||||
import de.edotzlaff.detection.detektion.Erdbeben;
|
import de.edotzlaff.detection.detektion.Erdbeben;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -31,6 +41,7 @@ public class EarthquakeLocation extends FragmentActivity implements OnMapReadyCa
|
|||||||
|
|
||||||
private GoogleMap mMap;
|
private GoogleMap mMap;
|
||||||
private static final String TAGEPIZENTRUM = "Epizentrum";
|
private static final String TAGEPIZENTRUM = "Epizentrum";
|
||||||
|
private DatabaseReference mDatenbank;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -55,7 +66,7 @@ public class EarthquakeLocation extends FragmentActivity implements OnMapReadyCa
|
|||||||
//TODO Jan
|
//TODO Jan
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
/* public Epizentrum ermittleEpizentrum(DataSnapshot data)
|
public Epizentrum ermittleEpizentrum(DataSnapshot data)
|
||||||
{
|
{
|
||||||
Erdbeben erdbeben = new Erdbeben();
|
Erdbeben erdbeben = new Erdbeben();
|
||||||
erdbeben.addDetektionssignalList(mapToDetektionssignale(data));
|
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());
|
Log.i(TAGEPIZENTRUM, "Epizentrum konnte ermittelt werden, Koordinaten: " + epizentrum.getKoordinaten().getX() + " " + epizentrum.getKoordinaten().getY());
|
||||||
}
|
}
|
||||||
return epizentrum;
|
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<>();
|
ArrayList<Detektionssignal> detektionssignale = new ArrayList<>();
|
||||||
for(data.child("overviewnodes").getChildernKey)
|
for(int i=1; i<=3; i++)
|
||||||
{
|
{
|
||||||
Detektionssignal detektionssignal = new Detektionssignal();
|
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);
|
detektionssignale.add(detektionssignal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return detektionssignale;
|
return detektionssignale;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//################################################################## ^^^^ Calculate Epicenter ^^^^ #######################################################################
|
//################################################################## ^^^^ Calculate Epicenter ^^^^ #######################################################################
|
||||||
//##########################################################################################################################################################################
|
//##########################################################################################################################################################################
|
||||||
|
@ -251,6 +251,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
String laengengrad;
|
String laengengrad;
|
||||||
String timestamp;
|
String timestamp;
|
||||||
String ampltiude;
|
String ampltiude;
|
||||||
|
String welle;
|
||||||
int emptyIDG =0;
|
int emptyIDG =0;
|
||||||
|
|
||||||
for (int i=1; i<=data.getChildrenCount(); i++)
|
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();
|
laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
|
||||||
timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
|
timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
|
||||||
ampltiude = data.child("IDG" + i).child("i_amplitude").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++;
|
emptyIDG++;
|
||||||
}else{
|
}else{
|
||||||
@ -290,6 +292,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
mDatenbank.child("IDG" + k).child("e_laengengrad").setValue("");
|
mDatenbank.child("IDG" + k).child("e_laengengrad").setValue("");
|
||||||
mDatenbank.child("IDG" + k).child("h_timestamp").setValue("");
|
mDatenbank.child("IDG" + k).child("h_timestamp").setValue("");
|
||||||
mDatenbank.child("IDG" + k).child("i_amplitude").setValue("");
|
mDatenbank.child("IDG" + k).child("i_amplitude").setValue("");
|
||||||
|
mDatenbank.child("IDG" + k).child("w_wellengeschwindigkeit").setValue("");
|
||||||
}
|
}
|
||||||
|
|
||||||
//###### Bei Vibration der APP ####
|
//###### Bei Vibration der APP ####
|
||||||
@ -327,14 +330,16 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
String laengengrad;
|
String laengengrad;
|
||||||
String timestamp;
|
String timestamp;
|
||||||
String ampltiude;
|
String ampltiude;
|
||||||
|
String welle;
|
||||||
androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
|
androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
|
||||||
localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
|
localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
|
||||||
breitengrad = data.child("IDG" + i).child("d_breitengrad").getValue().toString();
|
breitengrad = data.child("IDG" + i).child("d_breitengrad").getValue().toString();
|
||||||
laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
|
laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
|
||||||
timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
|
timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
|
||||||
ampltiude = data.child("IDG" + i).child("i_amplitude").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;
|
return true;
|
||||||
}else
|
}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("e_laengengrad").setValue(currentLocation.getLongitude());
|
||||||
mDatenbank.child("IDG" + k).child("h_timestamp").setValue(Calendar.getInstance().getTimeInMillis());
|
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("i_amplitude").setValue(1000);
|
||||||
|
mDatenbank.child("IDG" + k).child("w_wellengeschwindigkeit").setValue(4500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//###### Bei Eintragungen in der DB ####
|
//###### Bei Eintragungen in der DB ####
|
||||||
@ -402,10 +408,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
//Bei genau 3 Einträgen:
|
//Bei genau 3 Einträgen:
|
||||||
if(takenIDG >= 3 && allowCalculation)
|
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;
|
allowCalculation = false;
|
||||||
System.out.println("Gebe an Berechnung raus");
|
Button btnEarthquake = (Button) findViewById(R.id.btnEarthquakeLocation);
|
||||||
//An Jans Code anknüpfen
|
btnEarthquake.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,8 +423,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
String laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
|
String laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
|
||||||
String timestamp = data.child("IDG" + i).child("h_timestamp").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 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;
|
return true;
|
||||||
}else
|
}else
|
||||||
@ -460,6 +467,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
public void resetDisplayText()
|
public void resetDisplayText()
|
||||||
{
|
{
|
||||||
|
Button btnEarthquake = (Button) findViewById(R.id.btnEarthquakeLocation);
|
||||||
|
btnEarthquake.setEnabled(false);
|
||||||
TextView txtDevice1 = (TextView) findViewById(R.id.txtdevice1);
|
TextView txtDevice1 = (TextView) findViewById(R.id.txtdevice1);
|
||||||
TextView txtDevice2 = (TextView) findViewById(R.id.txtdevice2);
|
TextView txtDevice2 = (TextView) findViewById(R.id.txtdevice2);
|
||||||
TextView txtDevice3 = (TextView) findViewById(R.id.txtdevice3);
|
TextView txtDevice3 = (TextView) findViewById(R.id.txtdevice3);
|
||||||
@ -469,6 +478,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
txtDevice3.setText("");
|
txtDevice3.setText("");
|
||||||
txtDevice4.setText("");
|
txtDevice4.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getandroidid ()
|
public String getandroidid ()
|
||||||
{
|
{
|
||||||
return Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
|
return Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||||
@ -536,6 +546,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private void init() {
|
private void init() {
|
||||||
|
|
||||||
Button btnEarthquake = (Button) findViewById(R.id.btnEarthquakeLocation);
|
Button btnEarthquake = (Button) findViewById(R.id.btnEarthquakeLocation);
|
||||||
|
btnEarthquake.setEnabled(false);
|
||||||
btnEarthquake.setOnClickListener(new View.OnClickListener() {
|
btnEarthquake.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user