Skip to content

Commit c8c02d0

Browse files
committed
Stop using custom getLineForOffset
1 parent e8c934f commit c8c02d0

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class PlaceholderManager(
135135
val type = attrs.getValue(TYPE_ATTRIBUTE)
136136
val textViewLayout: Layout = aztecText.layout
137137
val parentTextViewRect = Rect()
138-
val targetLineOffset = getLineForOffset(targetPosition)
138+
val targetLineOffset = textViewLayout.getLineForOffset(targetPosition)
139139
if (currentPosition != null) {
140140
if (targetLineOffset != 0 && currentPosition == targetPosition) {
141141
return
@@ -177,19 +177,6 @@ class PlaceholderManager(
177177
}
178178
}
179179

180-
private fun getLineForOffset(offset: Int): Int {
181-
var counter = 0
182-
var index = 0
183-
for (line in aztecText.text.split("\n")) {
184-
counter += line.length + 1
185-
if (counter > offset) {
186-
break
187-
}
188-
index += 1
189-
}
190-
return index
191-
}
192-
193180
private fun validateAttributes(attributes: AztecAttributes): Boolean {
194181
return attributes.hasAttribute(UUID_ATTRIBUTE) &&
195182
attributes.hasAttribute(TYPE_ATTRIBUTE) &&

0 commit comments

Comments
 (0)