Skip to content

Commit

Permalink
Fixed: Application crashes at first launch.
Browse files Browse the repository at this point in the history
  • Loading branch information
MohitMaliDeveloper committed Dec 6, 2024
1 parent c33fc58 commit c26138c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ class KiwixReaderFragment : CoreReaderFragment() {
when (restoreOrigin) {
FromExternalLaunch -> {
coreReaderLifeCycleScope?.launch {
if (!isAdded) return@launch
val settings =
requireActivity().getSharedPreferences(SharedPreferenceUtil.PREF_KIWIX_MOBILE, 0)
val zimReaderSource = fromDatabaseValue(settings.getString(TAG_CURRENT_FILE, null))
activity?.getSharedPreferences(SharedPreferenceUtil.PREF_KIWIX_MOBILE, 0)
val zimReaderSource = fromDatabaseValue(settings?.getString(TAG_CURRENT_FILE, null))
if (zimReaderSource?.canOpenInLibkiwix() == true) {
if (zimReaderContainer?.zimReaderSource == null) {
openZimFile(zimReaderSource, isFromManageExternalLaunch = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,7 @@ abstract class CoreReaderFragment :
override fun onDestroyView() {
super.onDestroyView()
try {
coreReaderLifeCycleScope?.cancel()
readerLifeCycleScope?.cancel()
readerLifeCycleScope = null
} catch (ignore: Exception) {
Expand Down

0 comments on commit c26138c

Please sign in to comment.