Closed Bug 1001397 Opened 11 years ago Closed 4 years ago

Generalize parts of TopSitesCursorWrapper into a MultiCursorWrapper base class

Categories

(Firefox for Android Graveyard :: Awesomescreen, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: lucasr, Unassigned)

References

Details

So that we can use similar features in other contexts e.g. search UI with asynchronous queries coming from different sources.
In my ideal world we'd make this cursor implement "List<Cursor>", although that's overkill I'll admit. I imagined we'll probably need a special interface (SuperCursor I call it) that can (optionally) provide some extra info/special behavior here: interface SuperCursor { boolean hasEntryAt(int position); // For instance, pinned sites might be 6 long, // but some rows are empty int updateCount(int prevCount); // Needed if we want to make the empty entries a cursor? // FUTURE: Do we need a way to rank results here... // or does the multicursor do the ranking (based on if something is in history? } Cursor emptySites = new EmptySuperCursor(pinnedSites, MAX_SIZE); Cursor suggestedSites = new SuggestedSuperCursor(pinnedSites, MAX_SIZE); Cursor pinnedSites = new PinnedSuperCursor(pinnedSites, MAX_SIZE); MultiCursor mc = new MultiCursor(pinnedSites, topSites, suggestedSites, emptySites); class MultiCursor { List<Cursor> cursors; List<Map<Int, Int>> indiciesMap; // optimization cache mapping columns between // this cursor and the individual interior cursors // Haven't thought about this all that much, but a rough sketch boolean moveTo(int position) { int realPosition = position; for (int i = 0; i < cursors.length; i++) { Cursor c = cursors[i]; // If this cursor is all used, just remove all its entries... if (c.length > realPosition) { realPosition -= c.length; // SuperCursors might have a different "real" length? continue; } if (c instanceof SuperCursor) { if (c.hasEntryAt(realPosition)) { c.moveTo(realPosition); continue; } realPosition -= c.getPosition(); } else { c.moveTo(realPosition); } } } } There's probably other methods that would need special work...
Assignee: nobody → eedens
Back into the pool...
Assignee: eric.edens → nobody
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly](https://play.google.com/store/apps/details?id=org.mozilla.fenix) an issue can be reported at the [Fenix GitHub project](https://github.com/mozilla-mobile/fenix/). If you want to discuss your report please use [Mozilla's chat](https://wiki.mozilla.org/Matrix#Connect_to_Matrix) server https://chat.mozilla.org and join the [#fenix](https://chat.mozilla.org/#/room/#fenix:mozilla.org) channel.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INCOMPLETE
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.