Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51d6eb7d authored by Romain Guy's avatar Romain Guy
Browse files

Fix crash when using a SimpleCursorAdapter initialized with a null Cursor.

Change-Id: Ia7d078db8ab941c830663e6af7cbb07d7bad24a8
parent 0c0b768e
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -338,6 +338,12 @@ public class SimpleCursorAdapter extends ResourceCursorAdapter {

    @Override
    public Cursor swapCursor(Cursor c) {
        // super.swapCursor() will notify observers before we have
        // a valid mapping, make sure we have a mapping before this
        // happens
        if (mFrom == null) {
            findColumns(mOriginalFrom);
        }
        Cursor res = super.swapCursor(c);
        // rescan columns in case cursor layout is different
        findColumns(mOriginalFrom);
@@ -358,6 +364,12 @@ public class SimpleCursorAdapter extends ResourceCursorAdapter {
    public void changeCursorAndColumns(Cursor c, String[] from, int[] to) {
        mOriginalFrom = from;
        mTo = to;
        // super.changeCursor() will notify observers before we have
        // a valid mapping, make sure we have a mapping before this
        // happens
        if (mFrom == null) {
            findColumns(mOriginalFrom);
        }
        super.changeCursor(c);
        findColumns(mOriginalFrom);
    }