@@ -94,7 +94,10 @@ public void adjustCanvas(
94
94
// Scales canvas while hiding with escape animation.
95
95
if (drawable .isHiding () && spec .hideAnimationBehavior == HIDE_ESCAPE ) {
96
96
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 );
98
101
}
99
102
100
103
// 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(
136
139
float endPx = endFraction * trackLength ;
137
140
float gapSize = min (spec .indicatorTrackGapSize , startPx );
138
141
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
-
144
142
float adjustedStartX = originX + startPx + gapSize ;
145
143
// TODO: workaround to maintain pixel-perfect compatibility with drawing logic
146
144
// not using indicatorTrackGapSize.
@@ -149,10 +147,6 @@ public void fillIndicator(
149
147
adjustedStartX -= displayedCornerRadius * 2 ;
150
148
}
151
149
float adjustedEndX = originX + endPx ;
152
- // Prevents drawing over the stop indicator.
153
- if (endPx == trackLength ) {
154
- adjustedEndX -= spec .trackStopIndicatorSize ;
155
- }
156
150
157
151
// Sets up the paint.
158
152
paint .setStyle (Style .FILL );
@@ -169,9 +163,28 @@ public void fillIndicator(
169
163
adjustedEndX ,
170
164
displayedTrackThickness / 2 );
171
165
canvas .drawRoundRect (indicatorBounds , displayedCornerRadius , displayedCornerRadius , paint );
166
+
167
+ // Draw stop indicator
168
+ if (spec .trackStopIndicatorSize > 0 ) {
169
+ drawStopIndicator (canvas , paint );
170
+ }
172
171
canvas .restore ();
173
172
}
174
173
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
+
175
188
/**
176
189
* Fills the whole track with track color.
177
190
*
@@ -196,13 +209,5 @@ void fillTrack(@NonNull Canvas canvas, @NonNull Paint paint) {
196
209
displayedCornerRadius ,
197
210
Path .Direction .CCW );
198
211
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
- }
207
212
}
208
213
}
0 commit comments