@@ -94,7 +94,10 @@ public void adjustCanvas(
9494 // Scales canvas while hiding with escape animation.
9595 if (drawable .isHiding () && spec .hideAnimationBehavior == HIDE_ESCAPE ) {
9696 canvas .scale (
97- trackThicknessFraction , trackThicknessFraction , bounds .left + bounds .width () / 2f , 0 );
97+ trackThicknessFraction ,
98+ trackThicknessFraction ,
99+ bounds .left + bounds .width () / 2f ,
100+ bounds .top + bounds .height () / 2f );
98101 }
99102
100103 // Clips all drawing to the track area, so it doesn't draw outside of its bounds (which can
@@ -136,11 +139,6 @@ public void fillIndicator(
136139 float endPx = endFraction * trackLength ;
137140 float gapSize = min (spec .indicatorTrackGapSize , startPx );
138141
139- // No need to draw if the indicator starts at or after the stop indicator.
140- if (startPx + gapSize >= trackLength - spec .trackStopIndicatorSize ) {
141- return ;
142- }
143-
144142 float adjustedStartX = originX + startPx + gapSize ;
145143 // TODO: workaround to maintain pixel-perfect compatibility with drawing logic
146144 // not using indicatorTrackGapSize.
@@ -149,10 +147,6 @@ public void fillIndicator(
149147 adjustedStartX -= displayedCornerRadius * 2 ;
150148 }
151149 float adjustedEndX = originX + endPx ;
152- // Prevents drawing over the stop indicator.
153- if (endPx == trackLength ) {
154- adjustedEndX -= spec .trackStopIndicatorSize ;
155- }
156150
157151 // Sets up the paint.
158152 paint .setStyle (Style .FILL );
@@ -169,9 +163,28 @@ public void fillIndicator(
169163 adjustedEndX ,
170164 displayedTrackThickness / 2 );
171165 canvas .drawRoundRect (indicatorBounds , displayedCornerRadius , displayedCornerRadius , paint );
166+
167+ // Draw stop indicator
168+ if (spec .trackStopIndicatorSize > 0 ) {
169+ drawStopIndicator (canvas , paint );
170+ }
172171 canvas .restore ();
173172 }
174173
174+ private void drawStopIndicator (@ NonNull Canvas canvas , @ NonNull Paint paint ) {
175+ int indicatorColor =
176+ MaterialColors .compositeARGBWithAlpha (spec .indicatorColors [0 ], drawable .getAlpha ());
177+ paint .setColor (indicatorColor );
178+ Rect trackBounds = canvas .getClipBounds ();
179+ RectF stopBounds =
180+ new RectF (
181+ trackBounds .right - spec .trackStopIndicatorSize ,
182+ -displayedTrackThickness / 2 ,
183+ trackBounds .right ,
184+ displayedTrackThickness / 2 );
185+ canvas .drawRoundRect (stopBounds , displayedCornerRadius , displayedCornerRadius , paint );
186+ }
187+
175188 /**
176189 * Fills the whole track with track color.
177190 *
@@ -196,13 +209,5 @@ void fillTrack(@NonNull Canvas canvas, @NonNull Paint paint) {
196209 displayedCornerRadius ,
197210 Path .Direction .CCW );
198211 canvas .drawPath (displayedTrackPath , paint );
199-
200- if (spec .trackStopIndicatorSize > 0 ) {
201- int indicatorColor =
202- MaterialColors .compositeARGBWithAlpha (spec .indicatorColors [0 ], drawable .getAlpha ());
203- paint .setColor (indicatorColor );
204- RectF stopBounds = new RectF (right - spec .trackStopIndicatorSize , -bottom , right , bottom );
205- canvas .drawRoundRect (stopBounds , displayedCornerRadius , displayedCornerRadius , paint );
206- }
207212 }
208213}
0 commit comments