Skip to content

Commit 9467233

Browse files
committed
refactor(android): guard selection color setters against no-op writes
1 parent 4080a33 commit 9467233

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,13 @@ class EnrichedMarkdown
132132
}
133133

134134
fun setSelectionColor(color: Int?) {
135+
if (selectionColor == color) return
135136
selectionColor = color
136137
applySelectionColorsToSegments()
137138
}
138139

139140
fun setSelectionHandleColor(color: Int?) {
141+
if (selectionHandleColor == color) return
140142
selectionHandleColor = color
141143
applySelectionColorsToSegments()
142144
}

android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,13 @@ class EnrichedMarkdownText
265265
}
266266

267267
fun setSelectionColor(color: Int?) {
268+
if (selectionColor == color) return
268269
selectionColor = color
269270
applySelectionColors(selectionColor, selectionHandleColor)
270271
}
271272

272273
fun setSelectionHandleColor(color: Int?) {
274+
if (selectionHandleColor == color) return
273275
selectionHandleColor = color
274276
applySelectionColors(selectionColor, selectionHandleColor)
275277
}

0 commit comments

Comments
 (0)