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

Commit a84f1d4e authored by Gary Mai's avatar Gary Mai
Browse files

Fix rotation crash in springboard

Save mResult in the instance bundle. It used to always be delivered
from the loader but it's possible for the springboard to not be the
top activity now so it can get recreated without getting a result
from the loader.

Test: Manually verified rotating the screen in the "choose a contact
to link" activity doesn't crash the app and the link happens as
expected.

Bug: 33196170
Change-Id: I0a5b21aed625059a1f65dc2e26de85af3feb5ebe
parent 2916634a
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ public class ContactEditorSpringBoardActivity extends AppCompatContactsActivity

    private static final String TAG = "EditorSpringBoard";
    private static final String TAG_RAW_CONTACTS_DIALOG = "rawContactsDialog";
    private static final String KEY_RAW_CONTACTS_METADATA = "rawContactsMetadata";
    private static final int LOADER_RAW_CONTACTS = 1;

    public static final String EXTRA_SHOW_READ_ONLY = "showReadOnly";
@@ -270,6 +271,18 @@ public class ContactEditorSpringBoardActivity extends AppCompatContactsActivity
        finish();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putParcelable(KEY_RAW_CONTACTS_METADATA, mResult);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        mResult = savedInstanceState.getParcelable(KEY_RAW_CONTACTS_METADATA);
    }

    private long[][] getRawContactIds() {
        final long[][] result = new long[mResult.rawContacts.size()][1];
        for (int i = 0; i < mResult.rawContacts.size(); i++) {