Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Paging 3 library in real life

Avatar for Orel Zion Orel Zion
September 02, 2022

Paging 3 library in real life

Is pagination so hard?
If you search Twitter for pagination it seems that the answer is simply yes :)

Fortunately for us Android developers Google has their library for pagination that suppose to take a lot of the burden away.

However, the library itself is very complex, and most of the tutorials I saw online doesn't really explain how to exploit this library for complex use cases.
They show you the simplest use-case of loading an infinite list of images from the internet, but what happens when you need to add filtering? Update the state across different lists?

In this presentation I was focusing on using the pagination library in a real life application with all of its complexity.

Bonus point: I was also showing how to do that with #compose

Avatar for Orel Zion

Orel Zion

September 02, 2022
Tweet

More Decks by Orel Zion

Other Decks in Programming

Transcript

  1. ©2022 Viz.ai Proprietary & Confidential ©2022 Viz.ai Proprietary & Confidential

    Orel Zion, DroidCon NYC 22 Jetpack's Paging 3 in real life
  2. ©2022 Viz.ai Proprietary & Confidential 9 “For every problem there

    is a solution which is simple, clean and wrong.” — Henry Louis Mencken
  3. ©2022 Viz.ai Proprietary & Confidential ©2022 Viz.ai 10 Agenda •

    Complex use-case of pagination • Implementation without the library • Refactor into using the library • Pros • Cons
  4. ©2022 Viz.ai Proprietary & Confidential Healthcare Data Viz ingests live

    data from imaging modalities (XR, CT, MR), EKG, EMR, and other clinical reports Enable Therapy This results in the right patient getting the right care at the right time. Improving patient outcome, treatment rate and provider experience. AI Analysis Viz cloud based AI algorithms automatically detect, measure and predict disease Trigger Action Viz alerts the most appropriate specialist and/or the clinical research team about the patient and enables them to easily take the next best clinical action 11 System of Action How It Works
  5. ©2022 Viz.ai Proprietary & Confidential ©2022 Viz.ai 14 Assumptions •

    Different lists • Shared items • Sync changes • Fast Switch • Saving state
  6. ©2022 Viz.ai Proprietary & Confidential My Custom Architecture 16 Repository

    View Model UI Paging Adapter Scroll Listener UI State Flow Local Data Source Remote Data Source Selected Filter On Tab Selected Paging Properties DB
  7. ©2022 Viz.ai Proprietary & Confidential ©2022 Viz.ai Wrap up 19

    Pros • Less work, less code • More organized, more sophisticated Cons • A mix of view and model, the adapter does it all • PagingSource requires you to define page key