Skip to content

Commit e2baeae

Browse files
committed
Attributes changed
1 parent c59c32e commit e2baeae

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

app/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@
195195
app:layout_constraintHorizontal_bias="0.5"
196196
app:layout_constraintStart_toStartOf="parent"
197197
app:layout_constraintTop_toTopOf="parent"
198-
app:tl_paddingRectangleFromEdge="10"
198+
app:tl_paddingRectangleFromEdge="12dp"
199199
app:tl_colorPath="@color/colorRed"
200200
app:tl_animatorDurationSec="4"
201-
app:tl_roundCornerInDp="30"
202-
app:tl_strokeWidthPath="24"
201+
app:tl_roundCornerInDp="24dp"
202+
app:tl_strokeWidthPath="8dp"
203203
app:tl_pathDirectionType="up_to_down"/>
204204

205205
</com.bvtech.toolslibrary.layouts.ExtendConstraintLayout>

toolsLibrary/src/main/java/com/bvtech/toolslibrary/widget/DrawerPathView.kt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ package com.bvtech.toolslibrary.widget;
22

33
import android.animation.ObjectAnimator
44
import android.content.Context
5-
import android.content.res.Resources
65
import android.graphics.*
76
import android.util.AttributeSet
87
import android.view.View
98
import com.bvtech.toolslibrary.R
10-
import com.bvtech.toolslibrary.widget.DrawerPathView.UiUtils.px
119
import kotlin.math.max
1210

1311
class DrawerPathView : View {
@@ -16,7 +14,7 @@ class DrawerPathView : View {
1614
private var length = 0f
1715
private var pathDirection = Path.Direction.CCW
1816
private var pathDirectionType = 1
19-
private var roundCorner = 28
17+
private var roundCorner = 28f
2018
private var pathWidth = 8f
2119
private var paddingRectangleFromEdge = 5f
2220
private var animatorDuration = 6000
@@ -38,11 +36,11 @@ class DrawerPathView : View {
3836
private fun initAttrs(attrs: AttributeSet?) {
3937
val arr = context.obtainStyledAttributes(attrs, R.styleable.WidgetAttributes)
4038
arr.let {
41-
paddingRectangleFromEdge = it.getFloat(R.styleable.WidgetAttributes_tl_paddingRectangleFromEdge, 5f)
39+
paddingRectangleFromEdge = it.getDimension(R.styleable.WidgetAttributes_tl_paddingRectangleFromEdge, 5f)
4240
animatorDuration = it.getInt(R.styleable.WidgetAttributes_tl_animatorDurationSec, 6)
4341
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)
4644
colorPath = it.getColor(R.styleable.WidgetAttributes_tl_colorPath, 0xff000000.toInt())
4745
}
4846
arr.recycle()
@@ -89,7 +87,7 @@ class DrawerPathView : View {
8987
}else if(pathDirectionType == 0){
9088
pathDirection = Path.Direction.CW
9189
}
92-
path?.addRoundRect(rectF, roundCorner.toFloat().px.toFloat(), roundCorner.toFloat().px.toFloat(), pathDirection)
90+
path?.addRoundRect(rectF, roundCorner, roundCorner, pathDirection)
9391
}
9492

9593
private fun setPaint() {
@@ -106,10 +104,4 @@ class DrawerPathView : View {
106104
paint?.let { paintT -> c.drawPath(pathT, paintT) }
107105
}
108106
}
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-
}
115107
}

toolsLibrary/src/main/res/values/attrs.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@
8383
</attr>
8484

8585
<attr name="tl_animatorDurationSec" format="integer" />
86-
<attr name="tl_paddingRectangleFromEdge" format="integer" />
87-
<attr name="tl_widthRec" format="integer" />
88-
<attr name="tl_heightRec" format="integer" />
89-
<attr name="tl_roundCornerInDp" format="integer" />
90-
<attr name="tl_strokeWidthPath" format="float" />
86+
<attr name="tl_paddingRectangleFromEdge" format="dimension" />
87+
<attr name="tl_widthRec" format="dimension" />
88+
<attr name="tl_heightRec" format="dimension" />
89+
<attr name="tl_roundCornerInDp" format="dimension" />
90+
<attr name="tl_strokeWidthPath" format="dimension" />
9191
<attr name="tl_pathDirection" format="integer" />
9292
<attr name="tl_colorPath" format="color"/>
9393
<attr name="tl_pathDirectionType">

0 commit comments

Comments
 (0)