Fix division by zero when calculating progress for large periods

This commit is contained in:
Alexander Bakker 2020-07-01 16:16:06 +02:00
parent c73c29d2ec
commit 93cc945a2c
3 changed files with 4 additions and 4 deletions

View file

@ -65,8 +65,8 @@ public class TotpProgressBar extends ProgressBar {
int currentProgress = (int) (maxProgress * ((float) millisTillRotation / (_period * 1000)));
// start progress animation, compensating for any changes to the animator duration scale settings
int animPart = maxProgress / _period;
int animEnd = (currentProgress / animPart) * animPart;
float animPart = (float) maxProgress / _period;
int animEnd = (int) ((currentProgress / animPart) * animPart);
int animPartDuration = (int) (1000 / _animDurationScale);
float animDurationFraction = (float) (currentProgress - animEnd) / animPart;
int realAnimDuration = (int) (1000 * animDurationFraction);

View file

@ -156,7 +156,7 @@
android:layout_width="wrap_content"
android:layout_height="3dp"
android:id="@+id/progressBar"
android:max="1000"
android:max="5000"
android:layout_weight="1"/>
</LinearLayout>

View file

@ -155,7 +155,7 @@
android:layout_width="wrap_content"
android:layout_height="3dp"
android:id="@+id/progressBar"
android:max="1000"
android:max="5000"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>