@@ -60,38 +60,52 @@ export class CameraView extends CameraViewBase {
6060 this . nativeViewProtected ?. setAnalyserCallback ( this . _processor ) ;
6161 }
6262
63+ get minZoom ( ) {
64+ return this . nativeViewProtected ?. getMinZoom ( ) ;
65+ }
66+ get maxZoom ( ) {
67+ return this . nativeViewProtected ?. getMaxZoom ( ) ;
68+ }
69+
6370 initNativeView ( ) {
6471 super . initNativeView ( ) ;
6572 const nativeView = this . nativeViewProtected ;
6673 nativeView [ 'refreshCameraDelay' ] = this . refreshCameraDelay ;
6774
75+ const that = new WeakRef ( this ) ;
6876 const listener = ( this . listener = new com . nativescript . cameraview . CameraEventListener ( {
6977 onReady ( ) { } ,
7078 onCameraOpen : ( ) => {
71- this . notify ( { eventName : 'cameraOpen' } ) ;
79+ that ?. get ( ) ? .notify ( { eventName : 'cameraOpen' } ) ;
7280 } ,
7381 onCameraVideo ( param0 ) { } ,
7482 onCameraAnalysis ( param0 ) { } ,
7583 onCameraVideoStart ( ) { } ,
7684 onZoom : ( zoom : number ) => {
77- this . notify ( { eventName : 'zoom' , zoom } ) ;
85+ that ?. get ( ) ? .notify ( { eventName : 'zoom' , zoom } ) ;
7886 } ,
7987 onCameraError : ( param0 : string , error ) => {
80- this . photoListeners ?. forEach ( ( c ) => c . onCameraError ( param0 , error ) ) ;
88+ that ?. get ( ) ? .photoListeners ?. forEach ( ( c ) => c . onCameraError ( param0 , error ) ) ;
8189 } ,
8290 onCameraClose : ( ) => {
83- this . notify ( { eventName : 'cameraClose' } ) ;
84- this . photoListeners ?. forEach ( ( c ) => c . onCameraClose ( ) ) ;
91+ const owner = that ?. get ( ) ;
92+ if ( owner ) {
93+ owner . notify ( { eventName : 'cameraClose' } ) ;
94+ owner . photoListeners ?. forEach ( ( c ) => c . onCameraClose ( ) ) ;
95+ }
8596 } ,
8697 onCameraPhoto : ( file : android . net . Uri ) => {
87- const result = file . toString ( ) ;
88- this . photoListeners ?. forEach ( ( c ) => c . onCameraPhoto ( result ) ) ;
98+ const owner = that ?. get ( ) ;
99+ if ( owner ) {
100+ const result = file . toString ( ) ;
101+ this . photoListeners ?. forEach ( ( c ) => c . onCameraPhoto ( result ) ) ;
102+ }
89103 } ,
90104 onCameraPhotoImage : ( image , info ) => {
91- this . photoListeners ?. forEach ( ( c ) => c . onCameraPhotoImage ( image , info ) ) ;
105+ that ?. get ( ) ? .photoListeners ?. forEach ( ( c ) => c . onCameraPhotoImage ( image , info ) ) ;
92106 } ,
93107 onCameraPhotoImageProxy : ( image , processor ) => {
94- this . photoListeners ?. forEach ( ( c ) => c . onCameraPhotoImageProxy ( image , processor ) ) ;
108+ that ?. get ( ) ? .photoListeners ?. forEach ( ( c ) => c . onCameraPhotoImageProxy ( image , processor ) ) ;
95109 }
96110 } ) ) ;
97111 nativeView . setListener ( listener ) ;
0 commit comments