Skip to content

Instantly share code, notes, and snippets.

@tpolecat
Created May 22, 2013 22:19
Show Gist options
  • Save tpolecat/5631403 to your computer and use it in GitHub Desktop.
Save tpolecat/5631403 to your computer and use it in GitHub Desktop.
def children(n: AccessibilityNodeInfo): List[AccessibilityNodeInfo] =
(0 until n.getChildCount).toList.map(n.getChild)
def linearize(n: AccessibilityNodeInfo): List[AccessibilityNodeInfo] =
n :: children(n).flatMap(linearize)
def getCertainClass(ani: AccessibilityNodeInfo, className: String, occurrence: Int): Option[AccessibilityNodeInfo] =
linearize(ani).filter(_.getClassName == className).lift(occurrence)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment