File tree Expand file tree Collapse file tree 1 file changed +21
-17
lines changed
media-placeholders/src/main/java/org/wordpress/aztec/placeholders Expand file tree Collapse file tree 1 file changed +21
-17
lines changed Original file line number Diff line number Diff line change @@ -496,24 +496,28 @@ class PlaceholderManager(
496496 return
497497 }
498498 aztecText.viewTreeObserver.removeOnGlobalLayoutListener(this )
499- val spans = aztecText.editableText.getSpans(
500- 0 ,
501- aztecText.editableText.length,
502- AztecPlaceholderSpan ::class .java
503- )
499+ job = redrawViews()
500+ }
501+ }
504502
505- if (spans == null || spans.isEmpty()) {
506- return
507- }
508- job = launch {
509- clearAllViews()
510- spans.forEach {
511- val type = it.attributes.getValue(TYPE_ATTRIBUTE )
512- val adapter = adapters[type] ? : return @forEach
513- it.drawable = buildPlaceholderDrawable(adapter, it.attributes)
514- aztecText.refreshText(false )
515- insertInPosition(it.attributes, aztecText.editableText.getSpanStart(it))
516- }
503+ fun redrawViews (): Job ? {
504+ val spans = aztecText.editableText.getSpans(
505+ 0 ,
506+ aztecText.editableText.length,
507+ AztecPlaceholderSpan ::class .java
508+ )
509+
510+ if (spans == null || spans.isEmpty()) {
511+ return null
512+ }
513+ return launch {
514+ clearAllViews()
515+ spans.forEach {
516+ val type = it.attributes.getValue(TYPE_ATTRIBUTE )
517+ val adapter = adapters[type] ? : return @forEach
518+ it.drawable = buildPlaceholderDrawable(adapter, it.attributes)
519+ aztecText.refreshText(false )
520+ insertInPosition(it.attributes, aztecText.editableText.getSpanStart(it))
517521 }
518522 }
519523 }
You can’t perform that action at this time.
0 commit comments