Skip to content

Commit

Permalink
cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
tsynik committed Apr 19, 2024
1 parent 17849d5 commit a848365
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/src/main/java/ru/yourok/torrserve/utils/CImageSpan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.graphics.Paint
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.text.style.ImageSpan
import androidx.annotation.NonNull
import java.lang.ref.WeakReference

class CImageSpan(dr: Drawable) : ImageSpan(dr) {
Expand All @@ -16,14 +15,14 @@ class CImageSpan(dr: Drawable) : ImageSpan(dr) {
val pfm = paint.fontMetricsInt
if (fm != null) {
fm.ascent = -rect.height() / 2 + pfm.ascent / 2
fm.descent = Math.max(0, rect.height() / 2 + pfm.ascent / 2)
fm.descent = 0.coerceAtLeast(rect.height() / 2 + pfm.ascent / 2)
fm.top = fm.ascent
fm.bottom = fm.descent
}
return rect.right
}

override fun draw(canvas: Canvas, text: CharSequence?, start: Int, end: Int, x: Float, top: Int, y: Int, bottom: Int, @NonNull paint: Paint) {
override fun draw(canvas: Canvas, text: CharSequence?, start: Int, end: Int, x: Float, top: Int, y: Int, bottom: Int, paint: Paint) {
val b = cachedDrawable!!
canvas.save()
val transY = (bottom + top) / 2 - b.bounds.height() / 2
Expand Down

0 comments on commit a848365

Please sign in to comment.