Timeline: add badge also when unread without notif
This commit is contained in:
parent
7e29665fd0
commit
b6e18e4a8f
@ -114,6 +114,14 @@ class BadgeFloatingActionButton @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var drawBadge: Boolean = false
|
||||||
|
set(value) {
|
||||||
|
if (field != value) {
|
||||||
|
field = value
|
||||||
|
invalidate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
countStr = countStr(count)
|
countStr = countStr(count)
|
||||||
textPaint.getTextBounds(countStr, 0, countStr.length, counterTextBounds)
|
textPaint.getTextBounds(countStr, 0, countStr.length, counterTextBounds)
|
||||||
@ -139,10 +147,10 @@ class BadgeFloatingActionButton @JvmOverloads constructor(
|
|||||||
|
|
||||||
override fun onDraw(canvas: Canvas) {
|
override fun onDraw(canvas: Canvas) {
|
||||||
super.onDraw(canvas)
|
super.onDraw(canvas)
|
||||||
|
if (count > 0 || drawBadge) {
|
||||||
if (count > 0) {
|
|
||||||
canvas.drawCircle(counterBounds.centerX(), counterBounds.centerY(), counterBounds.width() / 2f, tintPaint)
|
canvas.drawCircle(counterBounds.centerX(), counterBounds.centerY(), counterBounds.width() / 2f, tintPaint)
|
||||||
|
}
|
||||||
|
if (count > 0) {
|
||||||
val textX = counterBounds.centerX() - counterTextBounds.width() / 2f - counterTextBounds.left
|
val textX = counterBounds.centerX() - counterTextBounds.width() / 2f - counterTextBounds.left
|
||||||
val textY = counterBounds.centerY() + counterTextBounds.height() / 2f - counterTextBounds.bottom
|
val textY = counterBounds.centerY() + counterTextBounds.height() / 2f - counterTextBounds.bottom
|
||||||
canvas.drawText(countStr, textX, textY, textPaint)
|
canvas.drawText(countStr, textX, textY, textPaint)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user