lopspower / CircularProgressBar

Create circular ProgressBar in Android ⭕
Apache License 2.0
1.74k stars 223 forks source link

SetProgress sets progress to maxProgress if the old progress was higher than maxProgress #42

Open bart1998 opened 4 years ago

bart1998 commented 4 years ago

I think there is a small bug in this library. For example: when you set the max progress to 20 and the progress to 15, then set the max progress to 10 and the progress to 5, the actual progress will be set to 10 because of this line.

https://github.com/lopspower/CircularProgressBar/blob/471e1c6d3cc0a6bf59f0f9dfdfaf723c08d1088d/circularprogressbar/src/main/java/com/mikhaellopez/circularprogressbar/CircularProgressBar.kt#L43

This is a very easy fix, just change if (progress ... to if (value ... so that it checks the actual progress you set.

The use case where i am facing this is in a recyclerview. Here i have different max progress and progress values in each entry for a leveling system. As rows get recycled the max progress is changed before the progress.

A quick workaround (without changing the library) is to set the progress to 0 before changing the maxProgress.