When you set the indeterminateMode to true you spawn a handler that continuously updates the state of the progress bar.
var indeterminateMode = false
set(value) {
field = value
onIndeterminateModeChangeListener?.invoke(field)
progressIndeterminateMode = 0f
progressDirectionIndeterminateMode = ProgressDirection.TO_RIGHT
startAngleIndeterminateMode = DEFAULT_START_ANGLE
indeterminateModeHandler?.removeCallbacks(indeterminateModeRunnable)
progressAnimator?.cancel()
indeterminateModeHandler = Handler()
if (field) {
indeterminateModeHandler?.post(indeterminateModeRunnable)
}
}
The problem is that this handler gets cleared only in onDetachedFromWindow. Hence you get the leak if the view was never attached.
When you set the
indeterminateModetotrueyou spawn a handler that continuously updates the state of the progress bar.The problem is that this handler gets cleared only in
onDetachedFromWindow. Hence you get the leak if the view was never attached.