Call in {@link FragmentActivity#onStop()} to properly remove the {@link ProgressChangeListener}
for the camera and prevent any leaks or further updates.
162945
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
  public void onStop() {
    if (navigation != null) {
      navigation.removeProgressChangeListener(progressChangeListener);
    }
  }
756905
public synchronized boolean removeChangeListener(ChangeListener listener) {
        if (bEnableListener && listener != null) {
            eventSource.removeListener(listener);
            return true;
        }
        return false;
    }
797565
@Override
    public void removeInstanceChangeListener(String serviceName, ServiceInstanceChangeListener listener) throws ServiceException {
        ServiceInstanceUtils.validateManagerIsStarted(isStarted.get());
        ServiceInstanceUtils.validateServiceName(serviceName);
        if (listener == null) {
            throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
                    ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
                    "ServiceInstanceChangeListener");
        }

        getLookupService().removeServiceInstanceChangeListener(serviceName, listener);
    }
639391
public void stop()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "stop");

    synchronized (this)
    {
      active = false;
      // stop the liveness timer for sending ControlRequestHighestGeneratedTick, if needed

      //NOTE: the requestHighestGeneratedTickTimer will stop of its own accord once the
      //stream is noticed to be

      if (initRepeatHandler != null)
      {
        initRepeatHandler.cancel();
      }
      if (inactivityTimer != null)
      {
        inactivityTimer.cancel();
        inactivityTimer = null;
      }
      if (resetRequestAckSender != null)
      {
        resetRequestAckSender.stop();
      }
      // stop all the liveness timers for value ticks
      dem.stopTimer();
      if (imeRestorationHandler!=null)
        imeRestorationHandler.stopTimer();
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "stop");
  }
274587
public void clearLensDistortion() {
		detector.clearLensDistortion();
		if( refineGray != null )
			refineGray.clearLensDistortion();
		edgeIntensity.setTransform(null);
	}
813503
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    public static void detach(Activity activity, ViewTreeObserver.OnGlobalLayoutListener l) {
        ViewGroup contentView = activity.findViewById(android.R.id.content);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            contentView.getViewTreeObserver().removeOnGlobalLayoutListener(l);
        } else {
            //noinspection deprecation
            contentView.getViewTreeObserver().removeGlobalOnLayoutListener(l);
        }
    }
219720
protected boolean closeCamera() {
		if( verbose )
			Log.i(TAG,"closeCamera() activity="+getClass().getSimpleName());
		if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
			throw new RuntimeException("Attempted to close camera not on the main looper thread!");
		}

		boolean closed = false;

//		if( verbose ) {
//			StackTraceElement[] trace = new RuntimeException().getStackTrace();
//			for (int i = 0; i < Math.min(trace.length, 3); i++) {
//				System.out.println("[ " + i + " ] = " + trace[i].toString());
//			}
//		}

		// NOTE: Since open can only be called in the main looper this won't be enough to prevent
		// it from closing before it opens. That's why open.state exists
		open.mLock.lock();
		try {
			if( verbose )
				Log.i(TAG,"closeCamera: camera="+(open.mCameraDevice==null)+" state="+open.state);
			closePreviewSession();
			// close has been called while trying to open the camera!
			if( open.state == CameraState.OPENING ) {
				// If it's in this state that means an asych task is opening the camera. By changing the state
				// to closing it will not abort that process when the task is called.
				open.state = CameraState.CLOSING;
				if( open.mCameraDevice != null ) {
					throw new RuntimeException("BUG! Camera is opening and should be null until opened");
				}
			} else {
				if (null != open.mCameraDevice) {
					closed = true;
					open.closeCamera();
				}
				open.state = CameraState.CLOSED;
				open.clearCamera();
			}
		} finally {
			open.mLock.unlock();
		}
		return closed;
	}
1313218
function() {
			if (this.modeApplier) {
				this.modeApplier.removeEventListener("Highlight", this.listener.onHighlight);
				this.modeApplier.destroy();
			}
			if (this.annotationModel) {
				// remove annotation listeners
			}
			if (this.textView) {
				this.textView.removeEventListener("LineStyle", this.listener.onLineStyle);
				this.textView.removeEventListener("Destroy", this.listener.onDestroy);
			}
			this.textView = null;
			this.annotationModel = null;
			this.modeApplier = null;
			this.listener = null;
		}
