Skip to content

Conversation

@Fabtron
Copy link
Collaborator

@Fabtron Fabtron commented Feb 17, 2025

instead of throwing an exception and crashing the app a loading indicator is now shown until a project is available.

My assumption is that through the custom lifecycle a race condition happens where the fab button can be clicked while no project is set.

APPS-2155

How to test?

Integrate the sdk into an app where this view is used and apply this patch

Index: ui/src/main/java/io/snabble/sdk/ui/payment/PaymentCredentialsListFragment.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/ui/src/main/java/io/snabble/sdk/ui/payment/PaymentCredentialsListFragment.kt b/ui/src/main/java/io/snabble/sdk/ui/payment/PaymentCredentialsListFragment.kt
--- a/ui/src/main/java/io/snabble/sdk/ui/payment/PaymentCredentialsListFragment.kt	(revision 46053cc1447b8051bfe86f95ce494f4912b5adab)
+++ b/ui/src/main/java/io/snabble/sdk/ui/payment/PaymentCredentialsListFragment.kt	(date 1739776443474)
@@ -2,12 +2,15 @@
 
 import android.os.Bundle
 import android.view.View
+import androidx.lifecycle.lifecycleScope
 import io.snabble.sdk.Project
 import io.snabble.sdk.Snabble
 import io.snabble.sdk.payment.PaymentCredentials
 import io.snabble.sdk.ui.BaseFragment
 import io.snabble.sdk.ui.R
 import io.snabble.sdk.ui.utils.serializableExtra
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
 
 open class PaymentCredentialsListFragment : BaseFragment(
     layoutResId = R.layout.snabble_fragment_payment_credentials_list,
@@ -30,6 +33,9 @@
 
     override fun onActualViewCreated(view: View, savedInstanceState: Bundle?) {
         val v = view as PaymentCredentialsListView
-        type?.let { v.show(it, project) } ?: v.setProject(project)
+        lifecycleScope.launch {
+            delay(3000)
+            type?.let { v.show(it, project) } ?: v.setProject(project)
+        }
     }
 }

Switch to the branch and check it out again.

Definition of Done

  • Issue is linked
  • All requirements of the issue are fulfilled
  • Changelog is updated
  • Documentation is updated
  • Self-Review
  • Review with the Product Owner (Release-Variante o. Minified Build)

App Tests

  • Minified build has been tested (aka. Release Build)
  • Environments have been taken care of (Production/Staging)
  • Supported languages have been tested
  • Light-/Dark-Mode has been tested
  • Edge-Cases have been tested
  • Android API Levels have been taken care of (minSdk?)

Testing

  • Tests have been written (aka Unit-Tests, Integration-Tests, ...)

@Fabtron Fabtron changed the title Fix crash when adding a credit card (APPS-2155) Feb 17, 2025
@Fabtron Fabtron requested a review from rekire February 17, 2025 15:27
@Fabtron Fabtron marked this pull request as ready for review February 17, 2025 15:30
@Fabtron Fabtron merged commit fa45782 into main Feb 18, 2025
1 check passed
@Fabtron Fabtron deleted the apps-2155-fix-crash-while-adding-a-credit-card branch February 18, 2025 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants