@@ -212,7 +212,10 @@ class PlaceholderManager(
212212
213213 private suspend fun buildPlaceholderDrawable (adapter : PlaceholderAdapter , attrs : AztecAttributes ): Drawable {
214214 val drawable = ContextCompat .getDrawable(aztecText.context, android.R .color.transparent)!!
215- updateDrawableBounds(adapter, attrs, drawable)
215+ val editorWidth = if (aztecText.width > 0 ) {
216+ aztecText.width - aztecText.paddingStart - aztecText.paddingEnd
217+ } else aztecText.maxImagesWidth
218+ drawable.setBounds(0 , 0 , adapter.calculateWidth(attrs, editorWidth), adapter.calculateHeight(attrs, editorWidth))
216219 return drawable
217220 }
218221
@@ -441,23 +444,14 @@ class PlaceholderManager(
441444 spans.forEach {
442445 val type = it.attributes.getValue(TYPE_ATTRIBUTE )
443446 val adapter = adapters[type] ? : return @forEach
444- updateDrawableBounds (adapter, it.attributes, it.drawable )
447+ it.drawable = buildPlaceholderDrawable (adapter, it.attributes)
445448 aztecText.refreshText(false )
446449 insertInPosition(it.attributes, aztecText.editableText.getSpanStart(it))
447450 }
448451 }
449452 }
450453 }
451454
452- private suspend fun updateDrawableBounds (adapter : PlaceholderAdapter , attrs : AztecAttributes , drawable : Drawable ? ) {
453- val editorWidth = if (aztecText.width > 0 ) {
454- aztecText.width - aztecText.paddingStart - aztecText.paddingEnd - EDITOR_INNER_PADDING
455- } else aztecText.maxImagesWidth
456- if (drawable?.bounds?.right != editorWidth) {
457- drawable?.setBounds(0 , 0 , adapter.calculateWidth(attrs, editorWidth), adapter.calculateHeight(attrs, editorWidth))
458- }
459- }
460-
461455 private suspend fun clearAllViews () {
462456 positionToIdMutex.withLock {
463457 for (placeholder in positionToId) {
@@ -595,6 +589,7 @@ class PlaceholderManager(
595589 data class Placeholder (val elementPosition : Int , val uuid : String )
596590
597591 companion object {
592+ private const val TAG = " PlaceholderManager"
598593 private const val DEFAULT_HTML_TAG = " placeholder"
599594 private const val UUID_ATTRIBUTE = " uuid"
600595 private const val TYPE_ATTRIBUTE = " type"
0 commit comments