@@ -9,6 +9,16 @@ export class PDFView extends common.PDFView {
99 private promise : Promise < any > ;
1010 private tempFolder = fs . knownFolders . temp ( ) . getFolder ( 'PDFViewer.temp/' ) ;
1111
12+ private onLoadHandler = ( ( ) => {
13+ const pdfViewRef = new WeakRef ( this ) ;
14+
15+ return new pdfviewer . listener . OnLoadCompleteListener ( {
16+ loadComplete : ( numPages ) => {
17+ common . PDFView . notifyOfEvent ( common . PDFView . loadEvent , pdfViewRef ) ;
18+ }
19+ } ) ;
20+ } ) ( ) ;
21+
1222 public get android ( ) {
1323 return this . _android ;
1424 }
@@ -17,12 +27,12 @@ export class PDFView extends common.PDFView {
1727 this . _android = value ;
1828 }
1929
20- public load ( src : string ) {
30+ public loadPDF ( src : string ) {
2131 if ( ! src || ! this . android ) {
2232 return ;
2333 }
2434
25- // reset any previous promise since we've called load again
35+ // reset any previous promise since we've called loadPDF again
2636 this . promise = void 0 ;
2737
2838 if ( src . indexOf ( '://' ) === - 1 ) {
@@ -36,6 +46,7 @@ export class PDFView extends common.PDFView {
3646
3747 this . android
3848 . fromUri ( uri )
49+ . onLoad ( this . onLoadHandler )
3950 . load ( ) ;
4051 }
4152
@@ -48,7 +59,7 @@ export class PDFView extends common.PDFView {
4859 . getFile ( url , `${ this . tempFolder . path } /${ java . util . UUID . randomUUID ( ) } ` )
4960 . then ( file => {
5061 if ( this . promise === promise ) { // make sure we haven't switched
51- this . load ( file . path ) ;
62+ this . loadPDF ( file . path ) ;
5263 }
5364 } ) . catch ( error => {
5465 console . error ( error ) ;
@@ -58,6 +69,6 @@ export class PDFView extends common.PDFView {
5869
5970 private _createUI ( ) {
6071 this . _android = new pdfviewer . PDFView ( this . _context , void 0 ) ;
61- this . load ( this . src ) ;
72+ this . loadPDF ( this . src ) ;
6273 }
6374}
0 commit comments