Skip to content

Commit f08b4d5

Browse files
committed
Release activity on destroy callback
Signed-off-by: Simone Arpe <[email protected]>
1 parent 9b20296 commit f08b4d5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

android/src/main/java/com/pspdfkit/flutter/pspdfkit/FlutterPdfActivity.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ protected void onCreate(Bundle bundle) {
3030
bindActivity();
3131
}
3232

33+
@Override
34+
protected void onDestroy() {
35+
super.onDestroy();
36+
releaseActivity();
37+
}
38+
3339
@Override
3440
public void onDocumentLoaded(@NonNull PdfDocument pdfDocument) {
3541
super.onDocumentLoaded(pdfDocument);
@@ -52,6 +58,14 @@ private void bindActivity() {
5258
currentActivity = this;
5359
}
5460

61+
private void releaseActivity() {
62+
Result result = loadedDocumentResult.getAndSet(null);
63+
if (result != null) {
64+
result.success(false);
65+
}
66+
currentActivity = null;
67+
}
68+
5569
public static FlutterPdfActivity getCurrentActivity() {
5670
return currentActivity;
5771
}

0 commit comments

Comments
 (0)