From 6d7bfef8a5fe8180f13904739996bb2b8de8a0d4 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 5 May 2023 23:09:03 +0200 Subject: Download Service Rewrite (#6420) --- .../de/danoeh/antennapod/ui/common/CircularProgressBar.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ui/common') 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; + } } -- cgit v1.2.3