Skip to content

Commit c3024dd

Browse files
author
heyangyang
committed
add conner style(round or cut) support
1 parent 95dfc53 commit c3024dd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

ios-progress-bar/src/main/java/com/hyy/iosprogressbar/IOSProgressBar.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class IOSProgressBar constructor(context: Context, attributeSet: AttributeSet?)
8181
//show Progress divider or not
8282
private var showProgressDivider = false
8383

84+
private var connerStyle = CONNER_STYLE_ROUND
85+
8486
private var dividerHeight = 0f
8587

8688
//progress orientation
@@ -238,6 +240,11 @@ class IOSProgressBar constructor(context: Context, attributeSet: AttributeSet?)
238240
resources.getDimension(R.dimen.default_progress_text_size)
239241
)
240242
progressTextPaint.textSize = progressTextSize
243+
244+
connerStyle = getInteger(
245+
R.styleable.IOSProgressBar_ipb_progress_conner_style,
246+
CONNER_STYLE_ROUND
247+
)
241248
}
242249

243250
typedArray.recycle()
@@ -311,28 +318,28 @@ class IOSProgressBar constructor(context: Context, attributeSet: AttributeSet?)
311318
viewBackgroundPath.reset()
312319
viewBackgroundPath.moveTo(left, top + connerRadius)
313320
//add left top conner
314-
if (connerRadius > 0) {
321+
if (connerRadius > 0 && connerStyle == CONNER_STYLE_ROUND) {
315322
connerRect.set(left, top, connerRadius*2, connerRadius*2)
316323
viewBackgroundPath.arcTo(connerRect, -180f, 90f,false)
317324
}
318325
viewBackgroundPath.lineTo(left + connerRadius, top)
319326
viewBackgroundPath.lineTo(right - connerRadius, top)
320327
//add right top conner
321-
if (connerRadius > 0) {
328+
if (connerRadius > 0 && connerStyle == CONNER_STYLE_ROUND) {
322329
connerRect.set(right-connerRadius*2, top, right, connerRadius*2)
323330
viewBackgroundPath.arcTo(connerRect, -90f, 90f, false)
324331
}
325332
viewBackgroundPath.lineTo(right, top + connerRadius)
326333
viewBackgroundPath.lineTo(right, bottom - connerRadius)
327334
//add right bottom conner
328-
if (connerRadius > 0) {
335+
if (connerRadius > 0 && connerStyle == CONNER_STYLE_ROUND) {
329336
connerRect.set(right-connerRadius*2, bottom-connerRadius*2, right, bottom)
330337
viewBackgroundPath.arcTo(connerRect, 0f, 90f, false)
331338
}
332339
viewBackgroundPath.lineTo(right - connerRadius, bottom)
333340
viewBackgroundPath.lineTo(left + connerRadius, bottom)
334341
//add left bottom conner
335-
if (connerRadius > 0) {
342+
if (connerRadius > 0 && connerStyle == CONNER_STYLE_ROUND) {
336343
connerRect.set(left, bottom-connerRadius*2, connerRadius*2, bottom)
337344
viewBackgroundPath.arcTo(connerRect, 90f, 90f, false)
338345
}
@@ -403,6 +410,8 @@ class IOSProgressBar constructor(context: Context, attributeSet: AttributeSet?)
403410
const val TAG = "IOSProgressBar"
404411
const val ORIENTATION_VERTICAL = 1
405412
const val ORIENTATION_HORIZONTAL = 2
413+
const val CONNER_STYLE_ROUND = 1
414+
const val CONNER_STYLE_CUT = 2
406415
}
407416

408417
}

0 commit comments

Comments
 (0)