title: what is the fragment equivalent of Activity.isFinishing()?
body: <p>In my activities I frequently use this idiom:</p>
  
  <pre><code>@Override
  public void onDestroy() {
      super.onDestroy();
      if (isFinishing() != true) return;
      // do some final cleanup since we're going away for good
  }
  </code></pre>
  
  <p>Fragment has an <code>onDestroy()</code> method, but what is the equivalent of <code>isFinishing()</code>?  Should I just check <code>getActivity().isFinishing()</code> from within the fragment's <code>onDestroy()</code>?</p>
  
  <p>EDITED TO ADD:</p>
  
  <p>Here are the callbacks (in order) I get under various circumstances, along with whether <code>getActivity()</code> returns null or non-null and, if non-null, the value of <code>getActivity().isFinishing()</code>:</p>
  
  <p>Scenario #1:  <code>DialogFragment</code> is showing and user taps back button (i.e. need to release references):</p>
  
  <pre><code>onDismiss(): activity = non-null, finishing = false
  onDestroy(): activity = non-null, finishing = false
  </code></pre>
  
  <p>Scenario #2:  <code>DialogFragment</code> is showing and parent activity finishes (i.e. need to release references):</p>
  
  <pre><code>onDestroy(): activity = non-null, finishing = true
  onDismiss(): activity = null, finishing = n/a
  </code></pre>
  
  <p>Scenario #3:  <code>DialogFragment</code> is showing and OS temporarily destroys parent activity (i.e. should not release references):</p>
  
  <pre><code>onDestroy(): activity = non-null, finishing = false
  onDismiss(): activity = null, finishing = n/a
  </code></pre>