@Test public void showAllowingStateLossDoesNotPerformTransaction() throws Exception { final SenseDialogFragment dialogFragment = new SenseDialogFragment(); final FragmentManager mockedFragmentManager = mock(FragmentManager.class); doReturn(true).when(mockedFragmentManager) .isDestroyed(); final int expected = Constants.NONE; final int actual = dialogFragment.showAllowingStateLoss(mockedFragmentManager, "TAG"); assertEquals(expected, actual); verify(mockedFragmentManager, Mockito.never()).beginTransaction(); }
public int showAllowingStateLoss(@NonNull final FragmentManager fm, @NonNull final String tag) { if(fm.isDestroyed()) { return Constants.NONE; } return fm.beginTransaction() .add(this, tag) .commitAllowingStateLoss(); }
SenseDialogFragment extends DialogFragment implements StateSafeExecutor.Resumes { public int showAllowingStateLoss(@NonNull final FragmentManager fm, @NonNull final String tag) { if(fm.isDestroyed()) { return Constants.NONE; } return fm.beginTransaction() .add(this, tag) .commitAllowingStateLoss(); } }
SenseDialogFragment extends DialogFragment implements StateSafeExecutor.Resumes { public int showAllowingStateLoss(@NonNull final FragmentManager fm, @NonNull final String tag) { if(fm.isDestroyed()) { return Constants.NONE; } return fm.beginTransaction() .add(this, tag) .commitAllowingStateLoss(); }  }
SenseDialogFragment extends DialogFragment implements StateSafeExecutor.Resumes { public int showAllowingStateLoss(@NonNull final FragmentManager fm, @NonNull final String tag) { if(fm.isDestroyed()) { return Constants.NONE; } return fm.beginTransaction() .add(this, tag) .commitAllowingStateLoss(); }  @Override void onResume(); @Override void onDestroyView(); @Deprecated @Override int show(@NonNull FragmentTransaction transaction, String tag); @Deprecated @Override void show(@NonNull FragmentManager manager, String tag); int showAllowingStateLoss(@NonNull final FragmentManager fm,
                                     @NonNull final String tag); void dismissSafely(); }
SenseDialogFragment extends DialogFragment implements StateSafeExecutor.Resumes { public int showAllowingStateLoss(@NonNull final FragmentManager fm, @NonNull final String tag) { if(fm.isDestroyed()) { return Constants.NONE; } return fm.beginTransaction() .add(this, tag) .commitAllowingStateLoss(); }  @Override void onResume(); @Override void onDestroyView(); @Deprecated @Override int show(@NonNull FragmentTransaction transaction, String tag); @Deprecated @Override void show(@NonNull FragmentManager manager, String tag); int showAllowingStateLoss(@NonNull final FragmentManager fm,
                                     @NonNull final String tag); void dismissSafely();  }