Bimba.git

commit d0957e9f030f9e24f8f2f82a3c0579ddab426317

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

new support library version

%!v(PANIC=String method: strings: negative Repeat count)


diff --git a/.idea/misc.xml b/.idea/misc.xml
index ba7052b8197ddf8ba8756022d905d03055c7ad60..635999df1e86791ad3787e455b4524e4d8879b93 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -24,7 +24,7 @@         
       </value>
     </option>
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">




diff --git a/app/build.gradle b/app/build.gradle
index 82d256882bd58e17de656e717112626b8d79791d..ddb34020f421af5d25578b83df9a2e7b365efb62 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -26,10 +26,10 @@     implementation fileTree(dir: 'libs', include: ['*.jar'])
     androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
         exclude group: 'com.android.support', module: 'support-annotations'
     })
-    implementation 'com.android.support:appcompat-v7:27.0.2'
-    implementation 'com.android.support:cardview-v7:27.0.2'
-    implementation 'com.android.support:design:27.0.2'
-    implementation 'com.android.support:support-vector-drawable:27.0.2'
+    implementation 'com.android.support:appcompat-v7:27.1.0'
+    implementation 'com.android.support:cardview-v7:27.1.0'
+    implementation 'com.android.support:design:27.1.0'
+    implementation 'com.android.support:support-vector-drawable:27.1.0'
     testImplementation 'junit:junit:4.12'
     implementation 'com.android.support.constraint:constraint-layout:1.0.2'
     implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"




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 cb6051e824467c2c6afcd0a33304abfbe468d054..8d6bf18d6f6a6a0baf481c72f38273e6c6b3a1fb 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/activities/DashActivity.kt
@@ -163,9 +163,6 @@         val tomorrow = Calendar.getInstance().apply {
             this.add(Calendar.DAY_OF_MONTH, 1)
         }.toIsoDate()
 
