Bimba.git

commit 309e91ead809585567b6b6752d860bf45011a074

Author: Adam Pioterek <adam.pioterek@protonmail.ch>

not crash Favourites when no valid timetable

 app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt | 8 ++++++--


diff --git a/app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt b/app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt
index f7251ffdfadd9cb15bd004a83788ed66aca34290..95e06d891e869f55f662beab1a639106dee8caf0 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt
@@ -54,7 +54,7 @@         }
         this.fullDepartures = map
     }
 
-    constructor(name :String, segments: HashSet<StopSegment>, cache:Map<AgencyAndId, List<Departure>>) {
+    constructor(name: String, segments: HashSet<StopSegment>, cache: Map<AgencyAndId, List<Departure>>) {
         this.fullDepartures = cache
         this.name = name
         this.segments = segments
@@ -161,7 +161,11 @@         }
 
         val full = fullTimetable()
 
-        val twoDayDepartures = Departure.rollDepartures(full)[timetable.getServiceForToday()]
+        val twoDayDepartures = try {
+            Departure.rollDepartures(full)[timetable.getServiceForToday()]
+        } catch (e: IllegalArgumentException) {
+            listOf<Departure>()
+        }
 
         if (twoDayDepartures?.isEmpty() != false)
             return null