fix(android): fix crashes and faulty preview on Chrome 86+#125
fix(android): fix crashes and faulty preview on Chrome 86+#125timbru31 wants to merge 1 commit intocesarvr:masterfrom
Conversation
| super.onWriteFailed(error); | ||
|
|
||
| Log.d(TAG, "onWriteFailed: Failed!!! " + error.toString() ); | ||
| LOG.e(LOG_TAG, "onWriteFailed: Failed: " + error); |
There was a problem hiding this comment.
Here lies the reason of the crash. The error might be null according to the JavaDocs: https://developer.android.com/reference/android/print/PrintDocumentAdapter.WriteResultCallback#onWriteFailed(java.lang.CharSequence)
| LOG.i(APPNAME, "Cleaning pdfwriter & webView objects."); | ||
| LOG.d(LOG_TAG, "Cleaning pdfwriter & webView objects."); | ||
| mWrappedInstance.onFinish(); | ||
| webView.destroy(); |
There was a problem hiding this comment.
This ensures to destroy the webView instance after the user either printed or cancelled the share PDF intent.
acc5f50 to
3b78a66
Compare
| LOG.e(LOG_TAG, "getAsBase64 Error in I/O: ", ex); | ||
| cordovaCallback.error(IO_EXCEPTION); | ||
| } finally { | ||
| this.webView.destroy(); |
There was a problem hiding this comment.
This ensures that in both the success and error case of the base64 request the webView is successfully destroyed again.
3b78a66 to
d927e2d
Compare
| //.setMinMargins(PrintAttributes.Margins.NO_MARGINS).build(); | ||
|
|
||
|
|
||
| PrintDocumentAdapter printAdapter = null; |
There was a problem hiding this comment.
Before, a printerAdapater was always initialized, even when the target was share which uses the printerManager. Therefore, this code block was moved to the if block.
This is achieved by always using a new WebView instance and by destorying the old one fix(android): correct file name for temp folder fix(android): remove unused config file fix(android): register only one printer adapter fix(android): do not crash if error code is null (which is valid) refactor(android): use Cordova's log helper style: reformat codebase
d927e2d to
04c7491
Compare
This is achieved by always using a new WebView instance and by destorying the old one
fix(android): correct file name for temp folder
fix(android): remove unused config file
fix(android): register only one printer adapter
fix(android): do not crash if error code is null (which is valid)
refactor(android): use Cordova's log helper
style: reformat codebase
This fixes #124