android / architecture-samples

A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.
Apache License 2.0
44.13k stars 11.6k forks source link

Snackbar shown again on popBackstack() #961

Open kosavsech opened 1 year ago

kosavsech commented 1 year ago

https://github.com/android/architecture-samples/blob/03d9af0b6a1ab82e450ca7c45f973a119412a9ab/app/src/main/java/com/example/android/architecture/blueprints/todoapp/tasks/TasksScreen.kt#L121-L128 This part of code being legitimately trigger by https://github.com/android/architecture-samples/blob/03d9af0b6a1ab82e450ca7c45f973a119412a9ab/app/src/main/java/com/example/android/architecture/blueprints/todoapp/TodoNavGraph.kt#L96-L100 or https://github.com/android/architecture-samples/blob/03d9af0b6a1ab82e450ca7c45f973a119412a9ab/app/src/main/java/com/example/android/architecture/blueprints/todoapp/TodoNavGraph.kt#L110 But after you can go to task details again and click go back arrow in top bar. https://github.com/android/architecture-samples/blob/03d9af0b6a1ab82e450ca7c45f973a119412a9ab/app/src/main/java/com/example/android/architecture/blueprints/todoapp/taskdetail/TaskDetailScreen.kt#L66-L68 Last snackbar message will be shown again. But this time, in my opinion, because there is copy of route with USER_MESSAGE_ARG in backstack.

How this can be fixed or bypassed?

CodPro-Sui commented 9 months ago

override fun onDestroyView() { super.onDestroyView() // Dismiss the Snackbar if it's currently shown snackbar?.dismiss() } #