Skip to content

Commit c7bd4da

Browse files
authored
Merge pull request #998 from wordpress-mobile/fix/issue-with-placeholder-height
Use adapter height when drawing a placeholder
2 parents b77dbff + fd2b3b2 commit c7bd4da

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

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

163+
val adapter = adapters[type]!!
164+
val windowWidth = parentTextViewRect.right - parentTextViewRect.left - 20
165+
val height = adapter.calculateHeight(attrs, windowWidth)
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(
177-
adapter.calculateWidth(attrs, parentTextViewRect.right - parentTextViewRect.left - 20),
178-
parentTextViewRect.bottom - parentTextViewRect.top - 20
179+
adapter.calculateWidth(attrs, windowWidth) - 20,
180+
height - 20
179181
)
180182
val padding = 10
181183
params.setMargins(
182184
parentTextViewRect.left + padding + aztecText.paddingStart,
183185
parentTextViewRect.top + padding,
184-
parentTextViewRect.right - padding - aztecText.paddingEnd,
186+
0,
185187
0
186188
)
187189
box.layoutParams = params

0 commit comments

Comments
 (0)