@@ -2,12 +2,10 @@ package com.bvtech.toolslibrary.widget;
2
2
3
3
import android.animation.ObjectAnimator
4
4
import android.content.Context
5
- import android.content.res.Resources
6
5
import android.graphics.*
7
6
import android.util.AttributeSet
8
7
import android.view.View
9
8
import com.bvtech.toolslibrary.R
10
- import com.bvtech.toolslibrary.widget.DrawerPathView.UiUtils.px
11
9
import kotlin.math.max
12
10
13
11
class DrawerPathView : View {
@@ -16,7 +14,7 @@ class DrawerPathView : View {
16
14
private var length = 0f
17
15
private var pathDirection = Path .Direction .CCW
18
16
private var pathDirectionType = 1
19
- private var roundCorner = 28
17
+ private var roundCorner = 28f
20
18
private var pathWidth = 8f
21
19
private var paddingRectangleFromEdge = 5f
22
20
private var animatorDuration = 6000
@@ -38,11 +36,11 @@ class DrawerPathView : View {
38
36
private fun initAttrs (attrs : AttributeSet ? ) {
39
37
val arr = context.obtainStyledAttributes(attrs, R .styleable.WidgetAttributes )
40
38
arr.let {
41
- paddingRectangleFromEdge = it.getFloat (R .styleable.WidgetAttributes_tl_paddingRectangleFromEdge , 5f )
39
+ paddingRectangleFromEdge = it.getDimension (R .styleable.WidgetAttributes_tl_paddingRectangleFromEdge , 5f )
42
40
animatorDuration = it.getInt(R .styleable.WidgetAttributes_tl_animatorDurationSec , 6 )
43
41
pathDirectionType = it.getInt(R .styleable.WidgetAttributes_tl_pathDirectionType , 1 )
44
- roundCorner = it.getInt (R .styleable.WidgetAttributes_tl_roundCornerInDp , 28 )
45
- pathWidth = it.getFloat (R .styleable.WidgetAttributes_tl_strokeWidthPath , 8f )
42
+ roundCorner = it.getDimension (R .styleable.WidgetAttributes_tl_roundCornerInDp , 28f )
43
+ pathWidth = it.getDimension (R .styleable.WidgetAttributes_tl_strokeWidthPath , 8f )
46
44
colorPath = it.getColor(R .styleable.WidgetAttributes_tl_colorPath , 0xff000000 .toInt())
47
45
}
48
46
arr.recycle()
@@ -89,7 +87,7 @@ class DrawerPathView : View {
89
87
}else if (pathDirectionType == 0 ){
90
88
pathDirection = Path .Direction .CW
91
89
}
92
- path?.addRoundRect(rectF, roundCorner.toFloat().px.toFloat() , roundCorner.toFloat().px.toFloat() , pathDirection)
90
+ path?.addRoundRect(rectF, roundCorner, roundCorner, pathDirection)
93
91
}
94
92
95
93
private fun setPaint () {
@@ -106,10 +104,4 @@ class DrawerPathView : View {
106
104
paint?.let { paintT -> c.drawPath(pathT, paintT) }
107
105
}
108
106
}
109
-
110
- object UiUtils {
111
- val Float .dp: Int get() = (this / Resources .getSystem().displayMetrics.density).toInt()
112
- val Float .px: Int get() = (this * Resources .getSystem().displayMetrics.density).toInt()
113
- fun getWidthDisplayScreenSize () = Resources .getSystem().displayMetrics.widthPixels
114
- }
115
107
}
0 commit comments