@@ -6,9 +6,10 @@ import android.view.View
66import android.widget.*
77import ir.neo.stepbarview.DpHandler
88import ir.neo.stepbarview.StepBarView
9+ import ir.neo.stepbarview.StepBarView.StepsTitleSetter
10+ import kotlinx.android.synthetic.main.activity_main.*
911
1012class MainActivity : AppCompatActivity () ,SeekBar.OnSeekBarChangeListener{
11- lateinit var myStepBarView : StepBarView
1213 lateinit var sbAttrsValue: SeekBar
1314 lateinit var spActions : Spinner
1415 lateinit var tvValue : TextView
@@ -20,8 +21,7 @@ class MainActivity : AppCompatActivity() ,SeekBar.OnSeekBarChangeListener{
2021 setContentView(R .layout.activity_main)
2122
2223
23- myStepBarView = findViewById(R .id.my_stepBarView4)
24- myStepBarView.allowSelectStep = object : StepBarView .AllowSelectStep {
24+ my_stepBarView4.allowSelectStep = object : StepBarView .AllowSelectStep {
2525 override fun allowSelectStep (step : Int ) = step != 2
2626 }
2727
@@ -31,6 +31,27 @@ class MainActivity : AppCompatActivity() ,SeekBar.OnSeekBarChangeListener{
3131
3232
3333 initSpinner()
34+ initStepNames()
35+ }
36+
37+ private fun initStepNames () {
38+ my_stepBarView1.stepsTitleSetter = object : StepsTitleSetter {
39+ override fun getStepTitle (step : Int ): String {
40+ return when (step) {
41+ 1 -> " Fist"
42+ 2 -> " Second"
43+ 3 -> " Third"
44+ 4 -> " Fourth"
45+ 5 -> " Fifth"
46+ 6 -> " Sixth"
47+ 7 -> " Seventh"
48+ 8 -> " Eighth"
49+ 9 -> " Ninth"
50+ 10 -> " Tenth"
51+ else -> " Non"
52+ }
53+ }
54+ }
3455 }
3556
3657 private fun initSpinner () {
@@ -59,7 +80,7 @@ class MainActivity : AppCompatActivity() ,SeekBar.OnSeekBarChangeListener{
5980 }
6081
6182 spActions.setSelection(0 )
62- refreshValueText(myStepBarView .maxCount)
83+ refreshValueText(my_stepBarView4 .maxCount)
6384 }
6485
6586
@@ -68,37 +89,37 @@ class MainActivity : AppCompatActivity() ,SeekBar.OnSeekBarChangeListener{
6889 when (actionsList[position]){
6990 " sbv_max_count" -> {
7091 sbAttrsValue.max = 20
71- sbAttrsValue.progress = myStepBarView .maxCount- 2
92+ sbAttrsValue.progress = my_stepBarView4 .maxCount- 2
7293 refreshValueText(sbAttrsValue.progress)
7394 }
7495 " sbv_steps_line_height" -> {
7596 sbAttrsValue.max = 20
76- sbAttrsValue.progress = DpHandler .pxToDp(this @MainActivity, myStepBarView .stepsLineHeight.toInt())
97+ sbAttrsValue.progress = DpHandler .pxToDp(this @MainActivity, my_stepBarView4 .stepsLineHeight.toInt())
7798 refreshValueText(sbAttrsValue.progress)
7899 }
79100 " sbv_steps_size" -> {
80101 sbAttrsValue.max = 80
81- sbAttrsValue.progress = DpHandler .pxToDp(this @MainActivity, myStepBarView .stepsSize.toInt())
102+ sbAttrsValue.progress = DpHandler .pxToDp(this @MainActivity, my_stepBarView4 .stepsSize.toInt())
82103 refreshValueText(sbAttrsValue.progress)
83104 }
84105 " sbv_steps_text_size" -> {
85106 sbAttrsValue.max = 25
86- sbAttrsValue.progress = DpHandler .pxToSp(this @MainActivity, myStepBarView .stepsSize.toInt()).toInt()
107+ sbAttrsValue.progress = DpHandler .pxToSp(this @MainActivity, my_stepBarView4 .stepsSize.toInt()).toInt()
87108 refreshValueText(sbAttrsValue.progress)
88109 }
89110 " sbv_steps_line_margin_left" -> {
90111 sbAttrsValue.max = 40
91- sbAttrsValue.progress = DpHandler .pxToDp(this @MainActivity, myStepBarView .stepsLineMarginLeft.toInt())
112+ sbAttrsValue.progress = DpHandler .pxToDp(this @MainActivity, my_stepBarView4 .stepsLineMarginLeft.toInt())
92113 refreshValueText(sbAttrsValue.progress)
93114 }
94115 " sbv_steps_line_margin_right" -> {
95116 sbAttrsValue.max = 100
96- sbAttrsValue.progress = DpHandler .pxToDp(this @MainActivity, myStepBarView .stepsLineMarginRight.toInt())
117+ sbAttrsValue.progress = DpHandler .pxToDp(this @MainActivity, my_stepBarView4 .stepsLineMarginRight.toInt())
97118 refreshValueText(sbAttrsValue.progress)
98119 }
99120 " sbv_allow_touch_step_to" -> {
100- sbAttrsValue.max = myStepBarView .maxCount
101- sbAttrsValue.progress = myStepBarView .allowTouchStepTo
121+ sbAttrsValue.max = my_stepBarView4 .maxCount
122+ sbAttrsValue.progress = my_stepBarView4 .allowTouchStepTo
102123 refreshValueText(sbAttrsValue.progress)
103124 }
104125 }
@@ -135,25 +156,25 @@ class MainActivity : AppCompatActivity() ,SeekBar.OnSeekBarChangeListener{
135156 private fun refreshProgress (progress : Int ) {
136157 when (actionsList[spActions.selectedItemPosition]){
137158 " sbv_max_count" -> {
138- myStepBarView .maxCount= progress+ 2
159+ my_stepBarView4 .maxCount= progress+ 2
139160 }
140161 " sbv_steps_line_height" -> {
141- myStepBarView .stepsLineHeight = DpHandler .dpToPx(this @MainActivity,progress).toFloat()
162+ my_stepBarView4 .stepsLineHeight = DpHandler .dpToPx(this @MainActivity,progress).toFloat()
142163 }
143164 " sbv_steps_size" -> {
144- myStepBarView .stepsSize = DpHandler .dpToPx(this @MainActivity,progress).toFloat()
165+ my_stepBarView4 .stepsSize = DpHandler .dpToPx(this @MainActivity,progress).toFloat()
145166 }
146167 " sbv_steps_text_size" -> {
147- myStepBarView .stepsTextSize = DpHandler .spToPx(this ,progress.toFloat())
168+ my_stepBarView4 .stepsTextSize = DpHandler .spToPx(this ,progress.toFloat())
148169 }
149170 " sbv_steps_line_margin_left" -> {
150- myStepBarView .stepsLineMarginLeft = DpHandler .dpToPx(this @MainActivity,progress).toFloat()
171+ my_stepBarView4 .stepsLineMarginLeft = DpHandler .dpToPx(this @MainActivity,progress).toFloat()
151172 }
152173 " sbv_steps_line_margin_right" -> {
153- myStepBarView .stepsLineMarginRight = DpHandler .dpToPx(this @MainActivity,progress).toFloat()
174+ my_stepBarView4 .stepsLineMarginRight = DpHandler .dpToPx(this @MainActivity,progress).toFloat()
154175 }
155176 " sbv_allow_touch_step_to" -> {
156- myStepBarView .allowTouchStepTo = progress
177+ my_stepBarView4 .allowTouchStepTo = progress
157178 }
158179 }
159180 }
0 commit comments