BeksOmega / looping-layout

A looping LayoutManager for the Android RecyclerView.
Apache License 2.0
274 stars 16 forks source link

feat: Added state saving. #24

Closed BeksOmega closed 4 years ago

BeksOmega commented 4 years ago

:clap: Resolves

Closes #10

:star2: Description

Adds a "LayoutRequest" object that can be used to request a re-layout of the recycler. This object can be used to save the state of the recycler and reload it later.

The layout manager now properly supports adapter data updates and orientation changes. I.E it tries to maintain the state of the layout, instead of re-laying out from 0.

:bug: Testing

Added checks to all of the scrollTo unit tests to make sure the topLeftIndex and bottomRightIndex are being properly set.

Also manually tested orientation changes using the following procedure:

  1. Started off in portrait orientation.
  2. Scrolled the items so half of item 1 was hidden.
  3. Rotated the AVD to landscape.
  4. Observed how half of item 1 was still hidden.
  5. Rotated the AVD back to portrait.
  6. Observed how half of item 1 was still hidden.

Tested for all horiz and vert, reversed and not reversed, rtl and ltr.

All unit tests pass.

:thought_balloon: Other info

N/A