OnRetainInstanceListener.kt
TLDR
This file contains the implementation of a listener interface for retaining instances in the LeakCanary library. It defines a sealed class RetainInstanceEvent
and an interface OnRetainInstanceListener
along with a default implementation class DefaultOnRetainInstanceListener
.
Methods
onEvent(event: RetainInstanceEvent)
Called when there's a change to the retained instances. The event
parameter represents the type of event that occurred, which is an instance of the RetainInstanceEvent
sealed class.
Classes
DefaultOnRetainInstanceListener
This class provides a default implementation of the OnRetainInstanceListener
interface. It does not perform any action when the onEvent
method is called.
package leakcanary.internal
internal sealed class RetainInstanceEvent {
object NoMoreObjects : RetainInstanceEvent()
sealed class CountChanged : RetainInstanceEvent() {
class BelowThreshold(val retainedCount: Int) : RetainInstanceEvent()
class DumpingDisabled(val reason: String) : RetainInstanceEvent()
object DumpHappenedRecently : RetainInstanceEvent()
}
}
/**
* Called by LeakCanary when the number of retained instances updates .
*/
internal fun interface OnRetainInstanceListener {
/**
* Called when there's a change to the Retained Instances. See [RetainInstanceEvent] for
* possible events.
*/
fun onEvent(event: RetainInstanceEvent)
}
internal class DefaultOnRetainInstanceListener : OnRetainInstanceListener {
override fun onEvent(event: RetainInstanceEvent) {}
}