Skip to content

Commit

Permalink
Add redrawViews method to PlaceholderManager
Browse files Browse the repository at this point in the history
  • Loading branch information
planarvoid committed Nov 13, 2024
1 parent cbb43e3 commit 47331a1
Showing 1 changed file with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,24 +496,28 @@ class PlaceholderManager(
return
}
aztecText.viewTreeObserver.removeOnGlobalLayoutListener(this)
val spans = aztecText.editableText.getSpans(
0,
aztecText.editableText.length,
AztecPlaceholderSpan::class.java
)
job = redrawViews()
}
}

if (spans == null || spans.isEmpty()) {
return
}
job = launch {
clearAllViews()
spans.forEach {
val type = it.attributes.getValue(TYPE_ATTRIBUTE)
val adapter = adapters[type] ?: return@forEach
it.drawable = buildPlaceholderDrawable(adapter, it.attributes)
aztecText.refreshText(false)
insertInPosition(it.attributes, aztecText.editableText.getSpanStart(it))
}
fun redrawViews(): Job? {
val spans = aztecText.editableText.getSpans(
0,
aztecText.editableText.length,
AztecPlaceholderSpan::class.java
)

if (spans == null || spans.isEmpty()) {
return null
}
return launch {
clearAllViews()
spans.forEach {
val type = it.attributes.getValue(TYPE_ATTRIBUTE)
val adapter = adapters[type] ?: return@forEach
it.drawable = buildPlaceholderDrawable(adapter, it.attributes)
aztecText.refreshText(false)
insertInPosition(it.attributes, aztecText.editableText.getSpanStart(it))
}
}
}
Expand Down

0 comments on commit 47331a1

Please sign in to comment.