diff --git a/android/src/main/java/pt/tribeiro/flutter_plugin_pdf_viewer/FlutterPluginPdfViewerPlugin.java b/android/src/main/java/pt/tribeiro/flutter_plugin_pdf_viewer/FlutterPluginPdfViewerPlugin.java index 27570865..0243e749 100644 --- a/android/src/main/java/pt/tribeiro/flutter_plugin_pdf_viewer/FlutterPluginPdfViewerPlugin.java +++ b/android/src/main/java/pt/tribeiro/flutter_plugin_pdf_viewer/FlutterPluginPdfViewerPlugin.java @@ -85,13 +85,14 @@ public void run() { if (pageResult == null) { Log.d(TAG, "Retrieving page failed."); result.notImplemented(); + } else { + mainThreadHandler.post(new Runnable() { + @Override + public void run() { + result.success(pageResult); + } + }); } - mainThreadHandler.post(new Runnable() { - @Override - public void run() { - result.success(pageResult); - } - }); break; default: result.notImplemented(); @@ -200,7 +201,6 @@ private String getPage(String filePath, @Nullable Integer pageNumber) { ret = createTempPreview(bitmap, filePath, pageNumber); } finally { page.close(); - renderer.close(); } return ret; } catch (Exception ex) {