Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed NPE in LoginUsernamePasswordFragment #10833

Merged
merged 2 commits into from Dec 11, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -52,6 +52,7 @@
public class LoginUsernamePasswordFragment extends LoginBaseFormFragment<LoginListener> implements TextWatcher,
OnEditorCommitListener {
private static final String KEY_LOGIN_FINISHED = "KEY_LOGIN_FINISHED";
private static final String KEY_LOGIN_STARTED = "KEY_LOGIN_STARTED";
private static final String KEY_REQUESTED_USERNAME = "KEY_REQUESTED_USERNAME";
private static final String KEY_REQUESTED_PASSWORD = "KEY_REQUESTED_PASSWORD";
private static final String KEY_OLD_SITES_IDS = "KEY_OLD_SITES_IDS";
Expand All @@ -74,6 +75,7 @@ public class LoginUsernamePasswordFragment extends LoginBaseFormFragment<LoginLi

private boolean mAuthFailed;
private boolean mLoginFinished;
private boolean mLoginStarted;

private String mRequestedUsername;
private String mRequestedPassword;
Expand Down Expand Up @@ -229,6 +231,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {

if (savedInstanceState != null) {
mLoginFinished = savedInstanceState.getBoolean(KEY_LOGIN_FINISHED);
mLoginStarted = savedInstanceState.getBoolean(KEY_LOGIN_STARTED);

mRequestedUsername = savedInstanceState.getString(KEY_REQUESTED_USERNAME);
mRequestedPassword = savedInstanceState.getString(KEY_REQUESTED_PASSWORD);
Expand All @@ -253,6 +256,7 @@ public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);

outState.putBoolean(KEY_LOGIN_FINISHED, mLoginFinished);
outState.putBoolean(KEY_LOGIN_FINISHED, mLoginStarted);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the key here is wrong, it should be KEY_LOGIN_STARTED

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D How come I missed this. Great catch !

outState.putString(KEY_REQUESTED_USERNAME, mRequestedUsername);
outState.putString(KEY_REQUESTED_PASSWORD, mRequestedPassword);
outState.putIntegerArrayList(KEY_OLD_SITES_IDS, mOldSitesIDs);
Expand All @@ -277,6 +281,7 @@ protected void next() {
return;
}

mLoginStarted = true;
startProgress();

mRequestedUsername = getCleanedUsername();
Expand Down Expand Up @@ -418,6 +423,7 @@ public void onAuthenticationChanged(OnAuthenticationChanged event) {
}

if (event.isError()) {
mLoginStarted = false;
if (mRequestedUsername == null) {
// just bail since the operation was cancelled
return;
Expand Down Expand Up @@ -472,11 +478,12 @@ private void finishLogin() {
@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSiteChanged(OnSiteChanged event) {
if (!isAdded() || mLoginFinished) {
if (!isAdded() || mLoginFinished || !mLoginStarted) {
return;
}

if (event.isError()) {
mLoginStarted = false;
if (mRequestedUsername == null) {
// just bail since the operation was cancelled
return;
Expand Down