Skip to content

Commit

Permalink
perf: 优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
limuyang2 committed Jul 4, 2023
1 parent 405c68f commit 3a52f45
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import kotlin.math.sqrt
*
*/

class LPPSmoothCheckBox @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : View(context, attrs, defStyleAttr), Checkable {
internal class LPPSmoothCheckBox @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : View(context, attrs, defStyleAttr), Checkable {

private lateinit var mTickPaint: Paint
private lateinit var mFloorPaint: Paint
Expand Down Expand Up @@ -74,7 +74,7 @@ class LPPSmoothCheckBox @JvmOverloads constructor(context: Context, attrs: Attri

}

override fun onSaveInstanceState(): Parcelable? {
override fun onSaveInstanceState(): Parcelable {
val bundle = Bundle()
bundle.putParcelable(KEY_INSTANCE_STATE, super.onSaveInstanceState())
bundle.putBoolean(KEY_INSTANCE_STATE, isChecked)
Expand Down Expand Up @@ -135,13 +135,13 @@ class LPPSmoothCheckBox @JvmOverloads constructor(context: Context, attrs: Attri

private fun measureSize(measureSpec: Int): Int {
val defSize = dp2px(context, DEF_DRAW_SIZE.toFloat())
val specSize = View.MeasureSpec.getSize(measureSpec)
val specMode = View.MeasureSpec.getMode(measureSpec)
val specSize = MeasureSpec.getSize(measureSpec)
val specMode = MeasureSpec.getMode(measureSpec)

var result = 0
when (specMode) {
View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.AT_MOST -> result = defSize.coerceAtMost(specSize)
View.MeasureSpec.EXACTLY -> result = specSize
MeasureSpec.UNSPECIFIED, MeasureSpec.AT_MOST -> result = defSize.coerceAtMost(specSize)
MeasureSpec.EXACTLY -> result = specSize
}
return result
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 3a52f45

Please sign in to comment.