Browse Source

Per-AlphaV10 - Displayverbesserung

master
Raz492 3 years ago
parent
commit
53528a82e9
1 changed files with 78 additions and 62 deletions
  1. 78
    62
      app/src/main/java/de/edotzlaff/detection/MainActivity.java

+ 78
- 62
app/src/main/java/de/edotzlaff/detection/MainActivity.java View File

@@ -378,34 +378,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)
{
//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();
@@ -414,7 +463,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();
@@ -434,49 +493,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 ()
{

Loading…
Cancel
Save