Timeline: add badge also when unread without notif

This commit is contained in:
ganfra 2019-09-20 18:34:58 +02:00
parent 7e29665fd0
commit b6e18e4a8f

View File

@ -114,6 +114,14 @@ class BadgeFloatingActionButton @JvmOverloads constructor(
}
}
var drawBadge: Boolean = false
set(value) {
if (field != value) {
field = value
invalidate()
}
}
init {
countStr = countStr(count)
textPaint.getTextBounds(countStr, 0, countStr.length, counterTextBounds)
@ -139,10 +147,10 @@ class BadgeFloatingActionButton @JvmOverloads constructor(
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
if (count > 0) {
if (count > 0 || drawBadge) {
canvas.drawCircle(counterBounds.centerX(), counterBounds.centerY(), counterBounds.width() / 2f, tintPaint)
}
if (count > 0) {
val textX = counterBounds.centerX() - counterTextBounds.width() / 2f - counterTextBounds.left
val textY = counterBounds.centerY() + counterTextBounds.height() / 2f - counterTextBounds.bottom
canvas.drawText(countStr, textX, textY, textPaint)