Closed Yumcoder-dev closed 6 years ago
RecyclerView automatically saves its position as part of saved instance state. make sure your view state is getting saved. the only gotcha is that epoxy models must be set on the RecyclerView before view state is restored
Let me explain it in another real scenario: in a chat message list, we want to save last message id (set in epoxy model id) that seen by the user. If the user left the list and later back to it, new data will be fetched from the server and the list is constructed but we want to scroll to the last seen message (epoxy_model_id = message_id)
That should be easy enough. You will have to:
epoxyController.getAdapter().getCopyOfModels()
to get all your models and find the model who's id matches your saved idI have a similar issue with Carousel. I am using fragment and only onPaused is called before starting another fragment. When back to the recyclerview fragment, only onCreateView/onViewCreated/onResume are called. So calling onSaveInstanceState does not help. How to we deal with saving state for Carousel (multiple horizontal recyclerview) in fragment? Thanks.
Closing since @sauyee333 opened https://github.com/airbnb/epoxy/issues/385 and yumcoder seems to have this solved
suppose we have two layouts for land and portrait, how to save and restore current RecyclerView(with TypedEpoxyController) position?