Inhaltsstoffe in Filter Maske anzeigen
This commit is contained in:
parent
450e08b8e7
commit
c6b4bc1cd1
@ -9,4 +9,10 @@ public class Zutat {
|
||||
public String getName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,14 +7,21 @@
|
||||
package de.subway_surfers.vpr_app;
|
||||
|
||||
import Logik.Kind;
|
||||
import Logik.Zutat;
|
||||
import RestAPISchnittstelle.RestApiClient;
|
||||
import com.google.gson.*;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.SelectionMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class InhaltsstoffeFilternController {
|
||||
|
||||
private @FXML ListView<zutatListViewController> zutatListView;
|
||||
private @FXML ListView<Zutat> zutatListView;
|
||||
|
||||
private @FXML CheckBox speichernCheckBox;
|
||||
|
||||
@ -22,11 +29,28 @@ public class InhaltsstoffeFilternController {
|
||||
|
||||
private @FXML Button fortfahrenButton;
|
||||
|
||||
private ArrayList<Zutat> zutaten;
|
||||
|
||||
public void initialize(){
|
||||
|
||||
// hier ListView füllen
|
||||
zutatListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||
|
||||
RestApiClient api = new RestApiClient();
|
||||
String json = api.get("Inhaltsstoff");
|
||||
|
||||
zutaten = new ArrayList<>();
|
||||
|
||||
Gson gson = new Gson();
|
||||
|
||||
JsonElement je = JsonParser.parseString(json);
|
||||
JsonArray ja = je.getAsJsonArray();
|
||||
|
||||
for (JsonElement e : ja) {
|
||||
JsonObject jo = e.getAsJsonObject();
|
||||
zutaten.add(gson.fromJson(jo, Zutat.class));
|
||||
}
|
||||
|
||||
zutatListView.setItems(FXCollections.observableArrayList(zutaten));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user