Skip to content

Commit

Permalink
Add function & attribute to set defaultThumbInsideColor
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrisvin committed Jan 3, 2020
1 parent c4459e2 commit 29bc1bb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class RubberRangePicker : View {
private var normalTrackColor: Int = 0
private var highlightTrackColor: Int = 0
private var highlightThumbOnTouchColor: Int = 0
private var defaultThumbInsideColor: Int = 0
private var dampingRatio: Float = 0f
private var stiffness: Float = 0f

Expand Down Expand Up @@ -116,6 +117,7 @@ class RubberRangePicker : View {
normalTrackColor = Color.GRAY
highlightTrackColor = 0xFF38ACEC.toInt()
highlightThumbOnTouchColor = 0xFF82CAFA.toInt()
defaultThumbInsideColor = Color.WHITE
dampingRatio = SpringForce.DAMPING_RATIO_HIGH_BOUNCY
stiffness = SpringForce.STIFFNESS_LOW

Expand Down Expand Up @@ -151,6 +153,11 @@ class RubberRangePicker : View {
R.styleable.RubberRangePicker_highlightDefaultThumbOnTouchColor,
0xFF82CAFA.toInt()
)
defaultThumbInsideColor =
typedArray.getColor(
R.styleable.RubberRangePicker_defaultThumbInsideColor,
Color.WHITE
)
dampingRatio =
typedArray.getFloat(
R.styleable.RubberRangePicker_dampingRatio,
Expand Down Expand Up @@ -283,7 +290,7 @@ class RubberRangePicker : View {
if (thumbSelected) {
paint.color = highlightThumbOnTouchColor
} else {
paint.color = Color.WHITE
paint.color = defaultThumbInsideColor
}
canvas?.drawCircle(posX, posY, drawableThumbRadius - highlightTrackWidth, paint)
paint.style = Paint.Style.STROKE
Expand Down Expand Up @@ -621,6 +628,11 @@ class RubberRangePicker : View {
invalidate()
}

fun setDefaultThumbInsideColor(value: Int) {
defaultThumbInsideColor = value
invalidate()
}

@Throws(java.lang.IllegalArgumentException::class)
fun setDampingRatio(value: Float) {
if (value < 0.0f) {
Expand Down
14 changes: 13 additions & 1 deletion rubberpicker/src/main/java/com/jem/rubberpicker/RubberSeekBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class RubberSeekBar : View {
private var normalTrackColor: Int = 0
private var highlightTrackColor: Int = 0
private var highlightThumbOnTouchColor: Int = 0
private var defaultThumbInsideColor: Int = 0
private var dampingRatio: Float = 0f
private var stiffness: Float = 0f

Expand Down Expand Up @@ -109,6 +110,7 @@ class RubberSeekBar : View {
normalTrackColor = Color.GRAY
highlightTrackColor = 0xFF38ACEC.toInt()
highlightThumbOnTouchColor = 0xFF82CAFA.toInt()
defaultThumbInsideColor = Color.WHITE
dampingRatio = SpringForce.DAMPING_RATIO_HIGH_BOUNCY
stiffness = SpringForce.STIFFNESS_LOW

Expand Down Expand Up @@ -142,6 +144,11 @@ class RubberSeekBar : View {
R.styleable.RubberSeekBar_highlightDefaultThumbOnTouchColor,
0xFF82CAFA.toInt()
)
defaultThumbInsideColor =
typedArray.getColor(
R.styleable.RubberSeekBar_defaultThumbInsideColor,
Color.WHITE
)
dampingRatio =
typedArray.getFloat(
R.styleable.RubberSeekBar_dampingRatio,
Expand Down Expand Up @@ -237,7 +244,7 @@ class RubberSeekBar : View {
if (drawableThumbSelected) {
paint.color = highlightThumbOnTouchColor
} else {
paint.color = Color.WHITE
paint.color = defaultThumbInsideColor
}
canvas?.drawCircle(thumbX, thumbY, drawableThumbRadius - highlightTrackWidth, paint)
paint.style = Paint.Style.STROKE
Expand Down Expand Up @@ -491,6 +498,11 @@ class RubberSeekBar : View {
invalidate()
}

fun setDefaultThumbInsideColor(value: Int) {
defaultThumbInsideColor = value
invalidate()
}

@Throws(java.lang.IllegalArgumentException::class)
fun setDampingRatio(value: Float) {
if (value < 0.0f) {
Expand Down
2 changes: 2 additions & 0 deletions rubberpicker/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<attr name="normalTrackColor" format="color" />
<attr name="highlightTrackColor" format="color"/>
<attr name="highlightDefaultThumbOnTouchColor" format="color"/>
<attr name="defaultThumbInsideColor" format="color"/>
<attr name="dampingRatio" format="float"/>
<attr name="stiffness" format="float"/>
<attr name="minValue" format="integer"/>
Expand All @@ -31,6 +32,7 @@
<attr name="normalTrackColor"/>
<attr name="highlightTrackColor"/>
<attr name="highlightDefaultThumbOnTouchColor"/>
<attr name="defaultThumbInsideColor"/>
<attr name="dampingRatio"/>
<attr name="stiffness"/>
<attr name="minValue"/>
Expand Down

0 comments on commit 29bc1bb

Please sign in to comment.