Skip to content

Commit 039d841

Browse files
author
AnuragMishra-akm
committed
Fix: prevent null crash in DeckPicker ResizablePaneManager initialization
1 parent f60f733 commit 039d841

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -811,15 +811,24 @@ open class DeckPicker :
811811
if (fragmented) {
812812
loadStudyOptionsFragment()
813813

814-
ResizablePaneManager(
815-
parentLayout = requireNotNull(binding.deckpickerXlView),
816-
divider = requireNotNull(binding.resizingDivider),
817-
leftPane = deckPickerBinding.root,
818-
rightPane = requireNotNull(binding.studyoptionsFragment),
819-
sharedPrefs = Prefs.getUiConfig(this),
820-
leftPaneWeightKey = PREF_DECK_PICKER_PANE_WEIGHT,
821-
rightPaneWeightKey = PREF_STUDY_OPTIONS_PANE_WEIGHT,
822-
)
814+
val xlView = binding.deckpickerXlView
815+
val divider = binding.resizingDivider
816+
val rightPaneView = binding.studyoptionsFragment
817+
818+
// Avoid crash if tablet layout is not actually loaded
819+
if (xlView != null && divider != null && rightPaneView != null) {
820+
ResizablePaneManager(
821+
parentLayout = xlView,
822+
divider = divider,
823+
leftPane = deckPickerBinding.root,
824+
rightPane = rightPaneView,
825+
sharedPrefs = Prefs.getUiConfig(this),
826+
leftPaneWeightKey = PREF_DECK_PICKER_PANE_WEIGHT,
827+
rightPaneWeightKey = PREF_STUDY_OPTIONS_PANE_WEIGHT,
828+
)
829+
} else {
830+
Timber.w("XL PaneManager skipped because one or more views were null")
831+
}
823832
}
824833
}
825834
is StartupResponse.FatalError -> handleStartupFailure(response.failure)

0 commit comments

Comments
 (0)