@@ -44,7 +44,6 @@ import com.ichi2.anki.R
44
44
import com.ichi2.anki.analytics.AnalyticsDialogFragment
45
45
import com.ichi2.anki.common.utils.annotation.KotlinCleanup
46
46
import com.ichi2.anki.dialogs.DeckSelectionDialog.DecksArrayAdapter.DecksFilter
47
- import com.ichi2.anki.dialogs.DeckSelectionDialog.SelectableDeck
48
47
import com.ichi2.anki.launchCatchingTask
49
48
import com.ichi2.anki.showThemedToast
50
49
import com.ichi2.annotations.NeedsTest
@@ -247,23 +246,22 @@ open class DeckSelectionDialog : AnalyticsDialogFragment() {
247
246
if (field != null ) {
248
247
return field
249
248
}
249
+ val parentFragment = parentFragment
250
+ if (parentFragment is DeckSelectionListener ) {
251
+ return parentFragment
252
+ }
250
253
val activity: Activity = requireActivity()
251
254
if (activity is DeckSelectionListener ) {
252
255
return activity
253
256
}
254
- val parentFragment = parentFragment
255
- if (parentFragment is DeckSelectionListener ) {
256
- return parentFragment
257
- } else {
258
- // try to find inside the activity an active fragment that is a DeckSelectionListener
259
- val foundAvailableFragments =
260
- parentFragmentManager.fragments.filter {
261
- it.isResumed && it is DeckSelectionListener
262
- }
263
- if (foundAvailableFragments.isNotEmpty()) {
264
- // if we found at least one resumed candidate fragment use it
265
- return foundAvailableFragments[0 ] as DeckSelectionListener
257
+ // try to find inside the activity an active fragment that is a DeckSelectionListener
258
+ val foundAvailableFragments =
259
+ parentFragmentManager.fragments.filter {
260
+ it.isResumed && it is DeckSelectionListener
266
261
}
262
+ if (foundAvailableFragments.isNotEmpty()) {
263
+ // if we found at least one resumed candidate fragment use it
264
+ return foundAvailableFragments[0 ] as DeckSelectionListener
267
265
}
268
266
throw IllegalStateException (" Neither activity or any fragment in the activity were a selection listener" )
269
267
}
0 commit comments