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

Added image preloading to avoid lag

parent b741ba72
Branches
No related tags found
No related merge requests found
......@@ -7,10 +7,16 @@ import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import Common.BuildingManager;
import Popups.DirectionsPopup;
import Popups.GotoPopup;
import Structures.BuildingInfo;
import Structures.PhotoInfo;
import Structures.RoomInfo;
import Structures.ZoneInfo;
public class BuildingView extends AppCompatActivity {
BuildingInfo building = null;
......@@ -41,6 +47,18 @@ public class BuildingView extends AppCompatActivity {
tile_directions.setOnClickListener(view -> {
showDirectionsPopup();
});
// pre-load all the building's photos (to make the app faster)
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> {
for (RoomInfo room: building.getRooms()) {
for (ZoneInfo zone : room.getZones()) {
for (PhotoInfo photo : zone.getPhotos()) {
photo.getBitmap();
}
}
}
});
}
protected void showGotoPopup() {
......
......@@ -16,6 +16,9 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import Common.BuildingManager;
import Common.Coord;
import Popups.PhotoInfoPopup;
......@@ -100,6 +103,16 @@ public class ZoneView extends AppCompatActivity {
zone = null;
}
// pre-load all the zones's photos (to make the app faster)
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> {
for (ZoneInfo zone : room.getZones()) {
for (PhotoInfo photo : zone.getPhotos()) {
photo.getBitmap();
}
}
});
// set the left-right buttons
ImageButton btn_l = findViewById(R.id.btn_turn_l);
ImageButton btn_r = findViewById(R.id.btn_turn_r);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment