Bimba.git

commit 25689d73148b58a520b22aba401dbb38d9fc00c5

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

hopefully fixed giving up departures too fast

 app/src/main/java/ml/adamsprogs/bimba/activities/StopActivity.kt | 19 +
 app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt | 1 


diff --git a/app/src/main/java/ml/adamsprogs/bimba/activities/StopActivity.kt b/app/src/main/java/ml/adamsprogs/bimba/activities/StopActivity.kt
index af4f356de1080e93dc56549c509832a671e4ecba..03f2c61f6eb43219c44dfa164d82d4346527ca86 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/activities/StopActivity.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/activities/StopActivity.kt
@@ -56,19 +56,25 @@         sourceType = intent.getStringExtra(SOURCE_TYPE)
 
         setSupportActionBar(toolbar)
 
-        when (sourceType) {
+        val departures = when (sourceType) {
             SOURCE_TYPE_STOP -> {
                 stopSegment = StopSegment(intent.getSerializableExtra(EXTRA_STOP_ID) as AgencyAndId, null).apply { fillPlates() }
                 supportActionBar?.title = timetable.getStopName(stopSegment!!.stop)
+                null
             }
             SOURCE_TYPE_FAV -> {
                 favourite = intent.getParcelableExtra(EXTRA_FAVOURITE)
                 supportActionBar?.title = favourite!!.name
                 favourite!!.addOnVmPreparedListener(this)
+                if (favourite!!.fullDepartures.isNotEmpty())
+                    favourite!!.fullDepartures
+                else
+                    null
             }
+            else -> null
         }
 
-        sectionsPagerAdapter = SectionsPagerAdapter(supportFragmentManager, null)
+        sectionsPagerAdapter = SectionsPagerAdapter(supportFragmentManager, departures)
 
         container.adapter = sectionsPagerAdapter
 
@@ -107,7 +113,8 @@         lastUpdated = Calendar.getInstance().timeInMillis
     }
 
     override fun onVmPrepared() {
-        //fixme do we give up too fast?
+        //fixme do we give up too fast? (in testing)
+        // println("onVmPrepared: ticked? ${ticked()}; vmBacked? ${favourite!!.isBackedByVm}")
         if ((favourite!!.isBackedByVm || ticked()) && (timetableType == "departure")) {
             getFavouriteDepartures()
         }
@@ -154,14 +161,18 @@             favourite!!.registerOnVm(receiver, context)
     }
 
     override fun onVm(vmDepartures: Set<Departure>?, plateId: Plate.ID) {
-        //fixme do we give up too fast?
+        //fixme do we give up too fast? (in testing)
+        // println("onVm")
         if (vmDepartures == null && this.vmDepartures.isEmpty() && hasDepartures) {
+            // println("\tbut noVM")
             if (ticked()) {
+               //  println("\t\tbut ticked")
                 refreshAdapterFromStop()
             }
             return
         }
         if (timetableType == "departure" && stopSegment!!.contains(plateId)) {
+            // println("\tthereā€™s still vm")
             if (vmDepartures != null)
                 this.vmDepartures[plateId] = vmDepartures
             else




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 37e9fd76ff8f73dee734041f05d219d4fb26a665..469a7cdc28422e9fbc937c2e77c7fc4a59f2242b 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/models/Favourite.kt
@@ -53,7 +53,6 @@         this.cacheDir = File(parcel.readString())
         val mapDir = File(parcel.readString())
 
         val mapString = mapDir.readText()
-        val ile = mapString.length / 1024
 
         val map = HashMap<AgencyAndId, List<Departure>>()
         mapString.safeSplit("%").forEach {