fix autoellipsize of large text

commit_hash:e7c384090f3ca934a19ab434fe69e3f1b91e5038
This commit is contained in:
gulevsky
2025-01-15 19:36:00 +03:00
parent 56ceefc35c
commit ccfb9b79d7
@@ -1,6 +1,7 @@
package com.yandex.div.internal.widget
import android.view.ViewTreeObserver
import com.yandex.div.internal.KLog
/**
* Helper to calculate and update max lines for given [textView].
@@ -43,7 +44,8 @@ internal class AutoEllipsizeHelper(private val textView: EllipsizedTextView) {
val lastVisibleLine = lineAt(textHeight)
if (textHeight >= textHeight(lastVisibleLine + 1)) lastVisibleLine + 1 else lastVisibleLine
}
if (visibleLineCount < textView.lineCount) {
if (visibleLineCount > 0 && visibleLineCount < textView.lineCount) {
KLog.d(TAG) { "Trying to set new max lines $visibleLineCount. Current drawing pass is canceled. " }
textView.maxLines = visibleLineCount
false
} else {
@@ -60,4 +62,8 @@ internal class AutoEllipsizeHelper(private val textView: EllipsizedTextView) {
preDrawListener = null
}
}
private companion object {
const val TAG = "AutoEllipsizeHelper"
}
}