gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-android] branch master updated: [wallet] try not to instant


From: gnunet
Subject: [taler-taler-android] branch master updated: [wallet] try not to instantiate TalerWalletCore more than once
Date: Wed, 30 Aug 2023 16:41:12 +0200

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a commit to branch master
in repository taler-android.

The following commit(s) were added to refs/heads/master by this push:
     new f0e923c  [wallet] try not to instantiate TalerWalletCore more than once
f0e923c is described below

commit f0e923cee082015e21260e20d42c88456160c7d6
Author: Torsten Grote <t@grobox.de>
AuthorDate: Wed Aug 30 16:40:20 2023 +0200

    [wallet] try not to instantiate TalerWalletCore more than once
---
 wallet/src/main/AndroidManifest.xml                             | 2 +-
 wallet/src/main/java/net/taler/wallet/backend/BackendManager.kt | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/wallet/src/main/AndroidManifest.xml 
b/wallet/src/main/AndroidManifest.xml
index 96c2958..aee1525 100644
--- a/wallet/src/main/AndroidManifest.xml
+++ b/wallet/src/main/AndroidManifest.xml
@@ -48,7 +48,7 @@
         <activity
             android:name=".MainActivity"
             android:exported="true"
-            android:launchMode="singleTop"
+            android:launchMode="singleInstance"
             android:theme="@style/AppTheme.NoActionBar">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
diff --git a/wallet/src/main/java/net/taler/wallet/backend/BackendManager.kt 
b/wallet/src/main/java/net/taler/wallet/backend/BackendManager.kt
index ae338e8..b2f1f10 100644
--- a/wallet/src/main/java/net/taler/wallet/backend/BackendManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/backend/BackendManager.kt
@@ -22,6 +22,7 @@ import kotlinx.serialization.json.Json
 import net.taler.qtart.TalerWalletCore
 import net.taler.wallet.BuildConfig
 import org.json.JSONObject
+import java.util.concurrent.atomic.AtomicBoolean
 import kotlin.coroutines.resume
 import kotlin.coroutines.suspendCoroutine
 
@@ -40,12 +41,16 @@ class BackendManager(
         val json = Json {
             ignoreUnknownKeys = true
         }
+        @JvmStatic
+        private val initialized = AtomicBoolean(false)
     }
 
     private val walletCore = TalerWalletCore()
     private val requestManager = RequestManager()
 
     init {
+        // TODO using Dagger/Hilt and @Singleton would be nice as well
+        if (initialized.getAndSet(true)) error("Already initialized")
         walletCore.setMessageHandler { onMessageReceived(it) }
         if (BuildConfig.DEBUG) walletCore.setStdoutHandler {
             Log.d(TAG_CORE, it)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]