From 9505a6248e46e5cc9f7843ee4c637a88058e30ee Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Fri, 3 Nov 2023 14:15:38 +0000 Subject: [PATCH] Address some lifecycle issues Affects: https://ebce-lyrasis.atlassian.net/browse/PP-676 --- README-CHANGES.xml | 9 ++++++-- .../viewer/epub/readium2/Reader2Activity.kt | 21 +++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/README-CHANGES.xml b/README-CHANGES.xml index facdc56fa..56a88636e 100644 --- a/README-CHANGES.xml +++ b/README-CHANGES.xml @@ -350,7 +350,7 @@ - + @@ -358,11 +358,16 @@ - + + + + + + diff --git a/simplified-viewer-epub-readium2/src/main/java/org/librarysimplified/viewer/epub/readium2/Reader2Activity.kt b/simplified-viewer-epub-readium2/src/main/java/org/librarysimplified/viewer/epub/readium2/Reader2Activity.kt index 1a7abaffb..3982a37a9 100644 --- a/simplified-viewer-epub-readium2/src/main/java/org/librarysimplified/viewer/epub/readium2/Reader2Activity.kt +++ b/simplified-viewer-epub-readium2/src/main/java/org/librarysimplified/viewer/epub/readium2/Reader2Activity.kt @@ -438,14 +438,23 @@ class Reader2Activity : AppCompatActivity(R.layout.reader2) { ) } + @Deprecated("Deprecated in Java") override fun onBackPressed() { - if (this.tocFragment.isVisible) { - this.tocClose() - } else if (this.searchFragment.isVisible) { - this.searchClose() - } else { - super.onBackPressed() + if (this::tocFragment.isInitialized) { + if (this.tocFragment.isVisible) { + this.tocClose() + return + } + } + + if (this::searchFragment.isInitialized) { + if (this.searchFragment.isVisible) { + this.searchClose() + return + } } + + super.onBackPressed() } /**