Using AndroidX Paging for non UI paging (e.g. in Services)

88 Views Asked by At

The Paging docs start off with:

The Paging Library helps you load and display small chunks of data at a time. Loading partial data on demand reduces usage of network bandwidth and system resources. source

It's still unclear to me if Paging would be useful for non-UI applications. It looks like I can still use DataSources/ PagingSource and PagedLists, as a lazy loading list would be useful when processing data.

My use case, I want to load thousands of images to perform some processing in a Foreground Service. I will only inform the user once all images are processed through a notification, so no views are directly involved. I am confused. Perhaps the concept of Paging is not right because I am not showing a certain number of items to the user (a page). But then, I still need a buffer to load files efficiently and not bottleneck on IO. My initial implementation did IO and processing sequentially, and I can see a "jagged tooth" profile for the CPU usage.

My question: I would appreciate if someone could explain the actual flexibility of the Paging library for non-UI applications, and most importantly, let me know how to efficiently load files/ IO if the paging library is not the right fit.

0

There are 0 best solutions below