mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 12:56:45 -06:00
[Dialog/Day] Add showing lessons count and length.
This commit is contained in:
parent
06d252e4ca
commit
af8bda9e92
@ -14,6 +14,7 @@ import kotlinx.android.synthetic.main.row_lesson_change_item.view.*
|
||||
import kotlinx.android.synthetic.main.row_teacher_absence_item.view.*
|
||||
import kotlinx.coroutines.*
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
|
||||
import pl.szczodrzynski.edziennik.databinding.DialogDayBinding
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.event.EventDetailsDialog
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.event.EventListAdapter
|
||||
@ -22,6 +23,7 @@ import pl.szczodrzynski.edziennik.ui.dialogs.lessonchange.LessonChangeDialog
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.teacherabsence.TeacherAbsenceDialog
|
||||
import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||
import pl.szczodrzynski.edziennik.utils.models.Week
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
@ -83,6 +85,27 @@ class DayDialog(
|
||||
date.formattedString
|
||||
)
|
||||
|
||||
val lessons = withContext(Dispatchers.Default) {
|
||||
app.db.timetableDao().getForDateNow(profileId, date)
|
||||
}.filter { it.type != Lesson.TYPE_NO_LESSONS }
|
||||
|
||||
if (lessons.isNotEmpty()) { run {
|
||||
val startTime = lessons.first().startTime ?: return@run
|
||||
val endTime = lessons.last().endTime ?: return@run
|
||||
val diff = Time.diff(startTime, endTime)
|
||||
|
||||
b.lessonsInfo.setText(
|
||||
R.string.dialog_day_lessons_info,
|
||||
startTime.stringHM,
|
||||
endTime.stringHM,
|
||||
lessons.size.toString(),
|
||||
diff.hour.toString(),
|
||||
diff.minute.toString()
|
||||
)
|
||||
|
||||
b.lessonsInfo.visibility = View.VISIBLE
|
||||
}}
|
||||
|
||||
val lessonChanges = withContext(Dispatchers.Default) {
|
||||
app.db.timetableDao().getChangesForDateNow(profileId, date)
|
||||
}
|
||||
|
@ -26,10 +26,24 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:textAppearance="@style/NavView.TextView.Title"
|
||||
android:textIsSelectable="true"
|
||||
tools:text="wtorek, 17 grudnia" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lessonsInfo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:textAppearance="@style/NavView.TextView.Helper"
|
||||
android:textIsSelectable="true"
|
||||
android:visibility="gone"
|
||||
tools:text="8:00 - 14:20 (7 lekcji, 6 godzin, 20 minut)"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/lessonChangeLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -959,4 +959,5 @@
|
||||
<string name="dialog_grades_config_color_by_value">By grade\'s value</string>
|
||||
<string name="other">Other</string>
|
||||
<string name="menu_grades_config">Grades settings</string>
|
||||
<string name="dialog_day_lessons_info">%s - %s (%s lessons - %s hours %s minutes)</string>
|
||||
</resources>
|
||||
|
@ -1181,4 +1181,5 @@
|
||||
<string name="notification_user_action_required_title">Wymagane działanie w aplikacji</string>
|
||||
<string name="notification_user_action_required_text">Problem, który uniemożliwia synchronizację musi być rozwiązany przez użytkownika. Kliknij, aby uzyskać więcej informacji.</string>
|
||||
<string name="notification_user_action_required_captcha_librus">Librus: wymagane rozwiązanie zadania Captcha. Kliknij, aby kontynuować logowanie do dziennika.</string>
|
||||
<string name="dialog_day_lessons_info">%s - %s (%s lekcji - %s godzin %s minut)</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user