I am trying to use facebook litho to build the android app for TV.
We need to support keyboard events(up/down/left/right) to control the navigation.
I can intercept keyboard events by onKeyDown in the activity, but I don't know how to update the component's status from activity.
Overview
I have solved a similar problem, which is to re-render the top-level Litho component when an external action occurs by doing the following:
LithoView
created in my ActivitiesonCreate
method@Prop
on your top-level componentonCreate
and derive my initial component from thisComponent
instance from thisLithoView#setComponent(Component)
with that instanceThis is essentially an implementation of the MVI approach as explained here for Android with Mosby, though the example shown is highly simplified.
Example:
Activity:
Spec: