Skip to content

Commit a51f76a

Browse files
committed
Use adapter height when drawing a placeholder
1 parent b77dbff commit a51f76a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

media-placeholders/src/main/java/org/wordpress/aztec/placeholders/PlaceholderManager.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,22 +160,24 @@ class PlaceholderManager(
160160
aztecText.getLocationOnScreen(parentTextViewLocation)
161161
val parentTextViewTopAndBottomOffset = aztecText.scrollY + aztecText.compoundPaddingTop
162162

163+
164+
val adapter = adapters[type]!!
165+
val height = adapter.calculateHeight(attrs, parentTextViewRect.right - parentTextViewRect.left - 20)
163166
parentTextViewRect.top += parentTextViewTopAndBottomOffset
164-
parentTextViewRect.bottom += parentTextViewTopAndBottomOffset
167+
parentTextViewRect.bottom = parentTextViewRect.top + height
165168

166169
positionToId.removeAll {
167170
it.uuid == uuid
168171
}
169172

170173
var box = container.findViewWithTag<View>(uuid)
171174
val exists = box != null
172-
val adapter = adapters[type]!!
173175
if (!exists) {
174176
box = adapter.createView(container.context, uuid, attrs)
175177
}
176178
val params = FrameLayout.LayoutParams(
177179
adapter.calculateWidth(attrs, parentTextViewRect.right - parentTextViewRect.left - 20),
178-
parentTextViewRect.bottom - parentTextViewRect.top - 20
180+
height
179181
)
180182
val padding = 10
181183
params.setMargins(

0 commit comments

Comments
 (0)