Skip to content
Snippets Groups Projects
Commit bf14d3d8 authored by FurWaz's avatar FurWaz
Browse files

Added smart room in-popup adding

parent b64206a8
No related branches found
No related tags found
No related merge requests found
......@@ -207,16 +207,35 @@ public class PathwayPopup {
if (onValidate != null) onValidate.call(this);
}
protected void updateRoomLists(RoomInfo selection) {
this.updateRoomLists();
int roomindex = building.getRooms().indexOf(selection) + 1;
if (getSelectedType() == PathType.DOOR) {
sp_dest_up.setSelection( roomindex );
} else {
if (getUpDestination() == null)
sp_dest_up.setSelection( roomindex );
if (getDownDestination() == null)
sp_dest_down.setSelection( roomindex );
}
}
protected void updateRoomLists() {
List<String> names = new ArrayList<>();
names.add("<"+context.getResources().getString(R.string.none)+">");
for(RoomInfo r : building.getRooms()) names.add(r.getName());
for (RoomInfo r : building.getRooms()) names.add(r.getName());
String[] sp_dest_items = new String[names.size()];
for (int i = 0; i < names.size(); i++) sp_dest_items[i] = names.get(i);
sp_dest_up.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, sp_dest_items));
sp_dest_down.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, sp_dest_items));
RoomInfo selection_up = getUpDestination();
RoomInfo selection_down = getDownDestination();
sp_dest_up.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item, sp_dest_items));
sp_dest_down.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_spinner_dropdown_item, sp_dest_items));
if (selection_up != null) sp_dest_up.setSelection( building.getRooms().indexOf(selection_up) + 1 );
if (selection_down != null) sp_dest_down.setSelection( building.getRooms().indexOf(selection_down) + 1 );
}
protected void showAddRoomPopup() {
......@@ -233,8 +252,9 @@ public class PathwayPopup {
},
param -> {
RoomPopup popup = ((RoomPopup) param);
building.addRoom(new RoomInfo(popup.getInput().getText().toString()));
updateRoomLists();
RoomInfo new_room = new RoomInfo(popup.getInput().getText().toString());
building.addRoom(new_room);
updateRoomLists(new_room);
popup.dismiss();
return null;
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment