From 6834662c8209da946ebb0388c2b1dad69bc20c4b Mon Sep 17 00:00:00 2001 From: Karim Abou Zeid Date: Wed, 8 Jul 2015 16:38:42 +0200 Subject: [PATCH] Fixed the gap in the PlayPauseDrawable that occurred on some devices which were using custom DPIs --- .../com/kabouzeid/gramophone/views/PlayPauseDrawable.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/kabouzeid/gramophone/views/PlayPauseDrawable.java b/app/src/main/java/com/kabouzeid/gramophone/views/PlayPauseDrawable.java index 24740570..bcb55603 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/views/PlayPauseDrawable.java +++ b/app/src/main/java/com/kabouzeid/gramophone/views/PlayPauseDrawable.java @@ -78,7 +78,10 @@ public class PlayPauseDrawable extends Drawable { // The current distance between the two pause bars. final float barDist = lerp(pauseBarDistance, 0, progress); // The current width of each pause bar. - final float barWidth = lerp(pauseBarWidth, pauseBarHeight / 1.75f, progress); + float rawBarWidth = lerp(pauseBarWidth, pauseBarHeight / 1.75f, progress); + // We have to round the bar width when finishing the progress to prevent the gap + // that might occur onDraw because of a pixel is lost when casting float to int instead of rounding it. + final float barWidth = progress == 1 ? Math.round(rawBarWidth) : rawBarWidth; // The current position of the left pause bar's top left coordinate. final float firstBarTopLeft = lerp(0, barWidth, progress); // The current position of the right pause bar's top right coordinate.