diff --git a/app/src/main/java/org/mozilla/focus/search/RadioSearchEngineListPreference.kt b/app/src/main/java/org/mozilla/focus/search/RadioSearchEngineListPreference.kt index 74d855be1c3..eda57017ff4 100644 --- a/app/src/main/java/org/mozilla/focus/search/RadioSearchEngineListPreference.kt +++ b/app/src/main/java/org/mozilla/focus/search/RadioSearchEngineListPreference.kt @@ -39,14 +39,14 @@ class RadioSearchEngineListPreference : SearchEngineListPreference, RadioGroup.O } override fun onCheckedChanged(group: RadioGroup, checkedId: Int) { - val selectedEngine = group.getChildAt(checkedId) + val selectedEngine = group.getChildAt(checkedId) ?: return // check if the corresponding button was pressed or a11y focused. val hasProperState = selectedEngine.isPressed || selectedEngine.isAccessibilityFocused /* onCheckedChanged is called intermittently before the search engine table is full, so we must check these conditions to prevent crashes and inconsistent states. */ - if (group.childCount != searchEngines.count() || selectedEngine == null || !hasProperState) { + if (group.childCount != searchEngines.count() || !hasProperState) { return }