diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2023-05-05 23:09:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-05 23:09:03 +0200 |
commit | 6d7bfef8a5fe8180f13904739996bb2b8de8a0d4 (patch) | |
tree | 84f246b74fe7254678788e9f206d81d1a30ffa5e /ui/common | |
parent | 4c286931cd2dbd9038022f808f9d8a73ccbb6759 (diff) | |
download | AntennaPod-6d7bfef8a5fe8180f13904739996bb2b8de8a0d4.zip |
Download Service Rewrite (#6420)
Diffstat (limited to 'ui/common')
-rw-r--r-- | ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java index a693c28b0..42f63bd9d 100644 --- a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java @@ -4,7 +4,9 @@ import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.DashPathEffect; import android.graphics.Paint; +import android.graphics.PathEffect; import android.graphics.RectF; import android.util.AttributeSet; import android.view.View; @@ -13,11 +15,13 @@ import androidx.annotation.Nullable; public class CircularProgressBar extends View { public static final float MINIMUM_PERCENTAGE = 0.005f; public static final float MAXIMUM_PERCENTAGE = 1 - MINIMUM_PERCENTAGE; + private static final PathEffect DASHED = new DashPathEffect(new float[] {5f, 5f}, 0f); private final Paint paintBackground = new Paint(); private final Paint paintProgress = new Paint(); private float percentage = 0; private float targetPercentage = 0; + private boolean isIndeterminate = false; private Object tag = null; private final RectF bounds = new RectF(); @@ -73,9 +77,10 @@ public class CircularProgressBar extends View { float padding = getHeight() * 0.07f; paintBackground.setStrokeWidth(getHeight() * 0.02f); + paintBackground.setPathEffect(isIndeterminate ? DASHED : null); paintProgress.setStrokeWidth(padding); bounds.set(padding, padding, getWidth() - padding, getHeight() - padding); - canvas.drawArc(bounds, 0, 360, false, paintBackground); + canvas.drawArc(bounds, -90, 360, false, paintBackground); if (MINIMUM_PERCENTAGE <= percentage && percentage <= MAXIMUM_PERCENTAGE) { canvas.drawArc(bounds, -90, percentage * 360, false, paintProgress); @@ -92,4 +97,8 @@ public class CircularProgressBar extends View { invalidate(); } } + + public void setIndeterminate(boolean indeterminate) { + isIndeterminate = indeterminate; + } } |