The UI of the app looks like this, and can contain a moderately large amount of data (a few hundred products, tens of categories). The products strips scroll left to right. The entire UI scrolls vertically.
Category 1
Product 1 Product 2 Product 3 Product 4 <-- scrolls -->
Category 2
Product 1 Product 2 Product 3 Product 4 <-- scrolls -->
Category 3
Product 1 Product 2 Product 3 Product 4 <-- scrolls -->
I've implemented the horizontal scrolling product sections (within each category) as RecyclerViews. The vertically scrolling (containing the product sections) is implemented within a vertically scrolling RecyclerView. With simple dummy data from SQL it works fine and performance is good.
But to use real data I need each section to show its own subset of products. It seems desirable to run one query to get a products Cursor (CursorLoader) to provide access to ALL the products, across all the categories and then to use a filter on that cursor to display just the products for one category in each horizontal, products RecyclerView.
I am using this https://gist.github.com/Shywim/127f207e7248fe48400b which is a CursorRecyclerAdapter. It works well so far, and supports filtering, but I am unable to see how to implement filtering. I have found some samples for FilterQueryProvider but they seem to have significant performance implications as it seems as if it requires re-running the query again. I'm wondering if my approach is fundamentally sensible.
In my research I also found devs recommending no-one use FilterQueryProvider and to use CursorLoader instead, but if I'm relying on CursorLoader how do I implement it without a whole series of inefficient queries to populate the rows of the UI? I can't help thinking there must be a way to do one products query and filter that cursor for each row.
TLDR; In a scenario with one fairly large data set that needs displaying in subsets in various Cursor-backed Views, what approach is best in order to sub-divide the data into "sub-Cursors" whilst retaining good performance and efficiency?
UPDATE. Since posting this it occurs to me that in advance of querying for the products I need to know which categories I need to display - so I expect there to be two queries, performed in series. The app is in a kiosk setting with one device type, no screen rotations, and one app running so config changes are not a concern. So I think I can use an AsyncTask to run the first query to get a list of categories (containing products), and then run a query (using each Category ID) to get a cursor of products for each category. So far this is the best approach I've come up with, there must be a better way not least because I don't want to run lots of queries, especially when most are not useful until the user scrolls down the page.