Archived
Changed filter chip colour, but when pressed, the primary colour needs to be changed to a more desaturated tint
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
package com.denizk0461.studip.adapter
|
||||
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.denizk0461.studip.databinding.ItemScrollablePageBinding
|
||||
import com.denizk0461.studip.model.CanteenOffer
|
||||
import com.denizk0461.studip.model.CanteenOfferGroup
|
||||
import com.denizk0461.studip.model.CanteenOfferGroupElement
|
||||
|
||||
class CanteenOfferPageAdapter(private var offers: List<CanteenOfferGroup>, private var daysCovered: Int, private var prefsRegex: Regex) : RecyclerView.Adapter<CanteenOfferPageAdapter.CanteenOfferPageViewHolder>() {
|
||||
|
||||
@@ -31,15 +28,6 @@ class CanteenOfferPageAdapter(private var offers: List<CanteenOfferGroup>, priva
|
||||
|
||||
layoutManager = LinearLayoutManager(holder.binding.root.context, LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
// TODO second filter needs to be worked on; it shouldn't filter out something if two options are selected and only one is met
|
||||
// Log.d("eek!5", prefsRegex.toString())
|
||||
|
||||
// .filter { it.dietaryPreferences == prefs.deconstruct() }
|
||||
|
||||
// val filtered2 = filtered
|
||||
// offers
|
||||
|
||||
|
||||
adapter = CanteenOfferItemAdapter(offers.filter { it.dateId == position }) // TODO check if empty
|
||||
scheduleLayoutAnimation()
|
||||
}
|
||||
@@ -50,12 +38,4 @@ class CanteenOfferPageAdapter(private var offers: List<CanteenOfferGroup>, priva
|
||||
offers = items
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun refreshView(prefsRegex: Regex) {
|
||||
this.prefsRegex = prefsRegex
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
// private fun constructRegex(pref: String): String =
|
||||
// pref.replace('f', '.')
|
||||
}
|
||||
@@ -4,52 +4,23 @@ import com.denizk0461.studip.R
|
||||
|
||||
object Misc {
|
||||
|
||||
// val events: Array<StudIPEvent> = arrayOf(
|
||||
// StudIPEvent(1, "Literatures", "Nittel", "MZH 1380/1400", 0, 3, 1),
|
||||
// StudIPEvent(2, "Linguistics", "Du Bois", "SFG 1020", 1, 1, 1),
|
||||
// StudIPEvent(3, "System Erde", "Zolitschka, Labuhn-Deroubaix", "GW2 B1410", 1, 3, 1),
|
||||
// StudIPEvent(4, "Key Moments", "Esders-Angermund", "GW2 B2890", 2, 2, 1),
|
||||
// StudIPEvent(5, "ULS-1", "Herrmann", "GW2 B2890", 2, 3, 1),
|
||||
// StudIPEvent(6, "Gesellschaft und Raum", "Lossau, Mossig", "GW2 B1820", 3, 1, 1),
|
||||
// StudIPEvent(7, "Gesellschaft und Raum2", "Lossau, Mossig", "GW2 B1820", 4, 4, 2),
|
||||
// )
|
||||
|
||||
private val timeslotStartMap: Map<String, Int> = mapOf(
|
||||
"6:00" to 0,
|
||||
"6:15" to 0,
|
||||
"8:00" to 1,
|
||||
"8:15" to 1,
|
||||
"10:00" to 2,
|
||||
"10:15" to 2,
|
||||
"12:00" to 3,
|
||||
"12:15" to 3,
|
||||
"14:00" to 4,
|
||||
"14:15" to 4,
|
||||
"16:00" to 5,
|
||||
"16:15" to 5,
|
||||
"18:00" to 6,
|
||||
"18:15" to 6,
|
||||
"20:00" to 7,
|
||||
"20:15" to 7,
|
||||
)
|
||||
|
||||
private val timeslotEndMap: Map<String, Int> = mapOf(
|
||||
"8:00" to 0,
|
||||
"7:45" to 0,
|
||||
"10:00" to 1,
|
||||
"9:45" to 1,
|
||||
"12:00" to 2,
|
||||
"11:45" to 2,
|
||||
"14:00" to 3,
|
||||
"13:45" to 3,
|
||||
"16:00" to 4,
|
||||
"15:45" to 4,
|
||||
"18:00" to 5,
|
||||
"17:45" to 5,
|
||||
"20:00" to 6,
|
||||
"19:45" to 6,
|
||||
"22:00" to 7,
|
||||
"21:45" to 7,
|
||||
private val timeslotAcademicQuarter = mapOf(
|
||||
"6:00" to "6:15",
|
||||
"8:00" to "7:45",
|
||||
"8:00" to "8:15",
|
||||
"10:00" to "9:45",
|
||||
"10:00" to "10:15",
|
||||
"12:00" to "11:45",
|
||||
"12:00" to "12:15",
|
||||
"14:00" to "13:45",
|
||||
"14:00" to "14:15",
|
||||
"16:00" to "15:45",
|
||||
"16:00" to "16:15",
|
||||
"18:00" to "17:45",
|
||||
"18:00" to "18:15",
|
||||
"20:00" to "19:45",
|
||||
"20:00" to "20:15",
|
||||
"22:00" to "21:45",
|
||||
)
|
||||
|
||||
val indexToDrawable: Map<Int, Int> = mapOf(
|
||||
@@ -66,12 +37,5 @@ object Misc {
|
||||
10 to R.drawable.circle,
|
||||
)
|
||||
|
||||
fun parseTimeslot(time: String): Pair<Int, Int> {
|
||||
val splitTime = time.split(" - ")
|
||||
val start = timeslotStartMap[splitTime[0]] ?: 0
|
||||
val length = (timeslotEndMap[splitTime[1]] ?: 0)
|
||||
return Pair(start, length)
|
||||
}
|
||||
|
||||
val mysteryLink = "https://www.youtube.com/watch?v=nhIQMCXJzLI"
|
||||
const val mysteryLink = "https://www.youtube.com/watch?v=nhIQMCXJzLI"
|
||||
}
|
||||
@@ -88,7 +88,6 @@ class CanteenFragment : Fragment() {
|
||||
dates = groupedElements.map { it.date }.distinct()
|
||||
createTabLayoutMediator()
|
||||
|
||||
// this.groupedElements = groupedElements
|
||||
this.dateSize = dates.size
|
||||
|
||||
viewPagerAdapter.setNewItems(groupedElements, dates.size)
|
||||
@@ -121,15 +120,12 @@ class CanteenFragment : Fragment() {
|
||||
|
||||
private fun setPreference(pref: DietaryPreferences, newValue: Boolean) {
|
||||
viewModel.setPreference(pref, newValue)
|
||||
// viewPagerAdapter.refreshView(getPrefRegex())
|
||||
viewPagerAdapter.setNewItems(elements.groupElements().distinct(), dateSize)
|
||||
}
|
||||
|
||||
private fun getPreference(pref: DietaryPreferences): Boolean =
|
||||
viewModel.getPreference(pref)
|
||||
|
||||
// private data class RegexF(val index: Int)
|
||||
|
||||
private fun getPrefRegex(): Regex {
|
||||
val prefs = viewModel.getDietaryPrefs().deconstruct().replace('f', '.')
|
||||
|
||||
@@ -163,20 +159,10 @@ class CanteenFragment : Fragment() {
|
||||
this
|
||||
} else {
|
||||
this.filter {
|
||||
// Log.d("eek!5", "${it.title}: - ${prefsRegex} vs ${it.dietaryPreferences}")
|
||||
prefsRegex.matches(it.dietaryPreferences)
|
||||
}
|
||||
}
|
||||
|
||||
// Log.d("eek!6", "preference: $prefsRegex, list: $filteredForPreferences")
|
||||
|
||||
// val a = filteredForPreferences.map {
|
||||
// CanteenOfferGroupElement(
|
||||
// it.title,
|
||||
// it.price,
|
||||
// it.dietaryPreferences,
|
||||
// )
|
||||
// }
|
||||
val b = filteredForPreferences.map { offer ->
|
||||
CanteenOfferGroup(
|
||||
offer.date,
|
||||
@@ -196,6 +182,4 @@ class CanteenFragment : Fragment() {
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// private fun Regex.matchesAny
|
||||
}
|
||||
Reference in New Issue
Block a user