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);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
|
||||
.detectDiskReads()
|
||||
.detectDiskWrites()
|
||||
.detectNetwork()
|
||||
.penaltyLog()
|
||||
.build());
|
||||
// Netzwerk aktivieren
|
||||
StrictMode.setThreadPolicy(new StrictMode
|
||||
.ThreadPolicy
|
||||
.Builder()
|
||||
.detectDiskReads()
|
||||
.detectDiskWrites()
|
||||
.detectNetwork()
|
||||
.penaltyLog()
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
public void btnToggle(View view) {
|
||||
// Fehlernachricht in String schreiben
|
||||
String toast = "Obacht! Etwas ist schief gelaufen.";
|
||||
try {
|
||||
// Aufruf an den Mikrocontroller senden
|
||||
REST.getString(URL + "/toggle");
|
||||
// Erfolgsnachricht anpassen
|
||||
toast = "Muster geändert.";
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Nachricht auf dem Bildschirm ausgeben
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public void btnLos(View view) {
|
||||
// Textfeld im Code verfügbar machen
|
||||
EditText state = view.getRootView().findViewById(R.id.state);
|
||||
// Zahl aus dem Textfeld auslesen
|
||||
String nummer = state.getText().toString();
|
||||
// Fehlernachricht in String schreiben
|
||||
String toast = "Obacht! Etwas ist schief gelaufen.";
|
||||
try {
|
||||
// Aufruf mit Zahl an den Mikrocontroller senden
|
||||
REST.getString(URL + "/togglearg?state=" + nummer);
|
||||
// Erfolgsnachricht anpassen
|
||||
toast = "Muster auf " + nummer + " gesetzt.";
|
||||
} catch (IOException e) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@@ -64,4 +64,25 @@
|
||||
android:text="Nächstes Muster:"
|
||||
app:layout_constraintStart_toStartOf="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>
|
Reference in New Issue
Block a user