Created
June 25, 2019 21:49
-
-
Save ultra-taco/f6996f0ec428893f61360aded7d402e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JvmStatic | |
fun getAllChildren(v: View, recursive: Boolean, ignoredElements: List<View>): ArrayList<View> { | |
if (v !is ViewGroup || v.childCount == 0) { | |
val r = ArrayList<View>() | |
r.add(v) | |
return r | |
} else { | |
val list = ArrayList<View>() | |
list.add(v) | |
val children = v.childCount | |
for (i in 0 until children) { | |
val child = v.getChildAt(i) | |
if (!ignoredElements.contains(child)) { | |
if (recursive) { | |
list.addAll(getAllChildren(child, recursive, ignoredElements)) | |
} else { | |
list.add(child) | |
} | |
} | |
} | |
return list | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment