From 3c3ac5856d8e48fc01a268b004ed5e545a87d6f9 Mon Sep 17 00:00:00 2001 From: Aditi Bhatia Date: Fri, 7 Jun 2024 17:27:53 -0700 Subject: [PATCH 1/2] Add initialization check --- .../java/org/wordpress/android/ui/reader/ReaderFragment.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderFragment.kt index ec1427374780..ea9bf586f22a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderFragment.kt @@ -396,7 +396,9 @@ class ReaderFragment : Fragment(R.layout.reader_fragment_layout), ScrollableView } fun requestBookmarkTab() { - viewModel.bookmarkTabRequested() + if (::viewModel.isInitialized) { + viewModel.bookmarkTabRequested() + } } private fun showReaderInterests() { From c6b8452508fc3cf75c214ff85f0f5800ebfe92eb Mon Sep 17 00:00:00 2001 From: Aditi Bhatia Date: Fri, 7 Jun 2024 17:40:03 -0700 Subject: [PATCH 2/2] Initialize viewmodel if not --- .../java/org/wordpress/android/ui/reader/ReaderFragment.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderFragment.kt index ea9bf586f22a..033a3b56f768 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderFragment.kt @@ -396,9 +396,10 @@ class ReaderFragment : Fragment(R.layout.reader_fragment_layout), ScrollableView } fun requestBookmarkTab() { - if (::viewModel.isInitialized) { - viewModel.bookmarkTabRequested() + if (!::viewModel.isInitialized) { + viewModel = ViewModelProvider(this@ReaderFragment, viewModelFactory)[ReaderViewModel::class.java] } + viewModel.bookmarkTabRequested() } private fun showReaderInterests() {