Merge branch 'master' of https://git.schoffit.net/structix/janasRoboter
This commit is contained in:
@@ -20,36 +20,60 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
|
// Netzwerk aktivieren
|
||||||
.detectDiskReads()
|
StrictMode.setThreadPolicy(new StrictMode
|
||||||
.detectDiskWrites()
|
.ThreadPolicy
|
||||||
.detectNetwork()
|
.Builder()
|
||||||
.penaltyLog()
|
.detectDiskReads()
|
||||||
.build());
|
.detectDiskWrites()
|
||||||
|
.detectNetwork()
|
||||||
|
.penaltyLog()
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void btnToggle(View view) {
|
public void btnToggle(View view) {
|
||||||
|
// Fehlernachricht in String schreiben
|
||||||
String toast = "Obacht! Etwas ist schief gelaufen.";
|
String toast = "Obacht! Etwas ist schief gelaufen.";
|
||||||
try {
|
try {
|
||||||
|
// Aufruf an den Mikrocontroller senden
|
||||||
REST.getString(URL + "/toggle");
|
REST.getString(URL + "/toggle");
|
||||||
|
// Erfolgsnachricht anpassen
|
||||||
toast = "Muster geändert.";
|
toast = "Muster geändert.";
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
// Nachricht auf dem Bildschirm ausgeben
|
||||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void btnLos(View view) {
|
public void btnLos(View view) {
|
||||||
|
// Textfeld im Code verfügbar machen
|
||||||
EditText state = view.getRootView().findViewById(R.id.state);
|
EditText state = view.getRootView().findViewById(R.id.state);
|
||||||
|
// Zahl aus dem Textfeld auslesen
|
||||||
String nummer = state.getText().toString();
|
String nummer = state.getText().toString();
|
||||||
|
// Fehlernachricht in String schreiben
|
||||||
String toast = "Obacht! Etwas ist schief gelaufen.";
|
String toast = "Obacht! Etwas ist schief gelaufen.";
|
||||||
try {
|
try {
|
||||||
|
// Aufruf mit Zahl an den Mikrocontroller senden
|
||||||
REST.getString(URL + "/togglearg?state=" + nummer);
|
REST.getString(URL + "/togglearg?state=" + nummer);
|
||||||
|
// Erfolgsnachricht anpassen
|
||||||
toast = "Muster auf " + nummer + " gesetzt.";
|
toast = "Muster auf " + nummer + " gesetzt.";
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
// Nachricht auf dem Bildschirm ausgeben
|
||||||
|
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void btnSingen(View view) {
|
||||||
|
String toast = "Obacht! Etwas ist schief gelaufen.";
|
||||||
|
try {
|
||||||
|
REST.getString(URL + "/singen");
|
||||||
|
toast = "Singen aktiviert";
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,4 +64,25 @@
|
|||||||
android:text="Nächstes Muster:"
|
android:text="Nächstes Muster:"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="41dp"
|
||||||
|
android:text="Singen:"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textViewMuster" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnSingen"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="90dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:onClick="btnSingen"
|
||||||
|
android:text="Singen"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/textView"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/state" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Reference in New Issue
Block a user