Skip to content

Commit

Permalink
fix lint formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JeppeLeth authored Dec 17, 2020
1 parent 963689d commit cd379b0
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions slidetoact/src/main/java/com/ncorti/slidetoact/SlideToActView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -488,24 +488,30 @@ class SlideToActView @JvmOverloads constructor(
// Checking if the TextView has a Transformation method applied (e.g. AllCaps).
val textToDraw = mTextView.transformationMethod?.getTransformation(text, mTextView) ?: text
val leftOffset =
(mAreaHeight - 2 * mActualAreaMargin).toFloat() / mAreaHeight.toFloat() * mBorderRadius.toFloat() * 2
(mAreaHeight - 2 * mActualAreaMargin).toFloat() / mAreaHeight.toFloat() *
mBorderRadius.toFloat() * 2
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val maxWidth = mAreaWidth - (2 * mActualAreaWidth) - leftOffset
val textLayout = StaticLayout.Builder
.obtain(textToDraw, 0, textToDraw.length, mTextPaint, maxWidth.toInt())
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.setEllipsize(TextUtils.TruncateAt.END)
.setEllipsizedWidth(maxWidth.toInt() - mTextPaint.textSize.toInt())
.setMaxLines(max(1f, mAreaHeight / (mTextPaint.descent() - mTextPaint.ascent())).toInt())
.build()
.obtain(textToDraw, 0, textToDraw.length, mTextPaint, maxWidth.toInt())
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.setEllipsize(TextUtils.TruncateAt.END)
.setEllipsizedWidth(maxWidth.toInt() - mTextPaint.textSize.toInt())
.setMaxLines(
max(
1f,
mAreaHeight / (mTextPaint.descent() - mTextPaint.ascent())
).toInt()
)
.build()
canvas.save()

val dY = (height / 2) - (textLayout.height / 2)
val dX = (width / 2) - (textLayout.width / 2)

val mTextLeft = mActualAreaWidth + leftOffset + dX
val mTextTop = 0 + dY
val mTextRight = mAreaWidth - mActualAreaWidth - dX
val mTextRight = mAreaWidth - mActualAreaWidth - dX

canvas.translate(mTextLeft.toFloat(), mTextTop.toFloat())
canvas.translate(((mTextRight - mTextLeft) / 2).toFloat(), 0f)
Expand Down

0 comments on commit cd379b0

Please sign in to comment.