Per-AlphaV10 - Displayverbesserung
This commit is contained in:
parent
ba9e3d5aa7
commit
53528a82e9
@ -378,34 +378,83 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
public void analyzeDBchanges(DataSnapshot data)
|
public void analyzeDBchanges(DataSnapshot data)
|
||||||
{
|
{
|
||||||
|
for (int i=1; i<=data.getChildrenCount(); i++)
|
||||||
|
{
|
||||||
|
if(analyzeForFullIDG(data,i) || analyzeForEmptyIDG(data,i))
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int takenIDG = 0;
|
int takenIDG = 0;
|
||||||
for (int i=1; i<=data.getChildrenCount(); i++)
|
for (int i=1; i<=data.getChildrenCount(); i++)
|
||||||
{
|
{
|
||||||
if(analyzeForFullIDG(data,i))
|
if(analyzeForFullIDG(data,i))
|
||||||
{
|
{
|
||||||
//Ein voller IDG slot
|
|
||||||
takenIDG++;
|
takenIDG++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
{
|
|
||||||
if(enableDisplayReset)
|
|
||||||
{
|
|
||||||
resetDisplayText();
|
|
||||||
enableDisplayReset = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Bei genau 3 Einträgen:
|
|
||||||
if(takenIDG >= 3 && allowCalculation)
|
if(takenIDG >= 3 && allowCalculation)
|
||||||
{
|
{
|
||||||
Toast.makeText(MainActivity.this, "3 Geräte regisrtiert - Berechnung möglich!", Toast.LENGTH_SHORT).show();
|
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);
|
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)
|
public boolean analyzeForFullIDG(DataSnapshot data, int i)
|
||||||
{
|
{
|
||||||
String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
|
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 ()
|
public String getandroidid ()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user