All Downloads are FREE. Search and download functionalities are using the official Maven repository.

androidMain.RecursiveHierarchySubscriber.kt Maven / Gradle / Ivy

There is a newer version: 0.24.0
Show newest version
package dev.inmo.micro_utils.coroutines

import android.view.ViewGroup
import android.view.ViewGroup.OnHierarchyChangeListener

/**
 * Use [ViewGroup.setOnHierarchyChangeListener] recursively for all available [ViewGroup]s starting with [this].
 * This extension DO NOT guarantee that recursive subscription will happen after this method call
 */
fun ViewGroup.setOnHierarchyChangeListenerRecursively(
    listener: OnHierarchyChangeListener
) {
    setOnHierarchyChangeListener(listener)
    (0 until childCount).forEach {
        (getChildAt(it) as? ViewGroup) ?.setOnHierarchyChangeListenerRecursively(listener)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy