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

import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.provider.ContactsContract;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;


public void analyzeDBchanges(DataSnapshot data) public void analyzeDBchanges(DataSnapshot data)
{ {
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) || 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) 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();
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();
} }
} }


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 ()
{ {
return Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID); return Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
//########################################################################################################################################################### //###########################################################################################################################################################




}
}

/*
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