Closed Bug 888039 Opened 12 years ago Closed 12 years ago

Use support library's SimpleCursorAdapter if swapCursor() is needed

Categories

(Firefox for Android Graveyard :: Theme and Visual Design, defect)

ARM
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 26

People

(Reporter: sriram, Assigned: sriram)

References

Details

(Whiteboard: fixed-fig)

Attachments

(2 files, 1 obsolete file)

swapCursor() is only available on pre-honeycomb devices.
Attached patch Patch (obsolete) — Splinter Review
Thanks Android for you Loader, but don't force us to use newer methods!
Attachment #768607 - Flags: review?(margaret.leibovic)
Comment on attachment 768607 [details] [diff] [review] Patch We also use swapCursor in BrowserSearch.java. Let's change that, too.
Attachment #768607 - Flags: review?(margaret.leibovic) → review-
Attached patch PatchSplinter Review
Using the support library.
Attachment #769046 - Flags: review?(margaret.leibovic)
Summary: NSME on VisitedPage → Use support library's SimpleCursorAdapter if swapCursor() is needed
Just curious here, is there a reason we want to be using swapCursor instead of changeCursor? The docs say that changeCursor will close the cursor for us, but swapCursor won't. We're currently not doing anything with the cursor that swapCursor returns, so are we ending up with a bunch of unclosed cursors?
(In reply to :Margaret Leibovic from comment #4) > Just curious here, is there a reason we want to be using swapCursor instead > of changeCursor? The docs say that changeCursor will close the cursor for > us, but swapCursor won't. We're currently not doing anything with the cursor > that swapCursor returns, so are we ending up with a bunch of unclosed > cursors? I believe lucasr added swapCursor() because android recommends it. http://developer.android.com/reference/android/app/LoaderManager.html <-- search for swapCursor() in their example implementation. They've documented it.
From their docs: public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) mAdapter.swapCursor(data); ... more junk code ... }
Okay, I trust Lucas knows what he's doing, but I'm going to needinfo him just to make sure. However, I'm fine with landing this patch right now since he's away for a few days.
Flags: needinfo?(lucasr.at.mozilla)
Attachment #769046 - Flags: review?(margaret.leibovic) → review+
Attachment #768607 - Attachment is obsolete: true
(In reply to :Margaret Leibovic from comment #7) > Okay, I trust Lucas knows what he's doing, but I'm going to needinfo him > just to make sure. However, I'm fine with landing this patch right now since > he's away for a few days. SimpleCursorLoader owns the cursor and closes it for us when needed. We only need to make sure we don't keep dangling references to closed cursors. Have a look at SimpleCursorLoader's implementation for reference.
Flags: needinfo?(lucasr.at.mozilla)
Lucas asked me to file a followup for bug 887982 and bug 887985. Reusing this bug as this tracks a similar issue, and the bug is trivial.
Attachment #769768 - Flags: review?(margaret.leibovic)
Comment on attachment 769768 [details] [diff] [review] Patch: CursorAdapter I feel like we should start a wiki page about Cursor-related best practices. Maybe I'll ask ckitching to do that because he's also been fixing some Cursor issues recently.
Attachment #769768 - Flags: review?(margaret.leibovic) → review+
Assignee: nobody → sriram
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 26
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: