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

Added smart pathway in popup adding

parent bf14d3d8
No related branches found
No related tags found
No related merge requests found
......@@ -79,18 +79,30 @@ public class PathviewPopup {
public void setSelectedPath(PathInfo path) { this.p_path.setSelection(room.getPaths().indexOf(path)); }
public PathInfo getSelectedPath() {
return room.getPath( p_path.getSelectedItemPosition() );
int pos = p_path.getSelectedItemPosition();
if ( pos < 0 || pos >= room.getPaths().size() ) return null;
return room.getPath( pos );
}
public void show() {
dialog.show();
}
protected void updatePathwaysList(PathInfo selected) {
updatePathwaysList();
p_path.setSelection( room.getPaths().indexOf(selected) );
}
protected void updatePathwaysList() {
String[] str_orients = new String[room.getPaths().size()];
for (int i = 0; i < str_orients.length; i++)
str_orients[i] = room.getPath(i).getName();
PathInfo selection = getSelectedPath();
p_path.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, str_orients));
if (selection != null) p_path.setSelection( room.getPaths().indexOf(selection) );
if (room.getPaths().size() == 0) {
validate_btn.setEnabled(false);
TextView tv_err = dialog.findViewById(R.id.pathview_input_error_msg);
......@@ -118,12 +130,14 @@ public class PathviewPopup {
param -> {
PathwayPopup popup = ((PathwayPopup) param);
String name = popup.getInput().getText().toString();
PathInfo new_path;
if (popup.getSelectedType() == PathType.DOOR) {
room.addPath(new PathDoor(name, popup.getUpDestination()));
new_path = new PathDoor(name, popup.getUpDestination());
} else {
room.addPath(new PathStairs(name, popup.getUpDestination(), popup.getDownDestination()));
new_path = new PathStairs(name, popup.getUpDestination(), popup.getDownDestination());
}
updatePathwaysList();
room.addPath(new_path);
updatePathwaysList(new_path);
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