Created
January 14, 2020 16:55
-
-
Save AaronMT/905df26acd694d5724975957a27c60f4 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
fun nthChildOf( | |
parentMatcher: Matcher<View>, | |
childPosition: Int | |
): Matcher<View> { | |
return object : TypeSafeMatcher<View>() { | |
override fun describeTo(description: Description) { | |
description.appendText("Position is $childPosition") | |
} | |
public override fun matchesSafely(view: View): Boolean { | |
if (view.parent !is ViewGroup) { | |
return parentMatcher.matches(view.parent) | |
} | |
val group = view.parent as ViewGroup | |
return parentMatcher.matches(view.parent) && group.getChildAt(childPosition) == view | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment