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()
}
/**