From be9a740bc1c179cf3f73cf73e5b208feb2de4f3a Mon Sep 17 00:00:00 2001 From: haytham-c01 <0TU8KR21mbBs> Date: Sat, 25 Apr 2020 19:15:30 +0300 Subject: [PATCH] - added restrictions to minimum stepsCount and strokeWidth --- .idea/vcs.xml | 6 ++++++ .../java/com/haytham/coder/stepview/RectangularStepView.kt | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/stepview/src/main/java/com/haytham/coder/stepview/RectangularStepView.kt b/stepview/src/main/java/com/haytham/coder/stepview/RectangularStepView.kt index 9426b2d..04a4fc9 100644 --- a/stepview/src/main/java/com/haytham/coder/stepview/RectangularStepView.kt +++ b/stepview/src/main/java/com/haytham/coder/stepview/RectangularStepView.kt @@ -17,6 +17,7 @@ class RectangularStepView @JvmOverloads constructor( companion object{ private const val DEFAULT_STEPS_COUNT= 3 + private const val MINIMUM_STEPS_COUNT= 2 private const val DEFAULT_HEIGHT_WIDTH_RATIO= 0.08f } @@ -88,11 +89,11 @@ class RectangularStepView @JvmOverloads constructor( strokeWidth= getDimension( R.styleable.RectangularStepView_stepViewStrokeWidth, resources.getDimension(R.dimen.RectangularStepViewStrokeWidth) - ) + ).coerceAtLeast(0f) shapePaint.strokeWidth= strokeWidth - stepsCount= getInteger(R.styleable.RectangularStepView_stepsCount, DEFAULT_STEPS_COUNT) + stepsCount= getInteger(R.styleable.RectangularStepView_stepsCount, DEFAULT_STEPS_COUNT).coerceAtLeast(MINIMUM_STEPS_COUNT) _currentStep= getInteger(R.styleable.RectangularStepView_initialStep, 0).coerceIn(0, stepsCount-1) heightToWidthRatio= getFloat(R.styleable.RectangularStepView_heightToWidthRatio, DEFAULT_HEIGHT_WIDTH_RATIO).coerceIn(0.01f, 0.2f)