@@ -81,6 +81,8 @@ class IOSProgressBar constructor(context: Context, attributeSet: AttributeSet?)
81
81
// show Progress divider or not
82
82
private var showProgressDivider = false
83
83
84
+ private var connerStyle = CONNER_STYLE_ROUND
85
+
84
86
private var dividerHeight = 0f
85
87
86
88
// progress orientation
@@ -238,6 +240,11 @@ class IOSProgressBar constructor(context: Context, attributeSet: AttributeSet?)
238
240
resources.getDimension(R .dimen.default_progress_text_size)
239
241
)
240
242
progressTextPaint.textSize = progressTextSize
243
+
244
+ connerStyle = getInteger(
245
+ R .styleable.IOSProgressBar_ipb_progress_conner_style ,
246
+ CONNER_STYLE_ROUND
247
+ )
241
248
}
242
249
243
250
typedArray.recycle()
@@ -311,28 +318,28 @@ class IOSProgressBar constructor(context: Context, attributeSet: AttributeSet?)
311
318
viewBackgroundPath.reset()
312
319
viewBackgroundPath.moveTo(left, top + connerRadius)
313
320
// add left top conner
314
- if (connerRadius > 0 ) {
321
+ if (connerRadius > 0 && connerStyle == CONNER_STYLE_ROUND ) {
315
322
connerRect.set(left, top, connerRadius* 2 , connerRadius* 2 )
316
323
viewBackgroundPath.arcTo(connerRect, - 180f , 90f ,false )
317
324
}
318
325
viewBackgroundPath.lineTo(left + connerRadius, top)
319
326
viewBackgroundPath.lineTo(right - connerRadius, top)
320
327
// add right top conner
321
- if (connerRadius > 0 ) {
328
+ if (connerRadius > 0 && connerStyle == CONNER_STYLE_ROUND ) {
322
329
connerRect.set(right- connerRadius* 2 , top, right, connerRadius* 2 )
323
330
viewBackgroundPath.arcTo(connerRect, - 90f , 90f , false )
324
331
}
325
332
viewBackgroundPath.lineTo(right, top + connerRadius)
326
333
viewBackgroundPath.lineTo(right, bottom - connerRadius)
327
334
// add right bottom conner
328
- if (connerRadius > 0 ) {
335
+ if (connerRadius > 0 && connerStyle == CONNER_STYLE_ROUND ) {
329
336
connerRect.set(right- connerRadius* 2 , bottom- connerRadius* 2 , right, bottom)
330
337
viewBackgroundPath.arcTo(connerRect, 0f , 90f , false )
331
338
}
332
339
viewBackgroundPath.lineTo(right - connerRadius, bottom)
333
340
viewBackgroundPath.lineTo(left + connerRadius, bottom)
334
341
// add left bottom conner
335
- if (connerRadius > 0 ) {
342
+ if (connerRadius > 0 && connerStyle == CONNER_STYLE_ROUND ) {
336
343
connerRect.set(left, bottom- connerRadius* 2 , connerRadius* 2 , bottom)
337
344
viewBackgroundPath.arcTo(connerRect, 90f , 90f , false )
338
345
}
@@ -403,6 +410,8 @@ class IOSProgressBar constructor(context: Context, attributeSet: AttributeSet?)
403
410
const val TAG = " IOSProgressBar"
404
411
const val ORIENTATION_VERTICAL = 1
405
412
const val ORIENTATION_HORIZONTAL = 2
413
+ const val CONNER_STYLE_ROUND = 1
414
+ const val CONNER_STYLE_CUT = 2
406
415
}
407
416
408
417
}
0 commit comments