Skip to content

Commit

Permalink
Fixed NPE while resuming fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
arcao committed Apr 25, 2013
1 parent 6080aa8 commit 91ab690
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.lang.ref.WeakReference;

import android.os.Bundle;
import android.support.v4.app.DialogFragment;

public abstract class AbstractDialogFragment extends DialogFragment {
Expand All @@ -23,6 +24,9 @@ public void onDestroyView() {
public void dismiss() {
// this fix IllegalStateException when App is hidden
if (!isAdded() || getFragmentManager() == null) {
if (getArguments() == null)
setArguments(new Bundle());

getArguments().putBoolean(PARAM_DISMISS_LATER, true);
}

Expand All @@ -37,7 +41,7 @@ public void dismiss() {
public void onResume() {
super.onResume();

if (getArguments().getBoolean(PARAM_DISMISS_LATER, false)) {
if (getArguments() != null && getArguments().getBoolean(PARAM_DISMISS_LATER, false)) {
dismiss();
}
}
Expand Down

0 comments on commit 91ab690

Please sign in to comment.