/** {@inheritDoc} */
 @Override
 public void onPause() {
   super.onPause();
   camera.setPreviewCallback(null);
   if (inPreview) camera.stopPreview();
   inPreview = false;
   camera.release();
   camera = null;
 }
  /** {@inheritDoc} */
  @Override
  public void onSensorChanged(SensorEvent evt) {
    super.onSensorChanged(evt);

    if (evt.sensor.getType() == Sensor.TYPE_ACCELEROMETER
        || evt.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
      augmentedView.postInvalidate();
    }
  }
  /** {@inheritDoc} */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    camScreen = new CameraSurface(this);
    setContentView(camScreen);

    augmentedView = new AugmentedView(this);
    augmentedView.setOnTouchListener(this);
    LayoutParams augLayout = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    addContentView(augmentedView, augLayout);

    zoomLayout = new LinearLayout(this);
    zoomLayout.setVisibility((showZoomBar) ? LinearLayout.VISIBLE : LinearLayout.GONE);
    zoomLayout.setOrientation(LinearLayout.VERTICAL);
    zoomLayout.setPadding(5, 5, 5, 5);
    zoomLayout.setBackgroundColor(ZOOMBAR_BACKGROUND_COLOR);

    endLabel = new VerticalTextView(this);
    endLabel.setText(END_TEXT);
    endLabel.setTextColor(END_TEXT_COLOR);
    LinearLayout.LayoutParams zoomTextParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    zoomTextParams.gravity = Gravity.CENTER;
    zoomLayout.addView(endLabel, zoomTextParams);

    myZoomBar = new VerticalSeekBar(this);
    myZoomBar.setMax(100);
    myZoomBar.setProgress(50);
    myZoomBar.setOnSeekBarChangeListener(myZoomBarOnSeekBarChangeListener);
    LinearLayout.LayoutParams zoomBarParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
    zoomBarParams.gravity = Gravity.CENTER_HORIZONTAL;
    zoomLayout.addView(myZoomBar, zoomBarParams);

    FrameLayout.LayoutParams frameLayoutParams =
        new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT, Gravity.RIGHT);
    addContentView(zoomLayout, frameLayoutParams);

    updateDataOnZoom();

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");
  }
  /** {@inheritDoc} */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_motion);

    preview = (SurfaceView) findViewById(R.id.preview);
    previewHolder = preview.getHolder();
    previewHolder.addCallback(surfaceCallback);
    previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    if (Preferences.USE_RGB) {
      detector = new RgbMotionDetection();
    } else if (Preferences.USE_LUMA) {
      detector = new LumaMotionDetection();
    } else {
      // Using State based (aggregate map)
      detector = new AggregateLumaMotionDetection();
    }
  }
  /** {@inheritDoc} */
  @Override
  public void onPause() {
    super.onPause();

    wakeLock.release();
  }
  /** {@inheritDoc} */
  @Override
  public void onResume() {
    super.onResume();

    wakeLock.acquire();
  }
 /** {@inheritDoc} */
 @Override
 public void onResume() {
   super.onResume();
   camera = Camera.open();
 }
 /** {@inheritDoc} */
 @Override
 public void onConfigurationChanged(Configuration newConfig) {
   super.onConfigurationChanged(newConfig);
 }