Fixed duplicated week label if 'no meeting today' is first of the week, improved layout a bit

This commit is contained in:
Sylvain Berfini 2025-07-25 12:21:02 +02:00
parent 8dcb18d059
commit 670eecf0d6
3 changed files with 12 additions and 16 deletions

View file

@ -189,6 +189,10 @@ class MeetingsListViewModel
var previousModel: MeetingModel? = null
var previousModelWeekLabel = ""
var meetingForTodayFound = false
val todayWeekLabel = TimestampUtils.firstAndLastDayOfWeek(
System.currentTimeMillis(),
false
)
Log.d("$TAG There are [${sortedSource.size}] conference info in DB")
for (info: ConferenceInfo in sortedSource) {
@ -235,17 +239,12 @@ class MeetingsListViewModel
// but only add that fake meeting if filter is empty
if (!meetingForTodayFound && model.isAfterToday) {
if (filter.isEmpty()) {
val todayWeekLabel = TimestampUtils.firstAndLastDayOfWeek(
System.currentTimeMillis(),
false
)
val first = previousModelWeekLabel != todayWeekLabel
list.add(MeetingListItemModel(null, first))
meetingForTodayFound = true
// Consider next meeting is first of the week (do not count "no meeting today" as first)
previousModelWeekLabel = model.weekLabel
firstMeetingOfTheWeek = true
firstMeetingOfTheWeek = false
}
} else {
previousModelWeekLabel = model.weekLabel
@ -259,10 +258,6 @@ class MeetingsListViewModel
// If no meeting was found after today, insert "Today" fake model at the end,
// but only add that fake meeting if filter is empty
if (!meetingForTodayFound && filter.isEmpty()) {
val todayWeekLabel = TimestampUtils.firstAndLastDayOfWeek(
System.currentTimeMillis(),
false
)
val firstMeetingOfTheWeek = previousModelWeekLabel != todayWeekLabel
list.add(MeetingListItemModel(null, firstMeetingOfTheWeek))
}

View file

@ -34,7 +34,7 @@
android:textColor="?attr/color_main2_500"
android:maxLines="1"
android:ellipsize="end"
android:visibility="@{model.firstMeetingOfTheWeek ? View.VISIBLE : View.GONE}"
android:visibility="@{model.firstMeetingOfTheWeek ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintStart_toStartOf="@id/cardview"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/header_day"

View file

@ -13,6 +13,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingStart="16dp"
android:paddingEnd="16dp">
@ -28,7 +29,7 @@
android:textColor="?attr/color_main2_500"
android:maxLines="1"
android:ellipsize="end"
android:visibility="@{model.firstMeetingOfTheWeek ? View.VISIBLE : View.GONE}"
android:visibility="@{model.firstMeetingOfTheWeek ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintStart_toStartOf="@id/title"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/header_day"
@ -55,7 +56,7 @@
android:contentDescription="@null"
android:src="@drawable/shape_circle_primary_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/header_day" />
app:layout_constraintTop_toBottomOf="@id/header_day"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
@ -76,7 +77,7 @@
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginStart="24dp"
android:layout_marginEnd="5dp"
android:paddingStart="16dp"
android:text="@string/meetings_list_no_meeting_for_today"
@ -86,8 +87,8 @@
android:ellipsize="end"
app:layout_constraintStart_toEndOf="@id/header_day"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/header_day_number"
app:layout_constraintBottom_toBottomOf="@id/header_day_number"
app:layout_constraintTop_toTopOf="@id/today_background"
app:layout_constraintBottom_toBottomOf="@id/today_background"
tools:ignore="RtlSymmetry" />
</androidx.constraintlayout.widget.ConstraintLayout>