inline fun <reified T> View.findViewByString(idString: String): T {
val id = this.resources.getIdentifier(idString, "id", context.packageName)
val view: View? = this.findViewById(id)
val idNotFoundMessage = "View with id \"$idString\" was not found"
val wrongClassMessage = "View with id \"$idString\" is not from expected class. " +
"Expected ${T::class.java.simpleName} found ${view?.javaClass?.simpleName}"
assertNotNull(idNotFoundMessage, view)
assertTrue(wrongClassMessage, view is T)
return view as T
}
it makes sure the widget that is looked for is not null and that the class is the expected class before returning the value
this is the implementation for findViewByString
it makes sure the widget that is looked for is not null and that the class is the expected class before returning the value