1017669
void terminate( boolean removeFromActiveSession ) {
        if (!isLive()) {
            return;
        }

        isLive = false;

        JcrObservationManager jcrObservationManager = observationManager();
        if (jcrObservationManager != null) {
            jcrObservationManager.removeAllEventListeners();
        }

        cleanLocks();
        if (removeFromActiveSession) this.repository.runningState().removeSession(this);
        this.context.getSecurityContext().logout();
    }
474775
public void stopRecording() {
        IRecordingListener listener = null;
        if (recordingListener != null && (listener = recordingListener.get()).isRecording()) {
            sendRecordStopNotify();
            notifyRecordingStop();
            // remove the listener
            removeStreamListener(listener);
            // stop the recording listener
            listener.stop();
            // clear and null-out the thread local
            recordingListener.clear();
            recordingListener = null;
        }
    }
336488
@Override
  public void progressiveStop(CircularProgressDrawable.OnEndListener listener) {
    if (!mParent.isRunning() || mEndAnimator.isRunning()) {
      return;
    }
    mOnEndListener = listener;
    mEndAnimator.addListener(new SimpleAnimatorListener() {

      @Override
      public void onPreAnimationEnd(Animator animation) {
        mEndAnimator.removeListener(this);
        CircularProgressDrawable.OnEndListener endListener = mOnEndListener;
        mOnEndListener = null;

        if (isStartedAndNotCancelled()) {
          setEndRatio(0f);
          mParent.stop();
          if (endListener != null) {
            endListener.onEnd(mParent);
          }
        }
      }
    });
    mEndAnimator.start();
  }
915692
public void onDetach() {
        if (mBluringTask != null) {
            mBluringTask.cancel(true);
        }
        mBluringTask = null;
        mHoldingActivity = null;
    }
1329995
@SuppressWarnings("WeakerAccess")
    public synchronized void stop() {
        if (isRunning()) {
            BeatFinder.getInstance().removeBeatListener(beatListener);
            VirtualCdj.getInstance().removeUpdateListener(updateListener);
            running.set(false);
            positions.clear();
            updates.clear();
            deliverLifecycleAnnouncement(logger, false);
        }
    }
1215557
private void releaseCamera() {
        if (mDisplayView != null)
            releaseDisplayView();
        if (mCamera != null) {
            if (VERBOSE) Log.d(TAG, "releasing camera");
            mCamera.stopPreview();
            mCamera.release();
            mCamera = null;
        }
    }
230854
@Override
    public boolean stop() {
        synchronized(MetricCollectorSupport.class) {
            if (uploaderThread != null) {
                uploaderThread.cancel();
                uploaderThread.interrupt();
                uploaderThread = null;
                if (singleton == this) { // defensive check
                    singleton = null;
                }
                return true;
            }
        }
        return false;
    }
1169001
public synchronized void stop() {
        if (isRunning()) {
            VirtualCdj.getInstance().removeUpdateListener(updateListener);
            running.set(false);
            pendingUpdates.clear();
            queueHandler.interrupt();
            queueHandler = null;

            // Report the loss of our hot cached metadata on the proper thread, outside our lock
            final Set<DeckReference> dyingCache = new HashSet<DeckReference>(hotCache.keySet());
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    for (DeckReference deck : dyingCache) {
                        if (deck.hotCue == 0) {
                            deliverTrackMetadataUpdate(deck.player, null);
                        }
                    }

                }
            });
            hotCache.clear();
            deliverLifecycleAnnouncement(logger, false);
        }
    }
506083
@Override
    public void onDestroyView() {
        mHandler.removeCallbacks(mRequestFocus);
        mGridView = null;
        mGridShown = false;
        mEmptyView = mProgressContainer = mGridContainer = null;
        mStandardEmptyView = null;
        super.onDestroyView();
    }