Started converting the app to a true MVVM architecture; fixed 7 month old bug that would cause substitution items to not be shown on the personal plan if they contained a question mark (e.g. 'INF7?inf999')

This commit is contained in:
Deniz Düzgören
2019-10-23 21:15:12 +02:00
parent 1a4b8ce142
commit 10033d999f
24 changed files with 658 additions and 626 deletions
@@ -2,7 +2,6 @@ package com.denizd.substitutionplan.adapters
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.SharedPreferences
import android.net.Uri
import android.text.SpannableString
import android.text.style.StrikethroughSpan
@@ -26,9 +25,9 @@ import java.util.*
* PlanFragment.kt and its subclasses
*
* @param substitutions a list of all substitutions of data type Substitution
* @param prefs a reference to the app's Shared Preferences used to get user-set colours
* @param colours a map of all user-defined colours for the individual courses
*/
internal class SubstitutionAdapter(private var substitutions: List<Substitution>, private val prefs: SharedPreferences) : RecyclerView.Adapter<SubstitutionAdapter.CardViewHolder>() {
internal class SubstitutionAdapter(private var substitutions: List<Substitution>, private val colours: Map<String, String>) : RecyclerView.Adapter<SubstitutionAdapter.CardViewHolder>() {
/**
* The ViewHolder class used by SubstitutionAdapter.kt to resolve references to views in
@@ -114,11 +113,7 @@ internal class SubstitutionAdapter(private var substitutions: List<Substitution>
View.GONE
} else {
val colourString = SubstUtil.getColourString(holder.course.text.toString())
val colourPrefsInt = if (colourString.isNotEmpty()) {
prefs.getString("card$colourString", "") ?: ""
} else {
""
}
val colourPrefsInt = colours[colourString] ?: ""
colour = SubstUtil.getColourForString(colourPrefsInt, holder.context)
cardBackgroundColour = if (colour != 0) {
colour