Browse Source

Pre-AlphaV9 - 5 GPS Test Buttons und Displayaktualisierung

EpiTest
Raz492 3 years ago
parent
commit
65cabe66e9
1 changed files with 130 additions and 65 deletions
  1. 130
    65
      app/src/main/java/de/edotzlaff/detection/MainActivity.java

+ 130
- 65
app/src/main/java/de/edotzlaff/detection/MainActivity.java View File

@@ -19,6 +19,7 @@ import android.location.Location;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.provider.ContactsContract;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
@@ -379,35 +380,83 @@ public class MainActivity extends AppCompatActivity {

public void analyzeDBchanges(DataSnapshot data)
{
int takenIDG = 0;
for (int i=1; i<=data.getChildrenCount(); i++)
{
if(analyzeForFullIDG(data,i))
if(analyzeForFullIDG(data,i) || analyzeForEmptyIDG(data,i))
{
//Ein voller IDG slot
takenIDG++;
TextView txtDevice1 = (TextView) findViewById(R.id.txtdevice1);
TextView txtDevice2 = (TextView) findViewById(R.id.txtdevice2);
TextView txtDevice3 = (TextView) findViewById(R.id.txtdevice3);
TextView txtDevice4 = (TextView) findViewById(R.id.txtdevice4);
String dbSlotStringContent = getSlotString(data,i);
String displayContent;
switch (i){
case 1:
displayContent = txtDevice1.getText().toString();
if(!displayContent.equals(dbSlotStringContent))
{
if(analyzeForEmptyIDG(data,i))
{
txtDevice1.setText("");
}else
{
txtDevice1.setText(dbSlotStringContent);
}
}
break;
case 2:
displayContent = txtDevice2.getText().toString();
if(!displayContent.equals(dbSlotStringContent))
{
if(analyzeForEmptyIDG(data,i))
{
txtDevice2.setText("");
}else
{
txtDevice2.setText(dbSlotStringContent);
}
}
break;
case 3:
displayContent = txtDevice3.getText().toString();
if(!displayContent.equals(dbSlotStringContent))
{
if(analyzeForEmptyIDG(data,i))
{
txtDevice3.setText("");
}else
{
txtDevice3.setText(dbSlotStringContent);
}
}
break;
case 4:
displayContent = txtDevice4.getText().toString();
if(!displayContent.equals(dbSlotStringContent))
{
if(analyzeForEmptyIDG(data,i))
{
txtDevice4.setText("");
}else
{
txtDevice4.setText(dbSlotStringContent);
}
}
break;
default:
break;
}
}
}

if(takenIDG>=1 && takenIDG <=5)
{
System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
//Kommt bei einer neuen vollen IDG ins Display
for(writtenDevices = writtenDevices; writtenDevices <= takenIDG; writtenDevices++)
{
setDisplayText(data,writtenDevices);
enableDisplayReset = true; //Für DB zurücksetzen
}
}else
int takenIDG = 0;
for (int i=1; i<=data.getChildrenCount(); i++)
{
if(enableDisplayReset)
if(analyzeForFullIDG(data,i))
{
resetDisplayText();
enableDisplayReset = false;
takenIDG++;
}
}

//Bei genau 3 Einträgen:
if(takenIDG >= 3 && allowCalculation)
{
Toast.makeText(MainActivity.this, "3 Geräte regisrtiert - Berechnung möglich!", Toast.LENGTH_SHORT).show();
@@ -416,7 +465,17 @@ public class MainActivity extends AppCompatActivity {
btnEarthquake.setEnabled(true);
}
}

public String getSlotString(DataSnapshot data,int i)
{
String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
String localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
String breitengrad = data.child("IDG" + i).child("d_breitengrad").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 ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
String databaseSlotString = "Device ID " + i + ": "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n";
return databaseSlotString;
}
public boolean analyzeForFullIDG(DataSnapshot data, int i)
{
String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
@@ -436,50 +495,6 @@ public class MainActivity extends AppCompatActivity {
}
}

public void setDisplayText(DataSnapshot data, int i)
{
String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
String localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
String breitengrad = data.child("IDG" + i).child("d_breitengrad").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 ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
TextView txtDevice1 = (TextView) findViewById(R.id.txtdevice1);
TextView txtDevice2 = (TextView) findViewById(R.id.txtdevice2);
TextView txtDevice3 = (TextView) findViewById(R.id.txtdevice3);
TextView txtDevice4 = (TextView) findViewById(R.id.txtdevice4);
switch (i){
case 1:
txtDevice1.setText("Device ID 1: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
break;
case 2:
txtDevice2.setText("Device ID 2: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
break;
case 3:
txtDevice3.setText("Device ID 3: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
break;
case 4:
txtDevice4.setText("Device ID 4: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
break;
default:
break;
}
}

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);
TextView txtDevice4 = (TextView) findViewById(R.id.txtdevice4);
txtDevice1.setText("");
txtDevice2.setText("");
txtDevice3.setText("");
txtDevice4.setText("");
}

public String getandroidid ()
{
return Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
@@ -755,4 +770,54 @@ public class MainActivity extends AppCompatActivity {
//###########################################################################################################################################################


}
}

/*
public void setDisplayText(DataSnapshot data, int i)
{
String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
String localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
String breitengrad = data.child("IDG" + i).child("d_breitengrad").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 ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
TextView txtDevice1 = (TextView) findViewById(R.id.txtdevice1);
TextView txtDevice2 = (TextView) findViewById(R.id.txtdevice2);
TextView txtDevice3 = (TextView) findViewById(R.id.txtdevice3);
TextView txtDevice4 = (TextView) findViewById(R.id.txtdevice4);
switch (i){
case 1:
txtDevice1.setText("Device ID 1: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
break;
case 2:
txtDevice2.setText("Device ID 2: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
break;
case 3:
txtDevice3.setText("Device ID 3: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
break;
case 4:
txtDevice4.setText("Device ID 4: "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n");
break;
default:
break;
}
}

*/

/*
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);
TextView txtDevice4 = (TextView) findViewById(R.id.txtdevice4);
txtDevice1.setText("");
txtDevice2.setText("");
txtDevice3.setText("");
txtDevice4.setText("");
allowCalculation=true;
}
*/

Loading…
Cancel
Save