Skip to content

Instantly share code, notes, and snippets.

View miguelhincapie's full-sized avatar

MiguelHincapieC miguelhincapie

View GitHub Profile
@miguelhincapie
miguelhincapie / GridKeyEventDelegateGist.kt
Created April 6, 2020 22:44
Snippet to navigate through recyclerView using accessibility
private fun onDownKeyPressed(currentFocus: View): Boolean = with(currentFocus) {
getNextElementPosition().let { nextElementPosition ->
if (isPositionInbound(nextElementPosition)) {
sendFocusToListItem(nextElementPosition)
} else {
rootView.findViewById<View>(R.id.carouselRV)?.sendAccessibilityFocus()
}
}
return true
}
@miguelhincapie
miguelhincapie / CarouselKeyEventDelegate.kt
Created April 8, 2020 00:07
Key event delegate to navigate through the carousel using TalkBack
class CarouselKeyEventDelegate : BaseKeyEventDelegate() {
init {
keyEventActionMap.let {
it.put(
createKey(
R.id.carousel_container,
KEYCODE_DPAD_DOWN
),
this::consumeDownKeyOnCarouselContainer