Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix datetext dismiss. #767

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,58 @@ class SessionsItemDecoration(
val startDateTimeText =
calcDateTimeText(position, view, shouldShowDateText(position))

if (startDateTimeText.dateText != null) {
c.drawText(
startDateTimeText.dateText.value,
startDateTimeText.dateText.positionX,
startDateTimeText.dateText.positionY,
textPaint
)
when {
startDateTimeText.dateText.value.isNotEmpty() -> {
c.drawText(
startDateTimeText.dateText.value,
startDateTimeText.dateText.positionX,
startDateTimeText.dateText.positionY,
textPaint
)

c.drawText(
startDateTimeText.startTimeText.value,
startDateTimeText.startTimeText.positionX,
startDateTimeText.startTimeText.positionY,
textPaint
)
}
visibleSessionDate -> {
when (index) {
0 -> {
c.drawText(
sessionItem.startSessionDate(),
startDateTimeText.dateText.positionX,
startDateTimeText.dateText.positionY,
textPaint
)

c.drawText(
startDateTimeText.startTimeText.value,
startDateTimeText.startTimeText.positionX,
(startDateTimeText.startTimeText.positionY + sessionTimeTextHeightInPx),
textPaint
)
}
else -> {
c.drawText(
startDateTimeText.startTimeText.value,
startDateTimeText.startTimeText.positionX,
startDateTimeText.startTimeText.positionY,
textPaint
)
}
}
}
else -> {
c.drawText(
startDateTimeText.startTimeText.value,
startDateTimeText.startTimeText.positionX,
startDateTimeText.startTimeText.positionY,
textPaint
)
}
}

c.drawText(
startDateTimeText.startTimeText.value,
startDateTimeText.startTimeText.positionX,
startDateTimeText.startTimeText.positionY,
textPaint
)
}
}

Expand Down Expand Up @@ -105,24 +142,29 @@ class SessionsItemDecoration(
} else null

// session date text
val dateText = if (shouldShowDateText) {

var sessionDateTextPositionY = view.top.coerceAtLeast(
sessionTimeTextMarginTopInPx.toInt()
) + sessionTimeTextHeightInPx
var sessionDateTextPositionY = view.top.coerceAtLeast(
sessionTimeTextMarginTopInPx.toInt()
) + sessionTimeTextHeightInPx

if (sessionItem.startSessionTime() != nextSessionItem?.startSessionTime()) {
sessionDateTextPositionY = sessionDateTextPositionY.coerceAtMost(
view.bottom.toFloat() - sessionTimeTextHeightInPx
)
}
if (sessionItem.startSessionTime() != nextSessionItem?.startSessionTime()) {
sessionDateTextPositionY = sessionDateTextPositionY.coerceAtMost(
view.bottom.toFloat() - sessionTimeTextHeightInPx
)
}

val dateText = if (shouldShowDateText) {
PositionalText(
value = sessionItem.startSessionDate(),
positionX = sessionTimeTextMarginStartInPx,
positionY = sessionDateTextPositionY
)
} else null
} else {
PositionalText(
value = "",
positionX = sessionTimeTextMarginStartInPx,
positionY = sessionDateTextPositionY
)
}

val sessionTimeTextMarginTop = if (shouldShowDateText) {
sessionTimeTextMarginTopInPx + sessionTimeTextHeightInPx
Expand All @@ -149,7 +191,7 @@ class SessionsItemDecoration(
}

private data class StartDateTimeText(
val dateText: PositionalText?,
val dateText: PositionalText,
val startTimeText: PositionalText
)

Expand Down