Bimba.git

commit 823c0b030abe6aafd82318c320b7cb2ff1d24229

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

timetable validity warning only after hard starting

 app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt | 13 +


diff --git a/app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt b/app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt
index 01f9e43077ee55fadab86bdb766076a4d27aa11e..b3389a44b0e630c67900e4fd810e80964521eae8 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt
@@ -44,6 +44,7 @@     private lateinit var favourites: FavouriteStorage
     private lateinit var adapter: FavouritesAdapter
     private val actionModeCallback = ActionModeCallback()
     private var actionMode: ActionMode? = null
+    private var isWarned = false
 
     companion object {
         const val REQUEST_EDIT_FAVOURITE = 1
@@ -106,11 +107,11 @@                 favouritesList.visibility = View.VISIBLE
             }
         })
 
-        searchView.setOnQueryChangeListener({ oldQuery, newQuery ->
+        searchView.setOnQueryChangeListener { oldQuery, newQuery ->
             if (oldQuery != "" && newQuery == "")
                 searchView.clearSuggestions()
             filterSuggestions(newQuery)
-        })
+        }
 
         searchView.setOnSearchListener(object : FloatingSearchView.OnSearchListener {
             override fun onSuggestionClicked(searchSuggestion: SearchSuggestion) {
@@ -172,7 +173,9 @@         }
     }
 
     private fun warnTimetableValidity() {
-        //todo not on turn
+        if (isWarned)
+            return
+        isWarned = true
         if (timetable == null)
             return
         val validTill = timetable!!.getValidTill()
@@ -218,8 +221,8 @@             1 -> getString(R.string.timetable_validity_tomorrow)
             else -> return
         }
         AlertDialog.Builder(context)
-                .setPositiveButton(context.getText(android.R.string.ok),
-                        { dialog: DialogInterface, _: Int -> dialog.cancel() })
+                .setPositiveButton(context.getText(android.R.string.ok)
+                ) { dialog: DialogInterface, _: Int -> dialog.cancel() }
                 .setCancelable(true)
                 .setMessage(message)
                 .create().show()