예제 #1
0
        protected override void OnStop()
        {
            base.OnStop();
            if (_boxThread.IsAlive)
            {
                _cameraActive = false;
            }
            //wait for thread to abort
            int c = 0;
            while (_boxThread.IsAlive && c < 5000)
            {
                Thread.Sleep(1);
                c++;
            }
			if (_camera != null) {
				_camera.AutoFocus (null);
				_camera.Unlock ();
				_camera.StopPreview ();
				_camera.SetPreviewCallback (null);
				_camera.Release ();
				_camera = null;
			}
            if (_api.Initialized)
            {
                _api.Dispose();
            }
            if (!_boxThread.IsAlive)
            {
				_holderBox.RemoveCallback (this);
                _holderBox.Dispose();
                _surfaceBox.SetOnTouchListener(null);
                _surfaceBox.Dispose();
            }
			_holderCamera.RemoveCallback (this);
            _holderCamera.Dispose();
            _surfaceCamera.Dispose();
            _box = null;
            _data = null;
            _touchState = TouchState.None;
            bitmap.Recycle();
            GC.Collect();
            Java.Lang.JavaSystem.Gc();
        }
예제 #2
0
 public void SurfaceCreated(ISurfaceHolder holder)
 {
     if (holder.Equals(_holderCamera))
     {
         CreateCamera(holder);
     }
     else if (holder.Equals(_holderBox))
     {
         screenWidth = _surfaceBox.Width;
         screenHeight = _surfaceBox.Height;
         lineDistance = screenWidth / 20;
         _box = new CameraBox(screenWidth, screenHeight);
         _boxThread.Start();
     }
 }