@@ -119,12 +119,12 @@ class FillProgressLayout : LinearLayout {
119
119
120
120
private fun initPaint () {
121
121
backgroundPaint.apply {
122
- this . style = Paint .Style .FILL
123
- this . color = mBackgroundColor
122
+ style = Paint .Style .FILL
123
+ color = mBackgroundColor
124
124
}
125
125
progressPaint.apply {
126
- this . style = Paint .Style .FILL
127
- this . color = mProgressColor
126
+ style = Paint .Style .FILL
127
+ color = mProgressColor
128
128
}
129
129
130
130
}
@@ -166,27 +166,30 @@ class FillProgressLayout : LinearLayout {
166
166
}
167
167
168
168
private fun drawNormalProgress (canvas : Canvas ? ) {
169
- canvas?.let {
170
- it. drawRect(backRectF, backgroundPaint)
171
- it. drawRect(progressRectF, progressPaint)
169
+ canvas?.apply {
170
+ drawRect(backRectF, backgroundPaint)
171
+ drawRect(progressRectF, progressPaint)
172
172
}
173
173
}
174
174
175
175
private fun drawRoundedProgress (canvas : Canvas ? ) {
176
- canvas?.let {
177
- it.drawRoundRect(backRectF, mCornerRadius, mCornerRadius, backgroundPaint)
178
- it.drawRoundRect(progressRectF, mCornerRadius, mCornerRadius, progressPaint)
176
+ canvas?.apply {
177
+ save()
178
+ drawRoundRect(backRectF, mCornerRadius, mCornerRadius, backgroundPaint)
179
+ clipPath(clipPath)
180
+ drawRect(progressRectF, progressPaint)
181
+ restore()
179
182
}
180
183
}
181
184
182
- override fun dispatchDraw (canvas : Canvas ? ) {
183
- if (isRounded)
184
- canvas?.clipPath(clipPath)
185
- super .dispatchDraw(canvas)
186
- }
187
185
188
186
private fun isValidRes (res : Int ) = res != View .NO_ID
189
187
188
+ override fun onDetachedFromWindow () {
189
+ clearAnimation()
190
+ super .onDetachedFromWindow()
191
+ }
192
+
190
193
// ---------------------public setters--------------------------------------------------------------------//
191
194
192
195
fun setProgress (p : Int ) {
0 commit comments