At our company we are developing an app that displays a timeline. We are willing to let the user scroll it (almost) indefinitely.
Now there are 2 facts to consider:
- loading a large cursor can have a bad impact on performances (true especially for old devices)
- cursors seem to have a size limit of 1MB
In the current implementation we're loading by default 40 items, then when the user scrolls beyond a certain threshold we repeat the query by increasing the limit to 40+20 items, and so on.
However, this approach seems to be quite weak because it clashes with both the principles stated before: the query will eventually become fairly large and at some point the cursor might hit the memory limit of 1MB (we load a lot of strings).
Now we're thinking about exploiting the MergeCursor and proceed like so:
- Load a cursor of 40 items the first time
- When the user scrolls beyond a certain level, we load another cursor containing the next 40 items and set in the cursor adapter a MergeCursor that concatenates the new cursor to the previous one.
- Continue with this approach till at most X steps (depending on tests) to avoid hitting some OOM exception. At the end the timeline cursor will be the concatenation of X cursors.
What do you think about this approach? Any weakness (except the overhead, which should be small)?
In case, can you point/describe better solutions?
Thanks in advance