Skip to content

Commit

Permalink
Merge pull request #4206 from wordpress-mobile/issue/4184-show-passwo…
Browse files Browse the repository at this point in the history
…rd-field-crash

Adding isAdded() check to MagicLinkSignInFragment
  • Loading branch information
maxme authored Jun 10, 2016
2 parents 8873db8 + 7f01b7a commit 568cb9b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ private void slideInFragment(Fragment fragment, boolean shouldAddToBackStack) {
if (shouldAddToBackStack) {
fragmentTransaction.addToBackStack(null);
}
fragmentTransaction.commit();
fragmentTransaction.commitAllowingStateLoss();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.wordpress.android.ui.accounts.SignInFragment;
import org.wordpress.android.ui.main.WPMainActivity;
import org.wordpress.android.ui.notifications.utils.SimperiumUtils;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.EditTextUtils;

import java.util.HashMap;
Expand Down Expand Up @@ -185,19 +186,23 @@ private void configureMagicLinkUI() {
}

private void showPasswordFieldAndFocus() {
endProgress();
showPasswordField();
mPasswordEditText.requestFocus();
mSignInButton.setText(getString(R.string.sign_in));
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.showSoftInput(mPasswordEditText, InputMethodManager.SHOW_IMPLICIT);
if (isAdded()) {
endProgress();
showPasswordField();
mPasswordEditText.requestFocus();
mSignInButton.setText(getString(R.string.sign_in));
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.showSoftInput(mPasswordEditText, InputMethodManager.SHOW_IMPLICIT);
}
}

private void showPasswordField() {
mPasswordLayout.setVisibility(View.VISIBLE);
mForgotPassword.setVisibility(View.VISIBLE);
if (!mSelfHosted) {
mPasswordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
if (isAdded()) {
mPasswordLayout.setVisibility(View.VISIBLE);
mForgotPassword.setVisibility(View.VISIBLE);
if (!mSelfHosted) {
mPasswordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
}
}
}

Expand All @@ -212,8 +217,8 @@ public void onResponse(JSONObject response) {
} else {
showPasswordFieldAndFocus();
}
} catch (JSONException e) {
e.printStackTrace();
} catch (JSONException error) {
AppLog.e(AppLog.T.MAIN, error);
showPasswordFieldAndFocus();
}
}
Expand Down

0 comments on commit 568cb9b

Please sign in to comment.