private void endAllFlows() {
   for (final Flow flow : mFlowManager.getAllActiveFlows()) {
     mFlowManager.endFlow(flow);
   }
   cancelIdleWarning();
   if (mShowCamera) {
     mCameraFragment.cancelPendingPicture();
   }
 }
 @Override
 protected void onPostResume() {
   super.onPostResume();
   final Flow flow = getCurrentlyFocusedFlow();
   Log.d(TAG, "onPostResume: focusedFlow: " + flow);
   if (flow != null) {
     updateControlsForFlow(flow);
     if (Strings.isNullOrEmpty(flow.getImagePath())) {
       if (mShowCamera && mConfig.getEnableAutoTakePhoto()) {
         mCameraFragment.schedulePicture();
       }
     }
   }
 }
  private void refreshFlows() {
    final Set<Flow> activeFlows = Sets.newLinkedHashSet(mFlowManager.getAllActiveFlows());
    mActiveFlows.addAll(activeFlows);
    final Set<Flow> oldFlows = Sets.newLinkedHashSet(Sets.difference(mActiveFlows, activeFlows));
    for (final Flow oldFlow : oldFlows) {
      Log.d(TAG, "Removing inactive flow: " + oldFlow);
      mActiveFlows.remove(oldFlow);
    }

    if (mShowCamera) {
      mCameraFragment.setEnabled(!mActiveFlows.isEmpty());
    }

    if (mActiveFlows.isEmpty()) {
      cancelIdleWarning();
      finish();
      return;
    }

    long largestIdleTime = Long.MIN_VALUE;
    for (final Flow flow : mActiveFlows) {
      if (flow.getTap() == null) {
        continue;
      }

      if (DEBUG) {
        Log.d(TAG, "Refreshing with flow: " + flow);
      }

      final long idleTimeMs = flow.getIdleTimeMs();
      if (idleTimeMs > largestIdleTime) {
        largestIdleTime = idleTimeMs;
      }
    }

    if (largestIdleTime >= mConfig.getIdleWarningMs()) {
      sendIdleWarning();
    } else {
      cancelIdleWarning();
    }

    scrollToMostActiveTap();
  }