@@ -7,7 +7,6 @@ import android.graphics.drawable.Drawable
77import android.text.Editable
88import android.text.Layout
99import android.text.Spanned
10- import android.util.Log
1110import android.view.MotionEvent
1211import android.view.View
1312import android.view.ViewTreeObserver
@@ -111,7 +110,10 @@ class PlaceholderManager(
111110
112111 private suspend fun buildPlaceholderDrawable (adapter : PlaceholderAdapter , attrs : AztecAttributes ): Drawable {
113112 val drawable = ContextCompat .getDrawable(aztecText.context, android.R .color.transparent)!!
114- updateDrawableBounds(adapter, attrs, drawable)
113+ val editorWidth = if (aztecText.width > 0 ) {
114+ aztecText.width - aztecText.paddingStart - aztecText.paddingEnd
115+ } else aztecText.maxImagesWidth
116+ drawable.setBounds(0 , 0 , adapter.calculateWidth(attrs, editorWidth), adapter.calculateHeight(attrs, editorWidth))
115117 return drawable
116118 }
117119
@@ -318,31 +320,14 @@ class PlaceholderManager(
318320 spans.forEach {
319321 val type = it.attributes.getValue(TYPE_ATTRIBUTE )
320322 val adapter = adapters[type] ? : return @forEach
321- val start = aztecText.editableText.getSpanStart(it)
322- val end = aztecText.editableText.getSpanEnd(it)
323- val flags = aztecText.editableText.getSpanFlags(it)
324- aztecText.editableText.removeSpan(it)
325323 it.drawable = buildPlaceholderDrawable(adapter, it.attributes)
326- aztecText.editableText.setSpan(it, start, end, flags)
327324 aztecText.refreshText(false )
328325 insertInPosition(it.attributes, aztecText.editableText.getSpanStart(it))
329326 }
330327 }
331328 }
332329 }
333330
334- private suspend fun updateDrawableBounds (adapter : PlaceholderAdapter , attrs : AztecAttributes , drawable : Drawable ? ) {
335- val editorWidth = if (aztecText.width > 0 ) {
336- aztecText.width - aztecText.paddingStart - aztecText.paddingEnd
337- } else aztecText.maxImagesWidth
338- Log .d(TAG , " Updating drawable bounds - editor width: $editorWidth " )
339- if (drawable?.bounds?.right != editorWidth) {
340- Log .d(TAG , " Bounds before - right - ${drawable?.bounds?.right} - bottom - ${drawable?.bounds?.bottom} " )
341- drawable?.setBounds(0 , 0 , adapter.calculateWidth(attrs, editorWidth), adapter.calculateHeight(attrs, editorWidth))
342- Log .d(TAG , " Bounds after - right - ${drawable?.bounds?.right} - bottom - ${drawable?.bounds?.bottom} " )
343- }
344- }
345-
346331 private fun clearAllViews () {
347332 for (placeholder in positionToId) {
348333 container.findViewWithTag<View >(placeholder.uuid)?.let {
0 commit comments