Skip to content

Instantly share code, notes, and snippets.

@svinouze
Last active November 10, 2020 10:16
Show Gist options
  • Save svinouze/51b23a3c497935fd49511ca5124f264a to your computer and use it in GitHub Desktop.
Save svinouze/51b23a3c497935fd49511ca5124f264a to your computer and use it in GitHub Desktop.
class SegmentedProgressBar @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {
[...]
@get:ColorInt
var progressColor: Int = Color.GREEN
var progressAlpha: Float = 1f
var progress: Int = 0
[...]
private val progressPath: Path = Path()
private val progressPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
override fun onDraw(canvas: Canvas) {
[...]
val progressCoordinates = segmentCoordinatesComputer.progressCoordinates(progress, segmentCount, w, spacing)
drawSegment(canvas, progressPath, progressPaint, progressCoordinates, progressColor, progressAlpha)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment