[Home/Timetable] Add click listener to timetable card.

This commit is contained in:
Kacper Ziubryniewicz 2019-11-26 22:56:43 +01:00
parent ca3b6d0705
commit 6d8960f089

View File

@ -4,6 +4,7 @@
package pl.szczodrzynski.edziennik.ui.modules.home.cards package pl.szczodrzynski.edziennik.ui.modules.home.cards
import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -48,6 +49,7 @@ class HomeTimetableCard(
private lateinit var b: CardHomeTimetableBinding private lateinit var b: CardHomeTimetableBinding
private val today = Date.getToday() private val today = Date.getToday()
private var timetableDate: Date = Date.getToday()
private val searchEnd = today.clone().stepForward(0, 0, 7) private val searchEnd = today.clone().stepForward(0, 0, 7)
private var allLessons = listOf<LessonFull>() private var allLessons = listOf<LessonFull>()
@ -89,6 +91,12 @@ class HomeTimetableCard(
allLessons = it allLessons = it
update() update()
}) })
b.root.setOnClickListener {
activity.loadTarget(MainActivity.DRAWER_ITEM_TIMETABLE, Bundle().apply {
putString("timetableDate", timetableDate.stringY_m_d)
})
}
} }
private fun update() { launch { private fun update() { launch {
@ -122,7 +130,8 @@ class HomeTimetableCard(
} }
timetableDate timetableDate
} }
val timetableDate = deferred.await()
timetableDate = deferred.await()
val isToday = today == timetableDate val isToday = today == timetableDate
@ -266,4 +275,4 @@ class HomeTimetableCard(
} }
override fun unbind(position: Int, holder: HomeCardAdapter.ViewHolder) = Unit override fun unbind(position: Int, holder: HomeCardAdapter.ViewHolder) = Unit
} }