-        println(today)
-        println(tomorrow)
-        println(validTill)
         try {
             timetable.getServiceForToday()
             if (today >= validTill) {




diff --git a/app/src/main/java/ml/adamsprogs/bimba/activities/StopSpecifyActivity.kt b/app/src/main/java/ml/adamsprogs/bimba/activities/StopSpecifyActivity.kt
index af2cc5348b570956ec639644686c79df79e8e54a..49a53ef03dfa1f546a5c110986c3249f43a6b52d 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/activities/StopSpecifyActivity.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/activities/StopSpecifyActivity.kt
@@ -44,8 +44,8 @@     }
 
     class ShedAdapter(val context: Context, val values: Map<AgencyAndId, Pair<String, Set<String>>>) :
             RecyclerView.Adapter<ShedAdapter.ViewHolder>() {
-        override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
-            val context = parent?.context
+        override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
+            val context = parent.context
             val inflater = LayoutInflater.from(context)
 
             val rowView = inflater.inflate(R.layout.row_shed, parent, false)
@@ -54,16 +54,16 @@         }
 
         override fun getItemCount(): Int = values.size
 
-        override fun onBindViewHolder(holder: ViewHolder?, position: Int) {
-            holder?.root?.setOnClickListener {
+        override fun onBindViewHolder(holder: ViewHolder, position: Int) {
+            holder.root.setOnClickListener {
                 val id = values.entries.sortedBy { it.value.first }[position].key
                 val intent = Intent(context, StopActivity::class.java)
                 intent.putExtra(StopActivity.SOURCE_TYPE, StopActivity.SOURCE_TYPE_STOP)
                 intent.putExtra(StopActivity.EXTRA_STOP_ID, id)
                 context.startActivity(intent)
             }
-            holder?.stopCode?.text = values.values.sortedBy { it.first }[position].first
-            holder?.stopHeadlines?.text = values.values.sortedBy { it.first }[position].second
+            holder.stopCode.text = values.values.sortedBy { it.first }[position].first
+            holder.stopHeadlines.text = values.values.sortedBy { it.first }[position].second
                     .sortedBy { it } // fixme<p:1> natural sort
                     .joinToString()
         }




diff --git a/app/src/main/java/ml/adamsprogs/bimba/models/DeparturesAdapter.kt b/app/src/main/java/ml/adamsprogs/bimba/models/DeparturesAdapter.kt
index d47a9ce9948e66a7f748dcf55297573e2f92ba9a..26792a4a3bd07e01b312a53c4c4efb4532c66546 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/models/DeparturesAdapter.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/models/DeparturesAdapter.kt
@@ -38,15 +38,15 @@             else -> VIEW_TYPE_CONTENT
         }
     }
 
-    override fun onBindViewHolder(holder: ViewHolder?, position: Int) {
+    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
         if (departures == null) {
             return
         }
-        val line = holder?.lineTextView
-        val time = holder?.timeTextView
-        val direction = holder?.directionTextView
+        val line = holder.lineTextView
+        val time = holder.timeTextView
+        val direction = holder.directionTextView
         if (departures.isEmpty()) {
-            time?.text = context.getString(R.string.no_departures)
+            time.text = context.getString(R.string.no_departures)
             return
         }
         val departure = departures[position]
@@ -65,20 +65,20 @@             context.getString(Declinator.decline(departureIn), departureIn.toString())
         else
             context.getString(R.string.now)
 
-        line?.text = departure.lineText
-        time?.text = timeString
-        direction?.text = context.getString(R.string.departure_to, departure.headsign)
-        val icon = holder?.typeIcon
+        line.text = departure.lineText
+        time.text = timeString
+        direction.text = context.getString(R.string.departure_to, departure.headsign)
+        val icon = holder.typeIcon
         if (departure.vm)
-            icon?.setImageDrawable(ResourcesCompat.getDrawable(context.resources, R.drawable.ic_departure_vm, context.theme))
+            icon.setImageDrawable(ResourcesCompat.getDrawable(context.resources, R.drawable.ic_departure_vm, context.theme))
         else
-            icon?.setImageDrawable(ResourcesCompat.getDrawable(context.resources, R.drawable.ic_departure_timetable, context.theme))
+            icon.setImageDrawable(ResourcesCompat.getDrawable(context.resources, R.drawable.ic_departure_timetable, context.theme))
 
         if (departure.lowFloor)
-            holder?.floorIcon?.visibility = View.VISIBLE
+            holder.floorIcon.visibility = View.VISIBLE
         if (departure.isModified) {
-            holder?.infoIcon?.visibility = View.VISIBLE
-            holder?.root?.setOnClickListener {
+            holder.infoIcon.visibility = View.VISIBLE
+            holder.root.setOnClickListener {
                 AlertDialog.Builder(context)
                         .setPositiveButton(context.getText(android.R.string.ok),
                                 { dialog: DialogInterface, _: Int -> dialog.cancel() })
@@ -89,8 +89,8 @@             }
         }
     }
 
-    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
-        val context = parent?.context
+    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
+        val context = parent.context
         val inflater = LayoutInflater.from(context)
 
         val rowView = inflater.inflate(R.layout.row_departure, parent, false)




diff --git a/app/src/main/java/ml/adamsprogs/bimba/models/FavouriteEditRowAdapter.kt b/app/src/main/java/ml/adamsprogs/bimba/models/FavouriteEditRowAdapter.kt
index 841aa4e21c7a3ee97675f16aafab2db90aadb447..d05a401a423698f043129f70e99908351a55a3b5 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/models/FavouriteEditRowAdapter.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/models/FavouriteEditRowAdapter.kt
@@ -14,27 +14,27 @@     override fun getItemCount(): Int {
         return favourite.size
     }
 
-    override fun onBindViewHolder(holder: ViewHolder?, position: Int) {
+    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
         val timetable = Timetable.getTimetable()
         val favourites = FavouriteStorage.getFavouriteStorage()
         val id = favourite.timetables.flatMap { it.plates!! }.sortedBy { "${it.line}${it.stop}"}[position]
         val plate = Plate(id,null)
         val favouriteElement = "${timetable.getStopName(plate.id.stop)} ( ${timetable.getStopCode(plate.id.stop)}):\n${timetable.getLineNumber(plate.id.line)} → ${plate.id.headsign}"
-        holder?.rowTextView?.text = favouriteElement
+        holder.rowTextView.text = favouriteElement
 //        holder?.splitButton?.setOnClickListener {
 //            favourites.detach(favourite.name, id, favouriteElement)
 //            favourite = favourites.favourites[favourite.name]!!
 //            notifyDataSetChanged()
 //        }
-        holder?.deleteButton?.setOnClickListener {
+        holder.deleteButton.setOnClickListener {
             favourites.delete(favourite.name, id)
             favourite = favourites.favourites[favourite.name]!!
             notifyDataSetChanged()
         }
     }
 
-    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
-        val context = parent?.context
+    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
+        val context = parent.context
         val inflater = LayoutInflater.from(context)
 
         val rowView = inflater.inflate(R.layout.row_favourite_edit, parent, false)




diff --git a/app/src/main/java/ml/adamsprogs/bimba/models/FavouritesAdapter.kt b/app/src/main/java/ml/adamsprogs/bimba/models/FavouritesAdapter.kt
index f9b95488b5e02ea346ef58f9646dbaf09101c512..1903991cebdc22a2fc2dc00723106fe6ac515cd7 100644
--- a/app/src/main/java/ml/adamsprogs/bimba/models/FavouritesAdapter.kt
+++ b/app/src/main/java/ml/adamsprogs/bimba/models/FavouritesAdapter.kt
@@ -51,8 +51,8 @@     }
 
     override fun getItemCount() = favourites.size
 
-    override fun onBindViewHolder(holder: ViewHolder?, position: Int) {
-        holder?.selectedOverlay?.visibility = if (isSelected(position)) View.VISIBLE else View.INVISIBLE
+    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
+        holder.selectedOverlay.visibility = if (isSelected(position)) View.VISIBLE else View.INVISIBLE
 
         thread {
             val favourite = favourites[position]!!
@@ -75,16 +75,16 @@                 nextDepartureText = context.getString(R.string.no_next_departure)
                 nextDepartureLineText = ""
             }
             (context as Activity).runOnUiThread {
-                holder?.nameTextView?.text = favourite.name
-                holder?.timeTextView?.text = nextDepartureText
-                holder?.lineTextView?.text = nextDepartureLineText
+                holder.nameTextView.text = favourite.name
+                holder.timeTextView.text = nextDepartureText
+                holder.lineTextView.text = nextDepartureLineText
                 if (nextDeparture != null) {
                     if (nextDeparture.vm)
-                        holder?.typeIcon?.setImageDrawable(ResourcesCompat.getDrawable(context.resources, R.drawable.ic_departure_vm, context.theme))
+                        holder.typeIcon.setImageDrawable(ResourcesCompat.getDrawable(context.resources, R.drawable.ic_departure_vm, context.theme))
                     else
-                        holder?.typeIcon?.setImageDrawable(ResourcesCompat.getDrawable(context.resources, R.drawable.ic_departure_timetable, context.theme))
+                        holder.typeIcon.setImageDrawable(ResourcesCompat.getDrawable(context.resources, R.drawable.ic_departure_timetable, context.theme))
                 }
-                holder?.moreButton?.setOnClickListener {
+                holder.moreButton.setOnClickListener {
                     val popup = PopupMenu(context, it)
                     val inflater = popup.menuInflater
                     popup.setOnMenuItemClickListener {
@@ -101,8 +101,8 @@             }
         }
     }
 
-    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
-        val context = parent?.context
+    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
+        val context = parent.context
         val inflater = LayoutInflater.from(context)
 
         val rowView = inflater.inflate(R.layout.row_favourite, parent, false)