#android #android-fragments #android-architecture-navigation #android-navigation #bottomsheetdialogfragment
Вопрос:
У меня есть 3 фрагмента в нижней навигационной панели
-> с третьим фрагментом, имеющим страницу просмотра 2 с 2 фрагментами в них.
-> Нажатие на кнопку в одном из фрагментов viewpager открывает фрагмент нижней таблицы и после выполнения нескольких шагов в этом фрагменте нижней таблицы.
-> этот фрагмент отклоняется, и открывается другой фрагмент нижней таблицы.
Когда последний фрагмент BottomSheetDialog закрыт, приложение завершает работу со следующей ошибкой
java.util.NoSuchElementException: Collection contains no element matching the predicate.
at androidx.navigation.fragment.DialogFragmentNavigator$observer$1.onStateChanged(DialogFragmentNavigator.kt:216)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.java:284)
at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:302)
at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:148)
at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:134)
at androidx.fragment.app.Fragment.performStop(Fragment.java:3179)
at androidx.fragment.app.FragmentStateManager.stop(FragmentStateManager.java:619)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:297)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1793)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1711)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1654)
at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:488)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7660)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Я обновился до навигационной библиотеки 2.4.0-alpha03 месяц назад и проигнорировал эту проблему, думая, что она находится в альфа-версии и будет исправлена, alpha05 вышел и все еще остается прежним, я решил перейти на стабильную версию 2.3.5, и ошибка сохраняется.
Вот градуировка (модуль)
apply plugin: "androidx.navigation.safeargs.kotlin"
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.0-alpha05'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.0-alpha05'
градуировка (модуль)
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.0-alpha05"
График навигации выглядит следующим образом
<fragment
android:id="@ id/profile"
android:name="com.example.user.profile.ProfileFragment"
android:label="Profile"
tools:layout="@layout/fragment_profile">
<action
android:id="@ id/action_profile_to_editProfileFragment"
app:destination="@id/editProfileFragment"
app:enterAnim="@anim/from_right"
app:exitAnim="@anim/to_left"
app:popEnterAnim="@anim/from_left"
app:popExitAnim="@anim/to_right" />
<action
android:id="@ id/action_profile_to_predefinedHabitsFragment"
app:destination="@id/predefinedHabitsFragment" />
<action
android:id="@ id/action_profile_to_editHabitBottomSheetFragment"
app:destination="@id/editHabitBottomSheetFragment" />
</fragment>
<dialog
android:id="@ id/addPredefinedHabitBottomSheet"
android:name="com.example.habits.add.predefined.AddPredefinedHabitBottomSheet"
android:label="AddPredefinedHabitBottomSheet"
tools:layout="@layout/add_predefined_habit_bottom_sheet">
<argument
android:name="habitData"
app:argType="com.example.predefined.models.PredefinedHabitsModelItem" />
</dialog>
<dialog
android:id="@ id/addCustomHabitBottomSheet"
android:name="com.iku.habits.add.custom.AddCustomHabitBottomSheet"
android:label="AddCustomHabitBottomSheet"
tools:layout="@layout/add_custom_habit_bottom_sheet" />
Комментарии:
1. Я вижу то же самое. У меня есть веб-представление, затем перейдите к фрагменту диалога. Откройте этот фрагмент диалогового окна, затем перейдите к другому фрагменту диалогового окна. Затем откройте этот фрагмент диалога и завершите работу.
2. Пожалуйста, найдите соответствующую проблему в вопросах Google здесь — issuetracker.google.com/issues/201524952
3. Привет @SamIAmHarris вот обновленная информация по этому вопросу issuetracker.google.com/issues/191073055#comment14
Ответ №1:
Решение этой проблемы описано в выпуске Google — https://issuetracker.google.com/issues/191073055#comment14