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

Commit 1b64c9d3 authored by Carlos Valdivia's avatar Carlos Valdivia
Browse files

Fix NPE when restarting ChooseTypeAndAccountActiivty.

Note that this change still leaves things in an imperfect state. Now instead
of ANR with an NPE it will reshow the Choose account activity and then on the
second back, it will go away. So the user isn't hosed. But it is still a sloppy
experience.  Basically the bug fix reveals another not quite as bad bug
(see https://b/8661942).

Bug: 8151602
Change-Id: I44b188f5940d464c2dd81dd0b6b7cae3c189becd
parent 4e0eb22f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -34,13 +34,11 @@ import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.android.internal.R;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

@@ -110,6 +108,7 @@ public class ChooseTypeAndAccountActivity extends Activity
    private static final String KEY_INSTANCE_STATE_EXISTING_ACCOUNTS = "existingAccounts";
    private static final String KEY_INSTANCE_STATE_SELECTED_ACCOUNT_NAME = "selectedAccountName";
    private static final String KEY_INSTANCE_STATE_SELECTED_ADD_ACCOUNT = "selectedAddAccount";
    private static final String KEY_INSTANCE_STATE_ACCOUNT_LIST = "accountList";

    private static final int SELECTED_ITEM_NONE = -1;

@@ -169,6 +168,7 @@ public class ChooseTypeAndAccountActivity extends Activity

            mSelectedAddNewAccount = savedInstanceState.getBoolean(
                    KEY_INSTANCE_STATE_SELECTED_ADD_ACCOUNT, false);
            mAccounts = savedInstanceState.getParcelableArrayList(KEY_INSTANCE_STATE_ACCOUNT_LIST);
        } else {
            mPendingRequest = REQUEST_NULL;
            mExistingAccounts = null;
@@ -266,6 +266,7 @@ public class ChooseTypeAndAccountActivity extends Activity
                        mAccounts.get(mSelectedItemIndex).name);
            }
        }
        outState.putParcelableArrayList(KEY_INSTANCE_STATE_ACCOUNT_LIST, mAccounts);
    }

    public void onCancelButtonClicked(View view) {