From 2d426153dced226f39ad5f671dc70f45c0abd35b Mon Sep 17 00:00:00 2001 From: Andrey Novikov Date: Sun, 4 Feb 2024 19:58:30 +0300 Subject: [PATCH] Do not attempt to change map view if track is empty --- app/src/main/java/mobi/maptrek/MainActivity.java | 2 ++ app/src/main/java/mobi/maptrek/data/Track.java | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/mobi/maptrek/MainActivity.java b/app/src/main/java/mobi/maptrek/MainActivity.java index 90b28b73..e136ab37 100644 --- a/app/src/main/java/mobi/maptrek/MainActivity.java +++ b/app/src/main/java/mobi/maptrek/MainActivity.java @@ -2750,6 +2750,8 @@ public void onTrackView(Track track) { updateLocationDrawable(); } BoundingBox box = track.getBoundingBox(); + if (box == null) + return; box.extendBy(0.05); mMap.animator().animateTo(box); } diff --git a/app/src/main/java/mobi/maptrek/data/Track.java b/app/src/main/java/mobi/maptrek/data/Track.java index 6c97850e..7249a0bf 100644 --- a/app/src/main/java/mobi/maptrek/data/Track.java +++ b/app/src/main/java/mobi/maptrek/data/Track.java @@ -39,7 +39,8 @@ public class Track { private BoundingBox mBox = null; public BoundingBox getBoundingBox() { - //TODO Honor empty track + if (points.isEmpty()) + return null; if (mBox == null) { mBox = new BoundingBox(); synchronized (points) { @@ -50,7 +51,7 @@ public BoundingBox getBoundingBox() { return mBox; } - public class TrackPoint extends GeoPoint { + public static class TrackPoint extends GeoPoint { public final boolean continuous; public final float elevation; public final float speed;