Replace notesIndicator by notes

This commit is contained in:
2022-04-12 15:01:12 -05:00
parent 9d4161a255
commit 7187214282
9 changed files with 37 additions and 37 deletions

View File

@@ -71,7 +71,7 @@ class CheckmarkButtonView(
invalidate()
}
var hasNotes = false
var notes = ""
set(value) {
field = value
invalidate()
@@ -179,7 +179,7 @@ class CheckmarkButtonView(
canvas.drawText(label, rect.centerX(), rect.centerY(), paint)
}
drawNotesIndicator(canvas, color, em, hasNotes)
drawNotesIndicator(canvas, color, em, notes)
}
}
}

View File

@@ -54,7 +54,7 @@ class CheckmarkPanelView(
setupButtons()
}
var notesIndicators = BooleanArray(0)
var notes = arrayOf<String>()
set(values) {
field = values
setupButtons()
@@ -84,9 +84,9 @@ class CheckmarkPanelView(
index + dataOffset < values.size -> values[index + dataOffset]
else -> UNKNOWN
}
button.hasNotes = when {
index + dataOffset < notesIndicators.size -> notesIndicators[index + dataOffset]
else -> false
button.notes = when {
index + dataOffset < notes.size -> notes[index + dataOffset]
else -> ""
}
button.color = color
button.onToggle = { value -> onToggle(timestamp, value) }

View File

@@ -124,9 +124,9 @@ class HabitCardListAdapter @Inject constructor(
val habit = cache.getHabitByPosition(position)
val score = cache.getScore(habit!!.id!!)
val checkmarks = cache.getCheckmarks(habit.id!!)
val notesIndicators = cache.getNoteIndicators(habit.id!!)
val notes = cache.getNotes(habit.id!!)
val selected = selected.contains(habit)
listView!!.bindCardView(holder, habit, score, checkmarks, notesIndicators, selected)
listView!!.bindCardView(holder, habit, score, checkmarks, notes, selected)
}
override fun onViewAttachedToWindow(holder: HabitCardViewHolder) {

View File

@@ -87,7 +87,7 @@ class HabitCardListView(
habit: Habit,
score: Double,
checkmarks: IntArray,
notesIndicators: BooleanArray,
notes: Array<String>,
selected: Boolean
): View {
val cardView = holder.itemView as HabitCardView
@@ -99,7 +99,7 @@ class HabitCardListView(
cardView.score = score
cardView.unit = habit.unit
cardView.threshold = habit.targetValue / habit.frequency.denominator
cardView.notesIndicators = notesIndicators
cardView.notes = notes
val detector = GestureDetector(context, CardViewGestureDetector(holder))
cardView.setOnTouchListener { _, ev ->

View File

@@ -121,11 +121,11 @@ class HabitCardView(
numberPanel.threshold = value
}
var notesIndicators
get() = checkmarkPanel.notesIndicators
var notes
get() = checkmarkPanel.notes
set(values) {
checkmarkPanel.notesIndicators = values
numberPanel.notesIndicators = values
checkmarkPanel.notes = values
numberPanel.notes = values
}
var checkmarkPanel: CheckmarkPanelView

View File

@@ -102,7 +102,7 @@ class NumberButtonView(
field = value
invalidate()
}
var hasNotes = false
var notes = ""
set(value) {
field = value
invalidate()
@@ -221,7 +221,7 @@ class NumberButtonView(
canvas.drawText(units, rect.centerX(), rect.centerY(), pUnit)
}
drawNotesIndicator(canvas, color, em, hasNotes)
drawNotesIndicator(canvas, color, em, notes)
}
}
}

View File

@@ -72,7 +72,7 @@ class NumberPanelView(
setupButtons()
}
var notesIndicators = BooleanArray(0)
var notes = arrayOf<String>()
set(values) {
field = values
setupButtons()
@@ -96,9 +96,9 @@ class NumberPanelView(
index + dataOffset < values.size -> values[index + dataOffset]
else -> 0.0
}
button.hasNotes = when {
index + dataOffset < notesIndicators.size -> notesIndicators[index + dataOffset]
else -> false
button.notes = when {
index + dataOffset < notes.size -> notes[index + dataOffset]
else -> ""
}
button.color = color
button.targetType = targetType

View File

@@ -202,10 +202,10 @@ fun View.sp(value: Float) = InterfaceUtils.spToPixels(context, value)
fun View.dp(value: Float) = InterfaceUtils.dpToPixels(context, value)
fun View.str(id: Int) = resources.getString(id)
fun View.drawNotesIndicator(canvas: Canvas, color: Int, size: Float, hasNotes: Boolean) {
fun View.drawNotesIndicator(canvas: Canvas, color: Int, size: Float, notes: String) {
val pNotesIndicator = Paint()
pNotesIndicator.color = color
if (hasNotes) {
if (notes.isNotBlank()) {
val cy = 0.8f * size
canvas.drawCircle(width.toFloat() - cy, cy, 8f, pNotesIndicator)
}