From 564631291444e615d443e2bd4f6e00d8252602d8 Mon Sep 17 00:00:00 2001 From: Hicham Boushaba Date: Wed, 13 Nov 2024 15:12:01 +0100 Subject: [PATCH 1/2] Ignore click events when the view is not attached to a window When we don't handle this check, there are cases where the click might occur when the navController is not attached anymore, and would cause a crash. --- .../views/OrderDetailCustomerInfoView.kt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/details/views/OrderDetailCustomerInfoView.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/details/views/OrderDetailCustomerInfoView.kt index afdf4f10cc18..d2290ec4e14b 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/details/views/OrderDetailCustomerInfoView.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/details/views/OrderDetailCustomerInfoView.kt @@ -240,11 +240,7 @@ class OrderDetailCustomerInfoView @JvmOverloads constructor( ) binding.customerInfoCustomerNoteSection.setOnClickListener { - val action = - OrderDetailFragmentDirections.actionOrderDetailFragmentToEditCustomerOrderNoteFragment( - order.id - ) - findNavController().navigateSafely(action) + navigateToCustomerNote(order) } } } @@ -290,13 +286,26 @@ class OrderDetailCustomerInfoView @JvmOverloads constructor( } } + private fun navigateToCustomerNote(order: Order) { + if (!isAttachedToWindow) return + + val action = OrderDetailFragmentDirections.actionOrderDetailFragmentToEditCustomerOrderNoteFragment( + order.id + ) + findNavController().navigateSafely(action) + } + private fun navigateToShippingAddressEditingView(address: Address) { + if (!isAttachedToWindow) return + OrderDetailFragmentDirections .actionOrderDetailFragmentToShippingAddressEditingFragment(storedAddress = address) .let { findNavController().navigateSafely(it) } } private fun navigateToBillingAddressEditingView(address: Address) { + if (!isAttachedToWindow) return + OrderDetailFragmentDirections .actionOrderDetailFragmentToBillingAddressEditingFragment(storedAddress = address) .let { findNavController().navigateSafely(it) } From aa2a8f7bcdccb86877e8b8b4b444b6b943bf8321 Mon Sep 17 00:00:00 2001 From: Hicham Boushaba Date: Wed, 13 Nov 2024 16:57:15 +0100 Subject: [PATCH 2/2] Add a release note --- RELEASE-NOTES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 343cd58bae19..3dff33db48e9 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -3,7 +3,7 @@ *** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too. 21.2 ----- - +- [*] Fixed a crash that occurred when tapping on the customer shipping address in the order details screen [https://github.com/woocommerce/woocommerce-android/pull/12920] 21.1 -----