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

Added smart room's zone movements

parent ff072b5c
No related branches found
No related tags found
No related merge requests found
...@@ -104,6 +104,29 @@ public class RoomInfo implements Serializable { ...@@ -104,6 +104,29 @@ public class RoomInfo implements Serializable {
this.askForSave(); this.askForSave();
} }
public ZoneInfo getNearestZone(RoomInfo room) {
if (this.getNbZones() == 0) return null;
ZoneInfo selectedZone = this.getZone(0);
int zone_score = 0;
for (ZoneInfo z: this.zones) {
int z_score = 0;
for (PhotoInfo ph: z.getPhotos()) {
for (PathView pv: ph.getPathViews()) {
PathInfo p = pv.getPath();
if (p == null) continue;
if (p.getDestination().equals(room))
z_score++;
}
}
if (z_score > zone_score) {
zone_score = z_score;
selectedZone = z;
}
}
return selectedZone;
}
public void setBuilding(BuildingInfo building) { this.building = building; } public void setBuilding(BuildingInfo building) { this.building = building; }
public BuildingInfo getBuilding() { public BuildingInfo getBuilding() {
......
...@@ -227,7 +227,7 @@ public class ZoneView extends AppCompatActivity { ...@@ -227,7 +227,7 @@ public class ZoneView extends AppCompatActivity {
Toast.makeText(this, "Your can't go here.\nThis room doesn't have any zone or photos yet.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Your can't go here.\nThis room doesn't have any zone or photos yet.", Toast.LENGTH_SHORT).show();
return; return;
} }
ZoneInfo new_zone = dest.getZone(0); ZoneInfo new_zone = dest.getNearestZone(this.room);
old_zone = this.zone; old_zone = this.zone;
this.room = dest; this.room = dest;
this.zone = new_zone; this.zone = new_zone;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment